mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #5714 from exoego/fix-5699
AWS: Tell S3 bucket name and how to recover if deployment bucket does not exist
This commit is contained in:
commit
d00e677df6
@ -41,7 +41,17 @@ module.exports = {
|
||||
return this.provider.request('S3',
|
||||
'listObjectsV2',
|
||||
params
|
||||
).then((result) => {
|
||||
).catch((reason) => {
|
||||
if (!_.includes(reason.message, 'The specified bucket does not exist')) {
|
||||
return BbPromise.reject(reason);
|
||||
}
|
||||
const stackName = this.provider.naming.getStackName();
|
||||
return BbPromise.reject(new this.serverless.classes.Error([
|
||||
`The serverless deployment bucket "${params.Bucket}" does not exist.`,
|
||||
`Create it manually if you want to reuse the CloudFormation stack "${stackName}",`,
|
||||
'or delete the stack if it is no longer required.',
|
||||
].join(' ')));
|
||||
}).then((result) => {
|
||||
if (result && result.Contents && result.Contents.length) {
|
||||
const objects = result.Contents;
|
||||
|
||||
|
||||
@ -135,6 +135,23 @@ describe('checkForChanges', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should translate error if rejected due to missing bucket', () => {
|
||||
listObjectsV2Stub
|
||||
.rejects(new serverless.classes.Error('The specified bucket does not exist'));
|
||||
|
||||
return expect(awsDeploy.getMostRecentObjects()).to.be.rejectedWith([
|
||||
`The serverless deployment bucket "${awsDeploy.bucketName}" does not exist.`,
|
||||
'Create it manually if you want to reuse the CloudFormation stack "my-service-dev",',
|
||||
'or delete the stack if it is no longer required.',
|
||||
].join(' '));
|
||||
});
|
||||
|
||||
it('should throw original error if rejected not due to missing bucket', () => {
|
||||
listObjectsV2Stub
|
||||
.rejects(new serverless.classes.Error('Other reason'));
|
||||
return expect(awsDeploy.getMostRecentObjects()).to.be.rejectedWith('Other reason');
|
||||
});
|
||||
|
||||
it('should resolve if result array is empty', () => {
|
||||
const serviceObjects = {
|
||||
Contents: [],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user