Skip to content

Commit 64c970f

Browse files
authored
chore(CFN): update CFN stack to add managed policies to ci and release role (#1856)
* chore: update CFN stack to add managed policies to ci and release role * chore: add CFN template for non-prod account role
1 parent ca4c763 commit 64c970f

File tree

2 files changed

+95
-2
lines changed

2 files changed

+95
-2
lines changed

cfn/Public-ESDK-Java-CI.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Description: "DDB Table and IAM Managed Policies/Role for AWS KMS Hierarchical Keyring Testing"
3+
4+
Parameters:
5+
TableName:
6+
Type: String
7+
Description: Test Table Name
8+
Default: HierarchicalKeyringTestTable
9+
KeyStoreTable:
10+
Type: String
11+
Description: Key Store Test Table Name
12+
Default: KeyStoreTestTable
13+
ProjectName:
14+
Type: String
15+
Description: A prefix that will be applied to any names
16+
Default: Public-ESDK-Java
17+
GitHubRepo:
18+
Type: String
19+
Description: GitHub Repo that invokes CI
20+
Default: aws/aws-encryption-sdk-java
21+
22+
Resources:
23+
GitHubCIRole:
24+
Type: 'AWS::IAM::Role'
25+
Properties:
26+
RoleName: !Sub "GitHub-CI-${ProjectName}-Role-${AWS::Region}"
27+
Description: "Access DDB, KMS, Resources for CI from GitHub"
28+
ManagedPolicyArns:
29+
- "arn:aws:iam::370957321024:policy/ESDK-Dafny-DDB-ReadWriteDelete-us-west-2"
30+
- "arn:aws:iam::370957321024:policy/Hierarchical-GitHub-KMS-Key-Policy"
31+
- "arn:aws:iam::370957321024:policy/KMS-Public-CMK-EncryptDecrypt-Key-Access"
32+
- "arn:aws:iam::370957321024:policy/RSA-GitHub-KMS-Key-Policy"
33+
AssumeRolePolicyDocument: !Sub |
34+
{
35+
"Version": "2012-10-17",
36+
"Statement": [
37+
{
38+
"Effect": "Allow",
39+
"Principal": { "Federated": "arn:aws:iam::${AWS::AccountId}:oidc-provider/token.actions.githubusercontent.com" },
40+
"Action": "sts:AssumeRoleWithWebIdentity",
41+
"Condition": {
42+
"StringEquals": {
43+
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
44+
},
45+
"StringLike": {
46+
"token.actions.githubusercontent.com:sub": "repo:${GitHubRepo}:*"
47+
}
48+
}
49+
},
50+
{
51+
"Effect": "Allow",
52+
"Principal": {
53+
"AWS": "*"
54+
},
55+
"Action": "sts:AssumeRole",
56+
"Condition": {
57+
"StringEquals": {
58+
"aws:PrincipalArn": [
59+
"arn:aws:iam::587316601012:role/service-role/codebuild-AWS-ESDK-Java-service-role-ci",
60+
"arn:aws:iam::587316601012:role/service-role/codebuild-AWS-ESDK-Java-service-role-release",
61+
"arn:aws:iam::${AWS::AccountId}:role/ToolsDevelopment"
62+
]
63+
}
64+
}
65+
}
66+
]
67+
}

cfn/ci_cd.yml

+28-2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ Resources:
141141
- !Ref SecretsManagerPolicyCI
142142
- !Ref ParameterStorePolicy
143143
- !Ref CodeBuildBasePolicyCI
144+
- !Ref HierarchicalKeyringTestTableUsage
145+
- !Ref CodeBuildCISTSAllow
144146
- "arn:aws:iam::aws:policy/AWSCodeArtifactReadOnlyAccess"
145147
- "arn:aws:iam::aws:policy/AWSCodeArtifactAdminAccess"
146148

@@ -159,9 +161,28 @@ Resources:
159161
- !Ref CodeBuildBasePolicy
160162
- !Ref SecretsManagerPolicyRelease
161163
- !Ref ParameterStorePolicy
164+
- !Ref HierarchicalKeyringTestTableUsage
165+
- !Ref CodeBuildCISTSAllow
162166
- "arn:aws:iam::aws:policy/AWSCodeArtifactReadOnlyAccess"
163167
- "arn:aws:iam::aws:policy/AWSCodeArtifactAdminAccess"
164168

169+
CodeBuildCISTSAllow:
170+
Type: "AWS::IAM::ManagedPolicy"
171+
Properties:
172+
ManagedPolicyName: !Sub CodeBuildCISTSAllow-${ProjectName}
173+
Path: /service-role/
174+
PolicyDocument: |
175+
{
176+
"Version": "2012-10-17",
177+
"Statement": [
178+
{
179+
"Effect": "Allow",
180+
"Action": "sts:AssumeRole",
181+
"Resource": "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Java-Role-us-west-2"
182+
}
183+
]
184+
}
185+
165186
CodeBuildBatchPolicy:
166187
Type: "AWS::IAM::ManagedPolicy"
167188
Properties:
@@ -382,12 +403,17 @@ Resources:
382403
"Effect": "Allow",
383404
"Resource": [
384405
"arn:aws:kms:*:658956600833:key/*",
385-
"arn:aws:kms:*:658956600833:alias/*"
406+
"arn:aws:kms:*:658956600833:alias/*",
407+
"arn:aws:kms:*:370957321024:key/*",
408+
"arn:aws:kms:*:370957321024:alias/*"
386409
],
387410
"Action": [
388411
"kms:Encrypt",
389412
"kms:Decrypt",
390-
"kms:GenerateDataKey"
413+
"kms:ReEncrypt*",
414+
"kms:Generate*",
415+
"kms:GetPublicKey",
416+
"kms:DescribeKey"
391417
]
392418
}
393419
]

0 commit comments

Comments
 (0)