Skip to content

Commit

Permalink
Fix policy statement in aws-lambda unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyas Damle committed May 19, 2020
1 parent 8befbe9 commit 8ba9a3b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-lambda/test/test.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export = {
const role = new iam.Role(stack, 'SomeRole', {
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});
role.addToPolicy(new iam.PolicyStatement({ actions: ['confirm:itsthesame'] }));
role.addToPolicy(new iam.PolicyStatement({ actions: ['confirm:itsthesame'], resources: ['*'] }));

// WHEN
const fn = new lambda.Function(stack, 'Function', {
Expand All @@ -246,20 +246,20 @@ export = {
handler: 'index.test',
role,
initialPolicy: [
new iam.PolicyStatement({ actions: ['inline:inline'] }),
new iam.PolicyStatement({ actions: ['inline:inline'], resources: ['*'] }),
],
});

fn.addToRolePolicy(new iam.PolicyStatement({ actions: ['explicit:explicit'] }));
fn.addToRolePolicy(new iam.PolicyStatement({ actions: ['explicit:explicit'], resources: ['*'] }));

// THEN
expect(stack).to(haveResource('AWS::IAM::Policy', {
'PolicyDocument': {
'Version': '2012-10-17',
'Statement': [
{ 'Action': 'confirm:itsthesame', 'Effect': 'Allow' },
{ 'Action': 'inline:inline', 'Effect': 'Allow' },
{ 'Action': 'explicit:explicit', 'Effect': 'Allow' },
{ 'Action': 'confirm:itsthesame', 'Effect': 'Allow', 'Resource': '*' },
{ 'Action': 'inline:inline', 'Effect': 'Allow', 'Resource': '*' },
{ 'Action': 'explicit:explicit', 'Effect': 'Allow', 'Resource': '*' },
],
},
}));
Expand Down

0 comments on commit 8ba9a3b

Please sign in to comment.