Skip to content

Commit 5c4239e

Browse files
authored
Merge pull request #119 from oss-serverless/revert-113-fix-deployment-bucket-inus-east-1
2 parents a34162d + 26ce4a9 commit 5c4239e

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

lib/plugins/aws/deploy/lib/ensure-valid-bucket-exists.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
if (this.serverless.service.provider.deploymentBucket) {
2828
let result;
2929
try {
30-
result = await this.provider.request('S3', 'headBucket', {
30+
result = await this.provider.request('S3', 'getBucketLocation', {
3131
Bucket: this.bucketName,
3232
});
3333
} catch (err) {
@@ -37,8 +37,9 @@ module.exports = {
3737
);
3838
}
3939

40-
if (result.BucketRegion === 'EU') result.BucketRegion = 'eu-west-1';
41-
if (result.BucketRegion !== this.provider.getRegion()) {
40+
if (result.LocationConstraint === '') result.LocationConstraint = 'us-east-1';
41+
if (result.LocationConstraint === 'EU') result.LocationConstraint = 'eu-west-1';
42+
if (result.LocationConstraint !== this.provider.getRegion()) {
4243
throw new ServerlessError(
4344
'Deployment bucket is not in the same region as the lambda function',
4445
'DEPLOYMENT_BUCKET_INVALID_REGION'

test/unit/lib/plugins/aws/deploy/index.test.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,12 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
112112
deleteObjects: deleteObjectsStub,
113113
listObjectsV2: { Contents: [] },
114114
upload: s3UploadStub,
115+
headBucket: {},
115116
getBucketLocation: () => {
116117
return {
117118
LocationConstraint: 'us-east-1',
118119
};
119120
},
120-
headBucket: () => {
121-
return {
122-
BucketRegion: 'us-east-1',
123-
};
124-
},
125121
},
126122
CloudFormation: {
127123
describeStacks: describeStacksStub,
@@ -527,16 +523,12 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
527523
deleteObjects: deleteObjectsStub,
528524
listObjectsV2: { Contents: [] },
529525
upload: s3UploadStub,
526+
headBucket: {},
530527
getBucketLocation: () => {
531528
return {
532529
LocationConstraint: 'us-east-1',
533530
};
534531
},
535-
headBucket: () => {
536-
return {
537-
BucketRegion: 'us-east-1',
538-
};
539-
},
540532
},
541533
CloudFormation: {
542534
describeStacks: describeStacksStub,
@@ -1214,9 +1206,6 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
12141206
getBucketLocation: () => {
12151207
throw new Error();
12161208
},
1217-
headBucket: () => {
1218-
throw new Error();
1219-
},
12201209
},
12211210
CloudFormation: {
12221211
describeStacks: { Stacks: [{}] },
@@ -1253,11 +1242,6 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
12531242
LocationConstraint: 'us-west-1',
12541243
};
12551244
},
1256-
headBucket: () => {
1257-
return {
1258-
BucketRegion: 'us-west-1',
1259-
};
1260-
},
12611245
},
12621246
CloudFormation: {
12631247
describeStacks: { Stacks: [{}] },

0 commit comments

Comments
 (0)