-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathenv-iam-setup-stackset-role.yaml
More file actions
165 lines (155 loc) · 5.61 KB
/
env-iam-setup-stackset-role.yaml
File metadata and controls
165 lines (155 loc) · 5.61 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: 2010-09-09
Description: Creates a stack set execution IAM role in target accounts (staging, prod) for StackSet operations
Parameters:
EnvName:
Type: String
AllowedPattern: '[a-z0-9\-]*'
Description: Please specify your data science environment/team name. Used as a suffix for environment resource names.
EnvType:
Description: System Environment (e.g. dev, staging, prod). Used as a suffix for environment resource names.
Type: String
Default: dev
StackSetExecutionRoleName:
Type: String
Description: Name of the CloudFormation StackSet execution role. If empty, the name will be generated
Default: ''
AdministratorAccountId:
Type: String
Description: AWS Account Id of the account in which StackSets will be created (for multi-account deployment)
MaxLength: 12
MinLength: 12
Outputs:
StackSetExecutionRoleArn:
Description: The ARN of the AWS CloudFormation StackSet execution role
Value: !GetAtt SetupStackSetExecutionRole.Arn
StackSetExecutionRoleName:
Description: The name of the AWS CloudFormation StackSet execution role
Value: !Select ['1', !Split [ '/', !Select ['5', !Split [':', !GetAtt SetupStackSetExecutionRole.Arn ]]]]
Conditions:
GenerateStackSetExecutionRoleName: !Equals [ !Ref StackSetExecutionRoleName, '']
Resources:
# This role is used by StackSet operations in the target account to setup the infrastructure
SetupStackSetExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS:
- !Ref AdministratorAccountId
Action:
- sts:AssumeRole
Path: /
RoleName: !If
- GenerateStackSetExecutionRoleName
- !Ref 'AWS::NoValue'
- !Ref StackSetExecutionRoleName
Policies:
-
PolicyName: !Sub "${EnvName}-${EnvType}-${AWS::Region}-stackset-execution-policy"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: Allow
Action:
- 'cloudformation:Cancel*'
- 'cloudformation:Continue*'
- 'cloudformation:Create*'
- 'cloudformation:Deactivate*'
- 'cloudformation:Delete*'
- 'cloudformation:Describe*'
- 'cloudformation:Get*'
- 'cloudformation:Detect*'
- 'cloudformation:Execute*'
- 'cloudformation:Estimate*'
- 'cloudformation:List*'
- 'cloudformation:Publish*'
- 'cloudformation:Set*'
- 'cloudformation:Register*'
- 'cloudformation:Signal*'
- 'cloudformation:Stop*'
- 'cloudformation:Update*'
- 'cloudformation:Validate*'
- 'cloudformation:Test*'
Resource:
- !Sub 'arn:aws:cloudformation:*:${AWS::AccountId}:*'
-
Effect: Allow
Action:
- 's3:Get*'
- 's3:List*'
- 's3:Create*'
- 's3:Head*'
- 's3:Put*'
- 's3:Upload*'
Resource:
- 'arn:aws:s3:::*'
-
Effect: Allow
Action:
- 'sns:Create*'
- 'sns:Get*'
- 'sns:List*'
- 'sns:Publish'
- 'sns:Set*'
- 'sns:Subscribe'
- 'sns:Tag*'
- 'sns:Unsubscribe'
- 'sns:Untag*'
- 'sns:Add*'
Resource:
- 'arn:aws:sns:*:*:*'
-
Effect: Allow
Action:
- 'iam:Create*'
- 'iam:Attach*'
- 'iam:Add*'
- 'iam:Delete*'
- 'iam:Get*'
- 'iam:Create*'
- 'iam:List*'
- 'iam:Put*'
- 'iam:Tag*'
- 'iam:Update*'
- 'iam:Set*'
- 'iam:Remove*'
- 'iam:Detach*'
Resource:
- 'arn:*:iam::*:role/*StackSetExecution*'
- 'arn:*:iam::*:role/*SageMakerModelExecution*'
- Effect: Allow
Action:
- 'ec2:DescribeAvailabilityZones'
- 'ec2:CreateTags'
- 'ec2:DeleteTags'
- 'ec2:DescribeTags'
Resource:
- '*'
- Effect: Allow
Action:
- 'ssm:AddTagsToResource'
- 'ssm:DeleteParameter'
- 'ssm:GetParameter'
- 'ssm:PutParameter'
- 'ssm:RemoveTagsFromResource'
Resource:
- !Sub 'arn:aws:ssm:*:${AWS::AccountId}:*'
- Effect: Allow
Action:
- 'ssm:DeleteParameters'
- 'ssm:GetParameters'
Resource:
- '*'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonVPCFullAccess'
Tags:
- Key: EnvironmentName
Value: !Ref EnvName
- Key: EnvironmentType
Value: !Ref EnvType