Skip to content

Commit 13e7bde

Browse files
authored
feat(codedeploy): change LambdaDeploymentGroup default managed policy to AWSCodeDeployRoleForLambdaLimited (#10276)
The managed policy `AWSCodeDeployRoleForLambda` used for Lambda deployments has broad permissions, providing publish access to all SNS topics within the customer's accounts. This change replaces that with a new policy `AWSCodeDeployRoleForLambdaLimited` which removes those permissions. This should be safe, as the SNS publish permission is only ever used when setting up `triggers`, and we don't support that feature in `LambdaDeploymentGroup`. BREAKING CHANGE: the default policy for `LambdaDeploymentGroup` no longer contains `sns:Publish` on `*` permissions ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 17e2a0a commit 13e7bde

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-group.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class LambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploy
158158
assumedBy: new iam.ServicePrincipal('codedeploy.amazonaws.com'),
159159
});
160160

161-
this.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSCodeDeployRoleForLambda'));
161+
this.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSCodeDeployRoleForLambdaLimited'));
162162
this.deploymentConfig = props.deploymentConfig || LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES;
163163

164164
const resource = new CfnDeploymentGroup(this, 'Resource', {

packages/@aws-cdk/aws-codedeploy/test/lambda/integ.deployment-group.expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@
468468
{
469469
"Ref": "AWS::Partition"
470470
},
471-
":iam::aws:policy/service-role/AWSCodeDeployRoleForLambda"
471+
":iam::aws:policy/service-role/AWSCodeDeployRoleForLambdaLimited"
472472
]
473473
]
474474
}

packages/@aws-cdk/aws-codedeploy/test/lambda/test.deployment-group.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export = {
101101
[
102102
'arn:',
103103
{ Ref: 'AWS::Partition' },
104-
':iam::aws:policy/service-role/AWSCodeDeployRoleForLambda',
104+
':iam::aws:policy/service-role/AWSCodeDeployRoleForLambdaLimited',
105105
],
106106
],
107107
},
@@ -160,7 +160,7 @@ export = {
160160
[
161161
'arn:',
162162
{ Ref: 'AWS::Partition' },
163-
':iam::aws:policy/service-role/AWSCodeDeployRoleForLambda',
163+
':iam::aws:policy/service-role/AWSCodeDeployRoleForLambdaLimited',
164164
],
165165
],
166166
},

0 commit comments

Comments
 (0)