-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathcompute.yaml
188 lines (181 loc) · 7.3 KB
/
compute.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
Version: '2012-10-17'
Statement:
# Restrict the types of instances that can be started
# ASGs call run-instances --dry-run so the actions need to be grouped
- Sid: AllowRunInstancesInstanceType
Effect: Allow
Action:
- autoscaling:AttachInstances
- autoscaling:CreateAutoScalingGroup
- autoscaling:CreateLaunchConfiguration
- autoscaling:UpdateAutoScalingGroup
- autoscaling:DetachInstances
- ec2:RunInstances
- ec2:StartInstances
Resource:
- 'arn:aws:autoscaling:{{ aws_region }}:{{ aws_account_id }}:launchConfiguration:*'
- 'arn:aws:autoscaling:{{ aws_region }}:{{ aws_account_id }}:autoScalingGroup:*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:instance/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:image/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:launch-template/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:snapshot/*'
Condition:
StringEqualsIfExists:
ec2:InstanceType:
- t2.nano
- t2.micro
- t3.nano
- t3.micro
- t3a.micro
- m1.large # lowest cost instance type with EBS optimization supported
# Permit RunInstance to access any of the usual objects attached to an
# instance
- Sid: AllowEc2RunInstances
Effect: Allow
Action:
- ec2:RunInstances
Resource:
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:key-pair/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:network-interface/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:placement-group/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:security-group/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:subnet/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:volume/*'
- 'arn:aws:ec2:{{ aws_region }}::image/*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:launch-template/*'
- 'arn:aws:autoscaling:{{ aws_region }}:{{ aws_account_id }}:autoScalingGroup*'
- Sid: AllowRegionalUnrestrictedResourceActionsWhichIncurNoFees
Effect: Allow
Action:
- ec2:AttachVolume
- ec2:CancelSpotInstanceRequests
- ec2:CreateImage
- ec2:CreateKeyPair
- ec2:CreateLaunchTemplate
- ec2:CreateLaunchTemplateVersion
- ec2:CreatePlacementGroup
- ec2:CreateSnapshot
- ec2:CreateTags
- ec2:DeleteKeyPair
- ec2:DeleteLaunchTemplate
- ec2:DeleteLaunchTemplateVersions
- ec2:DeletePlacementGroup
- ec2:DeleteSnapshot
- ec2:DeleteTags
- ec2:DeregisterImage
- ec2:DetachVolume
- ec2:DisassociateIamInstanceProfile
- ec2:Get*
- ec2:ImportKeyPair
- ec2:ModifyImageAttribute
- ec2:ModifyInstanceAttribute
- ec2:ModifyInstanceMetadataOptions
- ec2:ModifyLaunchTemplate
- ec2:ModifySnapshotAttribute
- ec2:ModifyVolume
- ec2:RegisterImage
- ec2:ReplaceIamInstanceProfileAssociation
- ec2:ResetSnapshotAttribute
- ec2:StopInstances
- ec2:TerminateInstances
Resource:
- "*"
Condition:
StringEquals:
ec2:Region:
- '{{ aws_region }}'
# Spot Request permissions need to be pretty open
# https://stackoverflow.com/questions/36570812/aws-ec2-iam-policy-for-ec2requestspotinstances
- Sid: AllowGlobalUnrestrictedResourceActionsWhichIncurFees
Effect: Allow
Action:
- ec2:RequestSpotInstances
Resource:
- "*"
Condition:
StringEqualsIfExists:
ec2:InstanceType:
- t2.nano
- t2.micro
- t3.nano
- t3.micro
- t3a.micro
- m1.large # lowest cost instance type with EBS optimization supported
# ASG and ELB don't like being region restricted.
- Sid: AllowGlobalUnrestrictedResourceActionsWhichIncurNoFees
Effect: Allow
Action:
- autoscaling:Describe*
- autoscaling:ResumeProcesses
- autoscaling:SuspendProcesses
- ec2:Describe*
- elasticloadbalancing:DeleteRule
- elasticloadbalancing:DeleteListener
- elasticloadbalancing:Describe*
- elasticloadbalancing:DeregisterTargets
- elasticloadbalancing:ModifyListener
- elasticloadbalancing:ModifyTargetGroupAttributes
- elasticloadbalancing:ModifyRule
- elasticloadbalancing:SetIpAddressType
- elasticloadbalancing:SetRulePriorities
Resource:
- "*"
- Sid: AllowGlobalRestrictedResourceActionsWhichIncurFees
Effect: Allow
Action:
- autoscaling:EnableMetricsCollection
- ec2:CreateVolume
- elasticloadbalancing:CreateLoadBalancer*
- elasticloadbalancing:CreateRule
Resource:
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:volume/*'
- 'arn:aws:elasticloadbalancing:{{ aws_region }}:{{ aws_account_id }}:*'
- 'arn:aws:autoscaling:{{ aws_region }}:{{ aws_account_id }}:autoScalingGroup*'
- Sid: AllowGlobalResourceRestrictedActionsWhichIncurNoFees
Effect: Allow
Action:
- autoscaling:AttachLoadBalancerTargetGroups
- autoscaling:CancelInstanceRefresh
- autoscaling:CompleteLifecycleAction
- autoscaling:CreateOrUpdateTags
- autoscaling:Delete*
- autoscaling:DetachLoadBalancers
- autoscaling:DetachLoadBalancerTargetGroups
- autoscaling:DisableMetricsCollection
- autoscaling:PutScalingPolicy
- autoscaling:PutScheduledUpdateGroupAction
- autoscaling:PutLifecycleHook
- autoscaling:StartInstanceRefresh
- autoscaling:SetInstanceHealth
- autoscaling:SetInstanceProtection
- autoscaling:TerminateInstanceInAutoScalingGroup
- ec2:DeleteVolume
- elasticloadbalancing:AddListenerCertificates
- elasticloadbalancing:AddTags
- elasticloadbalancing:ApplySecurityGroupsToLoadBalancer
- elasticloadbalancing:AttachLoadBalancerToSubnets
- elasticloadbalancing:ConfigureHealthCheck
- elasticloadbalancing:CreateAppCookieStickinessPolicy
- elasticloadbalancing:CreateLBCookieStickinessPolicy
- elasticloadbalancing:CreateListener
- elasticloadbalancing:CreateTargetGroup
- elasticloadbalancing:Delete*
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
- elasticloadbalancing:DetachLoadBalancerFromSubnets
- elasticloadbalancing:DisableAvailabilityZonesForLoadBalancer
- elasticloadbalancing:EnableAvailabilityZonesForLoadBalancer
- elasticloadbalancing:ModifyLoadBalancerAttributes
- elasticloadbalancing:RemoveTags
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
- elasticloadbalancing:RegisterTargets
- elasticloadbalancing:SetLoadBalancer*
- elasticloadbalancing:SetSecurityGroups
- elasticloadbalancing:SetWebACL
Resource:
- 'arn:aws:autoscaling:{{ aws_region }}:{{ aws_account_id }}:launchConfiguration:*'
- 'arn:aws:autoscaling:{{ aws_region }}:{{ aws_account_id }}:autoScalingGroup:*'
- 'arn:aws:ec2:{{ aws_region }}:{{ aws_account_id }}:volume/*'
- 'arn:aws:elasticfilesystem:{{ aws_region }}:{{ aws_account_id }}:file-system/*'
- 'arn:aws:elasticloadbalancing:{{ aws_region }}:{{ aws_account_id }}:targetgroup/*'
- 'arn:aws:elasticloadbalancing:{{ aws_region }}:{{ aws_account_id }}:loadbalancer/*'
- 'arn:aws:elasticloadbalancing:{{ aws_region }}:{{ aws_account_id }}:listener/*'