Skip to content

Commit 78f1ade

Browse files
committed
feat(iam): add feature flag to validate PolicyStatement SID is alphanumeric
- 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 #34819
1 parent a6c0288 commit 78f1ade

17 files changed

+1119
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## Unreleased
6+
7+
### Features
8+
9+
* **iam:** add feature flag to validate PolicyStatement SID is alphanumeric ([#34819](https://github.com/aws/aws-cdk/issues/34819))
10+
- New feature flag `@aws-cdk/aws-iam:policyStatementValidateSid` enforces IAM SID validation
11+
- SIDs must be alphanumeric (A-Z, a-z, 0-9) per AWS IAM requirements
12+
- Validation occurs at synthesis time when flag is enabled
13+
- Fixed invalid SIDs in aws-ecs cluster.ts to be alphanumeric
14+
515
## [1.158.0](https://github.com/aws/aws-cdk/compare/v1.157.0...v1.158.0) (2022-05-27)
616

717

packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.policy-statement-sid.js.snapshot/PolicyStatementSidStack.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"Resources": {
3+
"TestRole6C9272DF": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
}
18+
}
19+
},
20+
"TestRoleDefaultPolicyD1C92014": {
21+
"Type": "AWS::IAM::Policy",
22+
"Properties": {
23+
"PolicyDocument": {
24+
"Statement": [
25+
{
26+
"Action": "s3:GetObject",
27+
"Effect": "Allow",
28+
"Resource": "*",
29+
"Sid": "ValidAlphanumericSid"
30+
},
31+
{
32+
"Action": "dynamodb:PutItem",
33+
"Effect": "Allow",
34+
"Resource": "*",
35+
"Sid": "AnotherValidSid123"
36+
}
37+
],
38+
"Version": "2012-10-17"
39+
},
40+
"PolicyName": "TestRoleDefaultPolicyD1C92014",
41+
"Roles": [
42+
{
43+
"Ref": "TestRole6C9272DF"
44+
}
45+
]
46+
}
47+
}
48+
},
49+
"Parameters": {
50+
"BootstrapVersion": {
51+
"Type": "AWS::SSM::Parameter::Value<String>",
52+
"Default": "/cdk-bootstrap/hnb659fds/version",
53+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
54+
}
55+
},
56+
"Rules": {
57+
"CheckBootstrapVersion": {
58+
"Assertions": [
59+
{
60+
"Assert": {
61+
"Fn::Not": [
62+
{
63+
"Fn::Contains": [
64+
[
65+
"1",
66+
"2",
67+
"3",
68+
"4",
69+
"5"
70+
],
71+
{
72+
"Ref": "BootstrapVersion"
73+
}
74+
]
75+
}
76+
]
77+
},
78+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
79+
}
80+
]
81+
}
82+
}
83+
}

packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.policy-statement-sid.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.policy-statement-sid.js.snapshot/iampolicystatementsidDefaultTestDeployAssert798739BA.assets.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.policy-statement-sid.js.snapshot/iampolicystatementsidDefaultTestDeployAssert798739BA.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.policy-statement-sid.js.snapshot/integ.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)