Skip to content

Commit 242091a

Browse files
fix(lambda): deprecate default feature flag @aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy (#34010)
deprecate default feature flag @aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy same as pr-33689 ### Issue # (if applicable) Closes #33688 . ### Reason for this change same as #33689 ### Description of changes ### Describe any new or updated permissions being added ### Description of how you validated changes ### Checklist - [ x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2dc8cc7 commit 242091a

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Flags come in three types:
8989
| [@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault](#aws-cdkaws-elasticloadbalancingv2albdualstackwithoutpublicipv4securitygrouprulesdefault) | When enabled, the default security group ingress rules will allow IPv6 ingress from anywhere | 2.176.0 | (fix) |
9090
| [@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections](#aws-cdkaws-iamoidcrejectunauthorizedconnections) | When enabled, the default behaviour of OIDC provider will reject unauthorized connections | 2.177.0 | (fix) |
9191
| [@aws-cdk/core:enableAdditionalMetadataCollection](#aws-cdkcoreenableadditionalmetadatacollection) | When enabled, CDK will expand the scope of usage data collected to better inform CDK development and improve communication for security concerns and emerging issues. | 2.178.0 | (config) |
92-
| [@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy](#aws-cdkaws-lambdacreatenewpolicieswithaddtorolepolicy) | When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement | 2.180.0 | (fix) |
92+
| [@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy](#aws-cdkaws-lambdacreatenewpolicieswithaddtorolepolicy) | [Deprecated] When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement | 2.180.0 | (fix) |
9393
| [@aws-cdk/aws-s3:setUniqueReplicationRoleName](#aws-cdkaws-s3setuniquereplicationrolename) | When enabled, CDK will automatically generate a unique role name that is used for s3 object replication. | 2.182.0 | (fix) |
9494
| [@aws-cdk/pipelines:reduceStageRoleTrustScope](#aws-cdkpipelinesreducestageroletrustscope) | Remove the root account principal from Stage addActions trust policy | 2.184.0 | (default) |
9595
| [@aws-cdk/aws-events:requireEventBusPolicySid](#aws-cdkaws-eventsrequireeventbuspolicysid) | When enabled, grantPutEventsTo() will use resource policies with Statement IDs for service principals. | 2.186.0 | (fix) |
@@ -172,7 +172,7 @@ The following json shows the current recommended set of flags, as `cdk init` wou
172172
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
173173
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
174174
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
175-
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true,
175+
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
176176
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true,
177177
"@aws-cdk/aws-events:requireEventBusPolicySid": true,
178178
"@aws-cdk/aws-dynamodb:retainTableReplica": true
@@ -1701,17 +1701,20 @@ When this feature flag is enabled, CDK expands the scope of usage data collectio
17011701

17021702
### @aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy
17031703

1704-
*When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement* (fix)
1704+
*[Deprecated] When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement* (fix)
17051705

1706-
When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
1706+
[Deprecated default feature] When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
17071707
The purpose of this is to prevent lambda from creating a dependency on the Default Policy Statement.
17081708
This solves an issue where a circular dependency could occur if adding lambda to something like a Cognito Trigger, then adding the User Pool to the lambda execution role permissions.
1709+
However in the current implementation, we have removed a dependency of the lambda function on the policy. In addition to this, a Role will be attached to the Policy instead of an inline policy being attached to the role.
1710+
This will create a data race condition in the CloudFormation template because the creation of the Lambda function no longer waits for the policy to be created. Having said that, we are not deprecating the feature (we are defaulting the feature flag to false for new stacks) since this feature can still be used to get around the circular dependency issue (issue-7016) particularly in cases where the lambda resource creation doesnt need to depend on the policy resource creation.
1711+
We recommend to unset the feature flag if already set which will restore the original behavior.
17091712

17101713

17111714
| Since | Default | Recommended |
17121715
| ----- | ----- | ----- |
17131716
| (not in v1) | | |
1714-
| 2.180.0 | `false` | `true` |
1717+
| 2.180.0 | `false` | `false` |
17151718

17161719

17171720
### @aws-cdk/aws-s3:setUniqueReplicationRoleName

packages/aws-cdk-lib/cx-api/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,19 @@ _cdk.json_
615615

616616
* `@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy`
617617

618-
When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
618+
[Deprecated default feature] When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
619619
The purpose of this is to prevent lambda from creating a dependency on the Default Policy Statement.
620620
This solves an issue where a circular dependency could occur if adding lambda to something like a Cognito Trigger, then adding the User Pool to the lambda execution role permissions.
621+
However in the current implementation, we have removed a dependency of the lambda function on the policy. In addition to this, a Role will be attached to the Policy instead of an inline policy being attached to the role.
622+
This will create a data race condition in the CloudFormation template because the creation of the Lambda function no longer waits for the policy to be created. Having said that, we are not deprecating the feature (we are defaulting the feature flag to false for new stacks) since this feature can still be used to get around the circular dependency issue (issue-7016) particularly in cases where the lambda resource creation doesnt need to depend on the policy resource creation.
623+
We recommend to unset the feature flag if already set which will restore the original behavior.
621624

622625
_cdk.json_
623626

624627
```json
625628
{
626629
"context": {
627-
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true
630+
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false
628631
}
629632
}
630633
```

packages/aws-cdk-lib/cx-api/lib/features.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1396,14 +1396,17 @@ export const FLAGS: Record<string, FlagInfo> = {
13961396
//////////////////////////////////////////////////////////////////////
13971397
[LAMBDA_CREATE_NEW_POLICIES_WITH_ADDTOROLEPOLICY]: {
13981398
type: FlagType.BugFix,
1399-
summary: 'When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement',
1399+
summary: '[Deprecated] When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement',
14001400
detailsMd: `
1401-
When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
1401+
[Deprecated default feature] When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
14021402
The purpose of this is to prevent lambda from creating a dependency on the Default Policy Statement.
14031403
This solves an issue where a circular dependency could occur if adding lambda to something like a Cognito Trigger, then adding the User Pool to the lambda execution role permissions.
1404+
However in the current implementation, we have removed a dependency of the lambda function on the policy. In addition to this, a Role will be attached to the Policy instead of an inline policy being attached to the role.
1405+
This will create a data race condition in the CloudFormation template because the creation of the Lambda function no longer waits for the policy to be created. Having said that, we are not deprecating the feature (we are defaulting the feature flag to false for new stacks) since this feature can still be used to get around the circular dependency issue (issue-7016) particularly in cases where the lambda resource creation doesnt need to depend on the policy resource creation.
1406+
We recommend to unset the feature flag if already set which will restore the original behavior.
14041407
`,
14051408
introducedIn: { v2: '2.180.0' },
1406-
recommendedValue: true,
1409+
recommendedValue: false,
14071410
},
14081411

14091412
//////////////////////////////////////////////////////////////////////

packages/aws-cdk-lib/recommended-feature-flags.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
6666
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
6767
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
68-
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true,
68+
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
6969
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true,
7070
"@aws-cdk/aws-events:requireEventBusPolicySid": true,
7171
"@aws-cdk/aws-dynamodb:retainTableReplica": true

0 commit comments

Comments
 (0)