-
Notifications
You must be signed in to change notification settings - Fork 0
/
master.yml
103 lines (97 loc) · 3.28 KB
/
master.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
AWSTemplateFormatVersion: '2010-09-09'
Description: Devops Assume Role into Account
Parameters:
CodePipelineAccountId:
Type: String
Description: Account ID of the Devops Account
ArtifactBucketArn:
Type: String
Description: Devops Artifact Bucket Ex arn:aws:s3:::devopsautomationrole-artifactbucket-abcdefg"
CodePiplineKMSKeyID:
Type: String
Description: The key id of the sso s3 bucket key. Ex 123456ad-3b12-4e22-be03-12345oea.
Resources:
DevopsAutomationRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS: !Sub "arn:aws:iam::${CodePipelineAccountId}:root"
Action: "sts:AssumeRole"
Condition:
ArnLike:
"aws:PrincipalArn":
- !Sub "arn:${AWS::Partition}:iam::${CodePipelineAccountId}:role/examplecompany/SSOCodePipelineRole"
Path: /examplecompany/
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/AWSCloudFormationFullAccess
Description: Role For Devops account to assume into this account
RoleName: ExampleCompanyMasterDevopsRole
Tags:
- Key: "ApplicationID"
Value: "1"
- Key: "Classification"
Value: "Confidential"
- Key: "SupportTeam"
Value: "[email protected]"
DevopsAutomationPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "s3:PutObject"
- "s3:GetObject"
- "s3:GetObjectVersion"
- "s3:GetBucketAcl"
- "s3:GetBucketLocation"
- "s3:GetObjectVersion"
- "s3:PutObjectAcl"
- "s3:GetBucketVersioning"
Resource:
- !Ref ArtifactBucketArn
- !Sub "${ArtifactBucketArn}/*"
- Effect: Allow
Action:
- "iam:PassRole"
- "iam:GetRole"
Resource: {"Fn::GetAtt" : [CloudformationRole, "Arn"] }
- Effect: Allow
Action:
- "kms:Decrypt"
- "kms:Encrypt"
- "kms:GenerateDataKey"
- "kms:List*"
Resource: !Sub "arn:${AWS::Partition}:kms:${AWS::Region}:${CodePipelineAccountId}:key/${CodePiplineKMSKeyID}"
PolicyName: ExampleCompanyDevopsAutomationPolicy
Roles:
- !Ref DevopsAutomationRole
CloudformationRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- cloudformation.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /examplecompany/
Description: Role For Cloudformation
RoleName: ExampleCompanyCloudformationRole
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/AdministratorAccess
Tags:
- Key: "ApplicationID"
Value: "1"
- Key: "Classification"
Value: "Confidential"
- Key: "SupportTeam"
Value: "[email protected]"