Skip to content

Commit 148bbdf

Browse files
chore(CFN): Allow access to CI keystore resources from CI and release roles (#637)
1 parent 3f5c095 commit 148bbdf

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

Diff for: cfn/ESDK-Python.yml

+19
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Resources:
174174
- !Ref CodeBuildBatchPolicy
175175
- !Ref CodeBuildBasePolicy
176176
- !Ref SecretsManagerPolicy
177+
- !Ref CodeBuildCISTSAllow
177178

178179
CodeBuildCIServiceRole:
179180
Type: "AWS::IAM::Role"
@@ -186,6 +187,7 @@ Resources:
186187
- !Ref CryptoToolsKMS
187188
- !Ref CodeBuildCIBatchPolicy
188189
- !Ref CodeBuildBasePolicy
190+
- !Ref CodeBuildCISTSAllow
189191

190192
CodeBuildBatchPolicy:
191193
Type: "AWS::IAM::ManagedPolicy"
@@ -339,3 +341,20 @@ Resources:
339341
}
340342
]
341343
}
344+
345+
CodeBuildCISTSAllow:
346+
Type: "AWS::IAM::ManagedPolicy"
347+
Properties:
348+
ManagedPolicyName: !Sub CodeBuildCISTSAllow-${ProjectName}
349+
Path: /service-role/
350+
PolicyDocument: |
351+
{
352+
"Version": "2012-10-17",
353+
"Statement": [
354+
{
355+
"Effect": "Allow",
356+
"Action": "sts:AssumeRole",
357+
"Resource": "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2"
358+
}
359+
]
360+
}

Diff for: cfn/Public-ESDK-Python-CI.yml

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

0 commit comments

Comments
 (0)