Skip to content

Conversation

@camerondurham
Copy link

Resolves #34819 by throwing error when PolicyStatement Statement id contains characters not allowed by the API.

Note this does duplicate #34828. I realized that PR makes too many changes to existing integ tests. This change is intended to be less intrusive.

Reference: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html

The Sid element supports ASCII uppercase letters (A-Z), lowercase letters (a-z), and numbers (0-9).

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

@aws-cdk-automation aws-cdk-automation requested a review from a team November 21, 2025 16:50
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Nov 21, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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)

@camerondurham
Copy link
Author

Will fix later today after work.

…umeric

- Add IAM_POLICY_STATEMENT_VALIDATE_SID feature flag
- Validate SIDs are alphanumeric (A-Z, a-z, 0-9) when flag enabled
- Fix invalid SIDs in aws-ecs cluster.ts
- Add comprehensive test coverage for SID validation
- Add README documentation and integ test

Closes aws#34819
@camerondurham camerondurham force-pushed the feat/iam-sid-validation-flag-main branch from 5860098 to 78f1ade Compare November 22, 2025 03:10
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 22, 2025 03:12

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Nov 22, 2025
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-iam): Invalid Policy Statement Id strings should fail at build time

2 participants