-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(iam): throw error when statement id is invalid (#34819) #34828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
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. |
5b3f98b to
94f3f9f
Compare
Resolves aws#34819 by throwing error when PolicyStatement Statement id contains characters not allowed by the API. See docs in https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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