mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
31 lines
952 B
JavaScript
31 lines
952 B
JavaScript
'use strict';
|
|
|
|
const BbPromise = require('bluebird');
|
|
|
|
module.exports = {
|
|
existsDeploymentBucket(bucketName) {
|
|
return BbPromise.resolve()
|
|
.then(() =>
|
|
this.provider.request('S3', 'getBucketLocation', {
|
|
Bucket: bucketName,
|
|
})
|
|
)
|
|
.then(resultParam => {
|
|
const result = resultParam;
|
|
if (result.LocationConstraint === '') result.LocationConstraint = 'us-east-1';
|
|
if (result.LocationConstraint === 'EU') result.LocationConstraint = 'eu-west-1';
|
|
if (result.LocationConstraint !== this.provider.getRegion()) {
|
|
throw new this.serverless.classes.Error(
|
|
'Deployment bucket is not in the same region as the lambda function'
|
|
);
|
|
}
|
|
return BbPromise.resolve();
|
|
})
|
|
.catch(err => {
|
|
throw new this.serverless.classes.Error(
|
|
`Could not locate deployment bucket. Error: ${err.message}`
|
|
);
|
|
});
|
|
},
|
|
};
|