-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcodepipeline-access.yaml
59 lines (56 loc) · 1.86 KB
/
codepipeline-access.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
ToolsAccountId:
AllowedPattern: ^[0-9]{12}$
ConstraintDescription: Must be a valid AWS account ID
Type: String
Default: "TOOLS_ACCOUNT_ID" # Replace with tools account id
KMSKeyArn:
Description: ARN of the KMS Key used by CodePipeline
Type: String
Default: "KMS_KEY_ARN" # Replace with key arn as generated by codepipeline-base.yaml
Resources:
PipelineCrossAccountRole:
Type: AWS::IAM::Role
Properties:
RoleName: "PipelineCrossAccountRole"
AssumeRolePolicyDocument:
Statement:
- Action: ["sts:AssumeRole"]
Effect: Allow
Principal:
Service: [codepipeline.amazonaws.com]
- Action: ["sts:AssumeRole"]
Effect: Allow
Principal:
AWS: !Sub "arn:aws:iam::${ToolsAccountId}:root"
Version: "2012-10-17"
Path: /
Policies:
- PolicyName: PipelineCrossAccountDeployment
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: "AllowDeployment"
Action:
- "ecs:DescribeServices",
- "ecs:DescribeTaskDefinition",
- "ecs:DescribeTasks",
- "ecs:ListTasks",
- "ecs:RegisterTaskDefinition",
- "ecs:UpdateService"
Effect: Allow
Resource: "*"
- Action:
- "kms:Encrypt"
- "kms:Decrypt"
- "kms:ReEncrypt*"
- "kms:GenerateDataKey*"
- "kms:DescribeKey"
Effect: Allow
Resource: !Ref KMSKeyArn
Sid: "AllowKMS"
Outputs:
PipelineCrossAccountRole:
Description: Pipeline Cross Account Role
Value: !GetAtt [PipelineCrossAccountRole, Arn]