Skip to content

Commit

Permalink
fix(AWS Deploy): Recognize LogicalResourceId in stackPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
jmonsma committed Oct 15, 2021
1 parent 8401ff7 commit 1a528c2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/plugins/aws/provider.js
Expand Up @@ -466,9 +466,16 @@ class AwsProvider {
anyOf: [
{ const: '*' },
{ $ref: '#/definitions/awsArn' },
{ $ref: '#/definitions/awsLogicalResourceId' },
{
type: 'array',
items: { anyOf: [{ const: '*' }, { $ref: '#/definitions/awsArn' }] },
items: {
anyOf: [
{ const: '*' },
{ $ref: '#/definitions/awsArn' },
{ $ref: '#/definitions/awsLogicalResourceId' },
],
},
},
],
},
Expand Down Expand Up @@ -577,6 +584,10 @@ class AwsProvider {
additionalProperties: false,
required: ['securityGroupIds', 'subnetIds'],
},
awsLogicalResourceId: {
type: 'string',
pattern: '^[#A-Za-z0-9-_./]+[*]?$',
},
awsLogGroupName: {
type: 'string',
pattern: '^[/#A-Za-z0-9-_.]+$',
Expand Down
16 changes: 15 additions & 1 deletion test/unit/lib/plugins/aws/lib/updateStack.test.js
Expand Up @@ -162,6 +162,18 @@ describe('updateStack', () => {
Action: 'Update:*',
Resource: '*',
},
{
Effect: 'Allow',
Principal: '*',
Action: 'Update:*',
Resource: 'LogicalResourceId/myEC2instance',
},
{
Effect: 'Deny',
Principal: '*',
Action: ['Update:Replace', 'Update:Delete'],
Resource: 'LogicalResourceId/CriticalResource*',
},
];

return awsDeploy.update().then(() => {
Expand All @@ -170,7 +182,9 @@ describe('updateStack', () => {
{ Key: 'tag1', Value: 'value1' },
]);
expect(updateStackStub.args[0][2].StackPolicyBody).to.equal(
'{"Statement":[{"Effect":"Allow","Principal":"*","Action":"Update:*","Resource":"*"}]}'
'{"Statement":[{"Effect":"Allow","Principal":"*","Action":"Update:*","Resource":"*"},' +
'{"Effect":"Allow","Principal":"*","Action":"Update:*","Resource":"LogicalResourceId/myEC2instance"},' +
'{"Effect":"Deny","Principal":"*","Action":["Update:Replace","Update:Delete"],"Resource":"LogicalResourceId/CriticalResource*"}]}'
);
});
});
Expand Down

0 comments on commit 1a528c2

Please sign in to comment.