Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(AWS Deploy): Support disableRollback parameter #10236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/providers/aws/guide/serverless.yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ provider:
stackParameters:
- ParameterKey: 'Keyname'
ParameterValue: 'Value'
disableRollback: true # To be used for non-production environment
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you write "for non-production environment" here?

I think this param is to control a choice as to whether to attempt to fix a partial deployment, or to roll it all back. That's not necessarily tied to production or not.

"true" is required to work around AWS issues like aws-cloudformation/cloudformation-coverage-roadmap#573 , whether in production or non-production

(see also https://github.com/serverless/serverless/blame/f22354e8dd45871915e21e5656055a9213f93ff0/docs/providers/aws/guide/serverless.yml.md#L95 )

Terraform has no-rollback as its default behaviour and plenty of people use that in production

rollbackConfiguration:
MonitoringTimeInMinutes: 20
RollbackTriggers:
Expand Down
5 changes: 5 additions & 0 deletions lib/plugins/aws/deploy/lib/createStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ module.exports = {
params.NotificationARNs = this.serverless.service.provider.notificationArns;
}

if (this.serverless.service.provider.disableRollback) {
delete params.OnFailure;
params.DisableRollback = this.serverless.service.provider.disableRollback;
}

return this.provider
.request('CloudFormation', 'createStack', params)
.then((cfData) => this.monitorStack('create', cfData));
Expand Down
9 changes: 9 additions & 0 deletions lib/plugins/aws/lib/updateStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ module.exports = {
params.Parameters = this.serverless.service.provider.stackParameters;
}

if (this.serverless.service.provider.disableRollback) {
fredericbarthelet marked this conversation as resolved.
Show resolved Hide resolved
delete params.OnFailure;
params.DisableRollback = this.serverless.service.provider.disableRollback;
}

return this.provider
.request('CloudFormation', 'createStack', params)
.then((cfData) => this.monitorStack('create', cfData));
Expand Down Expand Up @@ -133,6 +138,10 @@ module.exports = {
params.RollbackConfiguration = this.serverless.service.provider.rollbackConfiguration;
}

if (this.serverless.service.provider.disableRollback) {
params.DisableRollback = this.serverless.service.provider.disableRollback;
}

let cfData;
try {
cfData = await this.provider.request('CloudFormation', 'updateStack', params);
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/aws/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ class AwsProvider {
},
deploymentPrefix: { type: 'string' },
disableDefaultOutputExportNames: { const: true },
disableRollback: { const: true },
fredericbarthelet marked this conversation as resolved.
Show resolved Hide resolved
endpointType: {
anyOf: ['REGIONAL', 'EDGE', 'PRIVATE'].map(caseInsensitive),
},
Expand Down