mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
fix(AWS Deploy): Properly apply stackPolicy with changesets
This commit is contained in:
parent
e3ab8a907e
commit
ee30a7be62
@ -60,16 +60,6 @@ module.exports = {
|
||||
createChangeSetParams.Parameters = this.serverless.service.provider.stackParameters;
|
||||
}
|
||||
|
||||
// Policy must have at least one statement, otherwise no updates would be possible at all
|
||||
if (
|
||||
this.serverless.service.provider.stackPolicy &&
|
||||
Object.keys(this.serverless.service.provider.stackPolicy).length
|
||||
) {
|
||||
createChangeSetParams.StackPolicyBody = JSON.stringify({
|
||||
Statement: this.serverless.service.provider.stackPolicy,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.serverless.service.provider.rollbackConfiguration) {
|
||||
createChangeSetParams.RollbackConfiguration =
|
||||
this.serverless.service.provider.rollbackConfiguration;
|
||||
|
||||
@ -91,6 +91,21 @@ module.exports = {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Policy must have at least one statement, otherwise no updates would be possible at all
|
||||
if (
|
||||
this.serverless.service.provider.stackPolicy &&
|
||||
Object.keys(this.serverless.service.provider.stackPolicy).length
|
||||
) {
|
||||
log.info('Setting stack policy');
|
||||
const stackPolicyBody = JSON.stringify({
|
||||
Statement: this.serverless.service.provider.stackPolicy,
|
||||
});
|
||||
await this.provider.request('CloudFormation', 'setStackPolicy', {
|
||||
StackName: stackName,
|
||||
StackPolicyBody: stackPolicyBody,
|
||||
});
|
||||
}
|
||||
|
||||
log.info('Executing created change set');
|
||||
await this.provider.request('CloudFormation', 'executeChangeSet', executeChangeSetParams);
|
||||
|
||||
|
||||
@ -683,6 +683,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
|
||||
describe('custom deployment-related properties', () => {
|
||||
let createChangeSetStub;
|
||||
let executeChangeSetStub;
|
||||
let setStackPolicyStub;
|
||||
const deploymentRole = 'arn:xxx';
|
||||
const notificationArns = ['arn:xxx', 'arn:yyy'];
|
||||
const stackParameters = [
|
||||
@ -724,6 +725,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
|
||||
.resolves({ Stacks: [{}] });
|
||||
createChangeSetStub = sinon.stub().resolves({});
|
||||
executeChangeSetStub = sinon.stub().resolves({});
|
||||
setStackPolicyStub = sinon.stub().resolves({});
|
||||
const awsRequestStubMap = {
|
||||
...baseAwsRequestStubMap,
|
||||
ECR: {
|
||||
@ -748,6 +750,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
|
||||
StackName: 'new-service-dev',
|
||||
Status: 'CREATE_COMPLETE',
|
||||
},
|
||||
setStackPolicy: setStackPolicyStub,
|
||||
describeStackEvents: {
|
||||
StackEvents: [
|
||||
{
|
||||
@ -807,7 +810,7 @@ describe('test/unit/lib/plugins/aws/deploy/index.test.js', () => {
|
||||
});
|
||||
|
||||
it('should support `stackPolicy`', () => {
|
||||
expect(createChangeSetStub.getCall(1).args[0].StackPolicyBody).to.deep.equal(
|
||||
expect(setStackPolicyStub.getCall(0).args[0].StackPolicyBody).to.equal(
|
||||
JSON.stringify({ Statement: stackPolicy })
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user