-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
importedRoleStackSafeDefaultPolicyName feature flag results in excessively long IAM policy names #27409
Comments
Can you please share a minimal code sample? I'm not exactly sure how you're using the role |
Certainly, please find the code below:
|
Thanks, I see what's going on here. The feature flag makes use of
I wonder if it would have been better to use
It may be a better call to truncate the result returned from
|
There's an older issue: #24441 |
… in excessively long IAM policy names (#27548) When the importedRoleStackSafeDefaultPolicyName feature flag is enabled, the method to calculate the IAM Policy Name within `aws_iam.ImportedRole.addToPrincipalPolicy()` changes. Specifically, if the generated IAM Policy Name exceeds the maximum allowed length of 128 characters, it will be truncated using `Names.uniqueResourceName()`. Previously, the `Names.UniqueId()` method was used to generate the Policy Name. This method does not allow you to set a maximum length, so if the name exceeded the limit, it would be overwritten using `Names.uniqueResourceName()`—a function that allows for length specification. I considered replacing `Names.UniqueId()` entirely with `Names.uniqueResourceName()`. However, this is on hold due to concerns that existing Policy Names could be affected. If a complete replacement poses no issues, your guidance is appreciated, as I'm not fully versed in the logic behind these methods. Closes #27409 , #24441 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
… in excessively long IAM policy names (aws#27548) When the importedRoleStackSafeDefaultPolicyName feature flag is enabled, the method to calculate the IAM Policy Name within `aws_iam.ImportedRole.addToPrincipalPolicy()` changes. Specifically, if the generated IAM Policy Name exceeds the maximum allowed length of 128 characters, it will be truncated using `Names.uniqueResourceName()`. Previously, the `Names.UniqueId()` method was used to generate the Policy Name. This method does not allow you to set a maximum length, so if the name exceeded the limit, it would be overwritten using `Names.uniqueResourceName()`—a function that allows for length specification. I considered replacing `Names.UniqueId()` entirely with `Names.uniqueResourceName()`. However, this is on hold due to concerns that existing Policy Names could be affected. If a complete replacement poses no issues, your guidance is appreciated, as I'm not fully versed in the logic behind these methods. Closes aws#27409 , aws#24441 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
When using the @aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName feature flag with the CDK pipeline, the CDK generates exceedingly long IAM policy names that exceed AWS's character limits.
Expected Behavior
The CDK should generate names that respect AWS's character limits regardless of feature flag settings.
Current Behavior
When this feature flag is enabled, I get an error indicating that the policy name has exceeded the maximum allowed length (128 characters). The error message is as follows:
CREATE_FAILED Properties validation failed for resource Route53CrossAccountZoneDelegationRecordcrossaccountzonedelegationhandlerrolePolicyCadPlatformtoolboxDevToolchainCdkPipelineDevCadPlatformDevRoute53CrossAccountZoneDelegationRecordcrossaccountzonedelegationhandlerrole195BFE8B8FD65C38 with message: #/PolicyName: expected maxLength: 128, actual: 148
Reproduction Steps
Enable the @aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName feature flag with the CDK pipeline,
Define a stack that imports an IAM role and attach policies to it.
Deploy the stack.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.99.1 (build b2a895e)
Framework Version
No response
Node.js Version
v18.18.0
OS
Ubuntu 23.04
Language
Python
Language Version
Python 3.11.5
Other information
No response
The text was updated successfully, but these errors were encountered: