forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(aws-codepipeline): support for pipeline action’s service role
In realation to aws#49 The action’s service roles is a role which will be assumed by pipeline during execution of this action. The pipeline action’s service role can be used to perform more advanced configuration, when i.e. elevation of permissions is required, or when fine grained access control may be required. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-stages-actions.html This commit is motivated by enabling cross-account deployments, for which service role will be used as jump role to assume one used by Cloud Formation in target account.
- Loading branch information
Rado Smogura
committed
Jan 2, 2019
1 parent
1de9bcd
commit 3dd7836
Showing
6 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
317 changes: 317 additions & 0 deletions
317
packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-wtih-action-role.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,317 @@ | ||
{ | ||
"Resources": { | ||
"MyBucketF68F3FF0": { | ||
"Type": "AWS::S3::Bucket", | ||
"Properties": { | ||
"VersioningConfiguration": { | ||
"Status": "Enabled" | ||
} | ||
} | ||
}, | ||
"MyPipelineRoleC0D47CA4": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "codepipeline.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
}, | ||
"MyPipelineRoleDefaultPolicy34F09EFA": { | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"s3:GetObject*", | ||
"s3:GetBucket*", | ||
"s3:List*", | ||
"s3:DeleteObject*", | ||
"s3:PutObject*", | ||
"s3:Abort*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"MyBucketF68F3FF0", | ||
"Arn" | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::GetAtt": [ | ||
"MyBucketF68F3FF0", | ||
"Arn" | ||
] | ||
}, | ||
"/*" | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Action": [ | ||
"s3:GetObject*", | ||
"s3:GetBucket*", | ||
"s3:List*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"MyBucketF68F3FF0", | ||
"Arn" | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::GetAtt": [ | ||
"MyBucketF68F3FF0", | ||
"Arn" | ||
] | ||
}, | ||
"/*" | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Action": "iam:PassRole", | ||
"Effect": "Allow", | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"CFNDeployRole68D5E8D3", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
{ | ||
"Action": [ | ||
"cloudformation:CreateStack", | ||
"cloudformation:DescribeStack*", | ||
"cloudformation:GetStackPolicy", | ||
"cloudformation:GetTemplate*", | ||
"cloudformation:SetStackPolicy", | ||
"cloudformation:UpdateStack", | ||
"cloudformation:ValidateTemplate" | ||
], | ||
"Effect": "Allow", | ||
"Resource": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":cloudformation:", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
":", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":stack/aws-cdk-codepipeline-cross-region-deploy-stack/*" | ||
] | ||
] | ||
} | ||
}, | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole", | ||
"iam:PassRole" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "MyPipelineRoleDefaultPolicy34F09EFA", | ||
"Roles": [ | ||
{ | ||
"Ref": "MyPipelineRoleC0D47CA4" | ||
} | ||
] | ||
} | ||
}, | ||
"MyPipelineAED38ECF": { | ||
"Type": "AWS::CodePipeline::Pipeline", | ||
"Properties": { | ||
"RoleArn": { | ||
"Fn::GetAtt": [ | ||
"MyPipelineRoleC0D47CA4", | ||
"Arn" | ||
] | ||
}, | ||
"Stages": [ | ||
{ | ||
"Actions": [ | ||
{ | ||
"ActionTypeId": { | ||
"Category": "Source", | ||
"Owner": "AWS", | ||
"Provider": "S3", | ||
"Version": "1" | ||
}, | ||
"Configuration": { | ||
"S3Bucket": { | ||
"Ref": "MyBucketF68F3FF0" | ||
}, | ||
"S3ObjectKey": "some/path", | ||
"PollForSourceChanges": true | ||
}, | ||
"InputArtifacts": [], | ||
"Name": "S3", | ||
"OutputArtifacts": [ | ||
{ | ||
"Name": "Artifact_awscdkcodepipelinecloudformationcrossregionwithactionroleMyBucketS30423514B" | ||
} | ||
], | ||
"RunOrder": 1 | ||
} | ||
], | ||
"Name": "Source" | ||
}, | ||
{ | ||
"Actions": [ | ||
{ | ||
"ActionTypeId": { | ||
"Category": "Deploy", | ||
"Owner": "AWS", | ||
"Provider": "CloudFormation", | ||
"Version": "1" | ||
}, | ||
"Configuration": { | ||
"StackName": "aws-cdk-codepipeline-cross-region-deploy-stack", | ||
"ActionMode": "CREATE_UPDATE", | ||
"TemplatePath": "Artifact_awscdkcodepipelinecloudformationcrossregionwithactionroleMyBucketS30423514B::template.yml", | ||
"RoleArn": { | ||
"Fn::GetAtt": [ | ||
"CFNDeployRole68D5E8D3", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"InputArtifacts": [ | ||
{ | ||
"Name": "Artifact_awscdkcodepipelinecloudformationcrossregionwithactionroleMyBucketS30423514B" | ||
} | ||
], | ||
"Name": "CFN_Deploy", | ||
"OutputArtifacts": [], | ||
"RoleArn": { | ||
"Fn::GetAtt": [ | ||
"ActionRole60B0EDF7", | ||
"Arn" | ||
] | ||
}, | ||
"RunOrder": 1 | ||
} | ||
], | ||
"Name": "CFN" | ||
} | ||
], | ||
"ArtifactStore": { | ||
"Location": { | ||
"Ref": "MyBucketF68F3FF0" | ||
}, | ||
"Type": "S3" | ||
} | ||
}, | ||
"DependsOn": [ | ||
"MyPipelineRoleC0D47CA4", | ||
"MyPipelineRoleDefaultPolicy34F09EFA" | ||
] | ||
}, | ||
"ActionRole60B0EDF7": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"AWS": { | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::", | ||
{ | ||
"Ref": "AWS::AccountId" | ||
}, | ||
":root" | ||
] | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
}, | ||
"ActionRoleDefaultPolicyCA33BE56": { | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sqs:*", | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "ActionRoleDefaultPolicyCA33BE56", | ||
"Roles": [ | ||
{ | ||
"Ref": "ActionRole60B0EDF7" | ||
} | ||
] | ||
} | ||
}, | ||
"CFNDeployRole68D5E8D3": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "cloudformation.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.