-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtagPolicy.tf
47 lines (46 loc) · 1.09 KB
/
tagPolicy.tf
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
resource "aws_iam_policy" "TagBasedEC2RestrictionsPolicy" {
name = "TagBasedEC2RestrictionsPolicy"
path = "/"
//description = "My test policy"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "LaunchEC2Instances",
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:RunInstances",
"ec2:CreateSecurityGroup",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteSecurityGroup",
"ec2:RevokeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress"
],
"Resource": "*"
},
{
"Sid": "AllowActionsIfYouAreTheOwner",
"Effect": "Allow",
"Action": [
"ec2:StopInstances",
"ec2:StartInstances",
"ec2:RebootInstances",
"ec2:TerminateInstances",
"ec2:AttachVolume",
"ec2:DetachVolume",
"ec2:DeletehVolume"
],
"Resource": "*",
"Condition": {
"StringEquals":{
"ec2:ResourceTag/Owner": "$${aws:username}"
}
}
}
]
}
EOF
}