Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(lambda): deprecate feature flag @aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy #33689

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6ca8753
Update .mergify.yml. Add me, remove Kailey and Michelle
QuantumNeuralCoder Feb 6, 2025
47187a0
Update .mergify.yml Removing Jacob, Kirti, Colin, Calvin.
QuantumNeuralCoder Feb 6, 2025
8a3fd60
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 6, 2025
ae36a25
Pinning minimatch and @types/glob versions to get rid of incompatibil…
Feb 7, 2025
cb336ae
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 7, 2025
70e0a20
Update codecov.yml
QuantumNeuralCoder Feb 7, 2025
f63e2a7
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 7, 2025
5b356c0
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 7, 2025
9cea97f
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 10, 2025
679f8b1
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 19, 2025
1851e8b
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 19, 2025
47333b2
Merge branch 'aws:main' into main
QuantumNeuralCoder Feb 26, 2025
8e73063
Merge branch 'aws:main' into main
QuantumNeuralCoder Mar 3, 2025
34365a1
Merge branch 'aws:main' into main
QuantumNeuralCoder Mar 4, 2025
6c01b62
Merge branch 'aws:main' into main
QuantumNeuralCoder Mar 4, 2025
51a0d48
issue-33688 Merge remote-tracking branch 'upstream/main'
Mar 4, 2025
4c04550
deprecate feature flag @aws-cdk/aws-lambda:createNewPoliciesWithAddTo…
Mar 4, 2025
58e531b
Removed unrelated files
Mar 4, 2025
c7ea0b6
chore: revert unintended changes to files
Mar 4, 2025
e5c0bc5
fix: minor updates to the description
Mar 5, 2025
d83ab06
chore: remove package-lock.json from PR
Mar 5, 2025
55fadf3
chore: add package-lock.json to .gitignore
Mar 5, 2025
8c4f95e
chore: add package-lock.json to .gitignore
Mar 5, 2025
42d696d
chore: remove .gitignore from PR
Mar 5, 2025
ee85c2b
chore: sync .gitignore with upstream
Mar 5, 2025
141feb3
Merge branch 'main' into issue-33688
QuantumNeuralCoder Mar 6, 2025
f2c07d7
Enabling ff to prevent destructive changes to snapshop
Mar 7, 2025
2fcf9c5
Adding ff to prevent breaking change in snapshot
Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Flags come in three types:
| [@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) |
| [@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections](#aws-cdkaws-iamoidcrejectunauthorizedconnections) | When enabled, the default behaviour of OIDC provider will reject unauthorized connections | 2.177.0 | (fix) |
| [@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) |
| [@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) |
| [@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) |
| [@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. | V2NEXT | (fix) |

<!-- END table -->
Expand Down Expand Up @@ -168,7 +168,7 @@ The following json shows the current recommended set of flags, as `cdk init` wou
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true,
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true
}
}
Expand Down Expand Up @@ -1694,17 +1694,20 @@ When this feature flag is enabled, CDK expands the scope of usage data collectio

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

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

When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
The purpose of this is to prevent lambda from creating a dependency on the Default Policy Statement.
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.
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.
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.
We recommend to unset the feature flag if already set which will restore the original behavior.


| Since | Default | Recommended |
| ----- | ----- | ----- |
| (not in v1) | | |
| 2.180.0 | `false` | `true` |
| 2.180.0 | `false` | `false` |


### @aws-cdk/aws-s3:setUniqueReplicationRoleName
Expand Down
9 changes: 6 additions & 3 deletions packages/aws-cdk-lib/cx-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -615,16 +615,19 @@ _cdk.json_

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

When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
[Deprecated feature] When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
The purpose of this is to prevent lambda from creating a dependency on the Default Policy Statement.
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.
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.
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.
We recommend to unset the feature flag if already set which will restore the original behavior.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should mention if people are okay with the fact that lambda may be created before policy, and they're experiencing circular dependency issue, they can consider setting it to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed.


_cdk.json_

```json
{
"context": {
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false
}
}
```
```
7 changes: 5 additions & 2 deletions packages/aws-cdk-lib/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,14 +1390,17 @@ export const FLAGS: Record<string, FlagInfo> = {
},
[LAMBDA_CREATE_NEW_POLICIES_WITH_ADDTOROLEPOLICY]: {
type: FlagType.BugFix,
summary: 'When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement',
summary: '[Deprecated]When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement',
detailsMd: `
When this feature flag is enabled, Lambda will create new inline policies with AddToRolePolicy.
The purpose of this is to prevent lambda from creating a dependency on the Default Policy Statement.
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.
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.
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.
We recommend to unset the feature flag if already set which will restore the original behavior.
`,
introducedIn: { v2: '2.180.0' },
recommendedValue: true,
recommendedValue: false,
},
[SET_UNIQUE_REPLICATION_ROLE_NAME]: {
type: FlagType.BugFix,
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/recommended-feature-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": false,
"@aws-cdk/aws-s3:setUniqueReplicationRoleName": true
}