fix(iam): throw error when statement id is invalid (#34819)#34828
fix(iam): throw error when statement id is invalid (#34819)#34828camerondurham wants to merge 2 commits intoaws:mainfrom
Conversation
fe642f1 to
a82d2f1
Compare
|
Looks like there are existing invalid SIDs defined (DefaultSid-1, etc). Will go and fix them and revise this PR. |
408d887 to
597aa4f
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
10284c4 to
d3dd64d
Compare
|
Current failure is due to replacing a policy within statements: However, the current CFN stack seems invalid now, with the current Sid containing invalid characters that would be rejected on deployment (https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html)
Next StepsPlan to fix this build error
There appear to be other examples of using this approach in the CDK repo (see) |
e6beac1 to
3e35c95
Compare
|
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
94f3f9f to
48d7954
Compare
| skipValidation: true, | ||
| principals: [new ServicePrincipal('fargate.amazonaws.com')], | ||
| resources: ['*'], | ||
| actions: ['kms:GenerateDataKeyWithoutPlaintext'], | ||
| conditions: clusterConditions, | ||
| })); | ||
| key.addToResourcePolicy(new PolicyStatement({ | ||
| sid: 'Allow grant creation permission for Fargate tasks.', | ||
| skipValidation: true, |
There was a problem hiding this comment.
I'd prefer to not make these changes and use the "default" skipValidation:false when using the PolicyStatement constructor. However, when I don't it causes build to fail due to destructive CDK changes during the integ test. So this is a workaround until I can get some confirmation whether the destructive integ test changes are "acceptable" or not.
For reference what I'm talking about, see: #34828 (comment)
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Hi, This PR has conflicts that need to be resolved before it can be reviewed. |
|
This PR has been in the MERGE CONFLICTS state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing To prevent automatic closure:
This PR will automatically close in 14 days if no action is taken. |
9fa47ef to
ef6dd32
Compare
|
I've adjusted this PR in #36150 to instead use a feature flag to gate the changes since they broke several snapshot tests. The linked CR does still need approval for gating. Open to feedback on which approach is preferred. |
@camerondurham Thank you for your contribution! #36150 is the better approach. I have provided some feedback on that one. Closing this PR. |
|
Comments on closed issues and PRs are hard for our team to see. |
Resolves #34819 by throwing error when PolicyStatement Statement id contains characters not allowed by the API.
Reference: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html
Issue # (if applicable)
Closes #34819
Reason for this change
CDK build allows users to write invalid statement ids containing dashes when building policy statements, then failed on deployment. To reduce time to a successful deployment, I believe the CDK should throw an exception at build time to help user make a fix locally before a failed deployment.
Description of changes
Validate that statement id matches requirements specified in https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html in the constructor.
Add tests that verify only valid statement ids are set in constructor.
Describe any new or updated permissions being added
n/a
Description of how you validated changes
yes, added unit tests
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license