Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 70 additions & 1 deletion cfn/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Resources:
- !Ref ParameterStorePolicy
- !Ref S3ECReleaseTestKMSKeyPolicy
- !Ref S3ECReleaseS3BucketPolicy
- !Ref S3ECReleaseAssumeAlternatePolicy
- "arn:aws:iam::aws:policy/AWSCodeArtifactReadOnlyAccess"
- "arn:aws:iam::aws:policy/AWSCodeArtifactAdminAccess"

Expand Down Expand Up @@ -254,6 +255,20 @@ Resources:
Action: 'kms:*'
Resource: '*'

S3ECReleaseKMSKeyIDAlternate:
Type: 'AWS::KMS::Key'
Properties:
Description: Alternate KMS Key for Release Testing
Enabled: true
KeyPolicy:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'

S3ECReleaseKMSKeyAlias:
Type: 'AWS::KMS::Alias'
Properties:
Expand All @@ -263,7 +278,7 @@ Resources:
S3ECReleaseTestS3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: s3ec-release-test-bucket
BucketName: !Sub "s3ec-release-test-bucket-${AWS::StackName}"
LifecycleConfiguration:
Rules:
- Id: Expire in 14 days
Expand Down Expand Up @@ -313,3 +328,57 @@ Resources:
]
}
ManagedPolicyName: S3EC-Release-Test-KMS-Key-Policy

S3ECReleaseKMSKeyPolicyAlternate:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
PolicyDocument: !Sub |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Resource": [
"arn:aws:kms:*:${AWS::AccountId}:key/${S3ECReleaseKMSKeyIDAlternate}"
],
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey",
"kms:GenerateDataKeyPair"
]
}
]
}
ManagedPolicyName: S3EC-Release-KMS-Key-Policy-Alternate

S3ECReleaseTestRoleAlternate:
Type: 'AWS::IAM::Role'
Properties:
Path: /service-role/
RoleName: S3EC-Release-test-role-alternate
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service: codebuild.amazonaws.com
Action:
- "sts:AssumeRole"
Description: >-
Grant S3 put and get and KMS (alt key) encrypt, decrypt, and generate access
for testing
ManagedPolicyArns:
- !Ref S3ECReleaseKMSKeyPolicyAlternate
- !Ref S3ECReleaseS3BucketPolicy

S3ECReleaseAssumeAlternatePolicy:
Type: 'AWS::IAM::ManagedPolicy'
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: sts:AssumeRole
Resource:
Fn::GetAtt: [ S3ECReleaseTestRoleAlternate, Arn ]
ManagedPolicyName: S3EC-Release-Assume-Alternate-Policy