Skip to content

chore(CFN): Allow access to CI keystore resources from CI and release roles #637

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

Merged
merged 10 commits into from
Mar 18, 2024
19 changes: 19 additions & 0 deletions cfn/ESDK-Python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Resources:
- !Ref CodeBuildBatchPolicy
- !Ref CodeBuildBasePolicy
- !Ref SecretsManagerPolicy
- !Ref CodeBuildCISTSAllow

CodeBuildCIServiceRole:
Type: "AWS::IAM::Role"
Expand All @@ -186,6 +187,7 @@ Resources:
- !Ref CryptoToolsKMS
- !Ref CodeBuildCIBatchPolicy
- !Ref CodeBuildBasePolicy
- !Ref CodeBuildCISTSAllow

CodeBuildBatchPolicy:
Type: "AWS::IAM::ManagedPolicy"
Expand Down Expand Up @@ -339,3 +341,20 @@ Resources:
}
]
}

CodeBuildCISTSAllow:
Type: "AWS::IAM::ManagedPolicy"
Properties:
ManagedPolicyName: !Sub CodeBuildCISTSAllow-${ProjectName}
Path: /service-role/
PolicyDocument: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2"
}
]
}
59 changes: 59 additions & 0 deletions cfn/Public-ESDK-Python-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
AWSTemplateFormatVersion: "2010-09-09"
Description: "IAM Managed Policies/Role for AWS KMS Hierarchical Keyring Testing"

Parameters:
ProjectName:
Type: String
Description: A prefix that will be applied to any names
Default: Public-ESDK-Python
GitHubRepo:
Type: String
Description: GitHub Repo that invokes CI
Default: aws/aws-encryption-sdk-python

Resources:
GitHubCIRole:
Type: 'AWS::IAM::Role'
Properties:
RoleName: !Sub "GitHub-CI-${ProjectName}-Role-${AWS::Region}"
Description: "Access DDB, KMS, Resources for CI from GitHub"
ManagedPolicyArns:
- "arn:aws:iam::370957321024:policy/ESDK-Dafny-DDB-ReadWriteDelete-us-west-2"
- "arn:aws:iam::370957321024:policy/Hierarchical-GitHub-KMS-Key-Policy"
- "arn:aws:iam::370957321024:policy/KMS-Public-CMK-EncryptDecrypt-Key-Access"
- "arn:aws:iam::370957321024:policy/RSA-GitHub-KMS-Key-Policy"
AssumeRolePolicyDocument: !Sub |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Federated": "arn:aws:iam::${AWS::AccountId}:oidc-provider/token.actions.githubusercontent.com" },
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:${GitHubRepo}:*"
}
}
},
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"aws:PrincipalArn": [
"arn:aws:iam::587316601012:role/service-role/codebuild-python-esdk-CI-service-role",
"arn:aws:iam::587316601012:role/service-role/codebuild-python-esdk-service-role",
"arn:aws:iam::${AWS::AccountId}:role/ToolsDevelopment"
]
}
}
}
]
}
Loading