forked from clareliguori/spinnaker-ecs-devel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spinnaker-roles.yml
136 lines (127 loc) · 4.09 KB
/
spinnaker-roles.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
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
AWSTemplateFormatVersion: '2010-09-09'
Description: Setup AWS IAM roles for Spinnaker
Resources:
SpinnakerDevInstanceRole:
Type: AWS::IAM::Role
Properties:
RoleName: SpinnakerDevInstanceRole
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonS3FullAccess
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
SpinnakerDevInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref SpinnakerDevInstanceRole
InstanceProfileName: SpinnakerDevInstanceRole
SpinnakerDevInstancePolicy:
Type: AWS::IAM::Policy
Properties:
Roles:
- !Ref SpinnakerDevInstanceRole
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action: sts:AssumeRole
Effect: Allow
Resource: !GetAtt SpinnakerManagedRole.Arn
- Action:
- "ec2:DescribeRegions"
- "ec2:DescribeAvailabilityZones"
Effect: Allow
Resource: "*"
PolicyName: SpinnakerDevInstanceAssumeManagedRole
SpinnakerManagedRole:
Type: AWS::IAM::Role
Properties:
RoleName: SpinnakerManaged
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
AWS: !GetAtt SpinnakerDevInstanceRole.Arn
Service:
# TODO: Remove the requirement to re-use the Spinnaker Managed Role for
# various ECS service roles (https://github.com/spinnaker/spinnaker/issues/3340).
- ecs-tasks.amazonaws.com
- application-autoscaling.amazonaws.com
- ecs.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/PowerUserAccess
SpinnakerManagedPolicy:
Type: AWS::IAM::Policy
Properties:
Roles:
- !Ref SpinnakerManagedRole
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action: iam:PassRole
Effect: Allow
Resource:
- !GetAtt SpinnakerManagedRole.Arn
- "arn:aws:iam::*:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"
Condition:
StringLike:
"iam:PassedToService":
- application-autoscaling.amazonaws.com
- ec2.amazonaws.com
- ecs-tasks.amazonaws.com
- ecs.amazonaws.com
- Action: iam:CreateServiceLinkedRole
Effect: Allow
Resource: "*"
Condition:
StringLike:
"iam:AWSServiceName":
- ecs.application-autoscaling.amazonaws.com
- ecs.amazonaws.com
PolicyName: SpinnakerPassRole
ECSContainerInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: /
Roles: [!Ref 'ECSContainerInstanceRole']
InstanceProfileName: SpinnakerECSContainerInstances
ECSContainerInstanceRole:
Type: AWS::IAM::Role
Properties:
RoleName: SpinnakerECSContainerInstances
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [ec2.amazonaws.com]
Action: ['sts:AssumeRole']
Path: /
Policies:
- PolicyName: ecs-service
PolicyDocument:
Statement:
- Effect: Allow
Action:
- 'ecs:CreateCluster'
- 'ecs:DeregisterContainerInstance'
- 'ecs:DiscoverPollEndpoint'
- 'ecs:Poll'
- 'ecs:RegisterContainerInstance'
- 'ecs:StartTelemetrySession'
- 'ecs:Submit*'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
- 'ecr:GetAuthorizationToken'
- 'ecr:BatchGetImage'
- 'ecr:GetDownloadUrlForLayer'
Resource: '*'