-
Notifications
You must be signed in to change notification settings - Fork 1
/
iam.tf
115 lines (110 loc) · 3.52 KB
/
iam.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
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
resource "aws_iam_role" "splunk_role" {
name = "splunk-role-${random_id.random.hex}"
path = "/"
tags = merge(
local.common_tags,
{
"Name" = "splunk-role-${random_id.random.hex}"
},
)
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_iam_role_policy" "splunk_policy" {
name = "splunk-policy-${random_id.random.hex}"
role = aws_iam_role.splunk_role.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:Describe*",
"ec2:DeleteSubnet",
"ec2:DeleteRouteTable",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteVolume",
"ec2:StartInstances",
"ec2:DeleteInternetGateway",
"ec2:UnassignPrivateIpAddresses",
"ec2:CreateTags",
"ec2:RunInstances",
"ec2:DetachInternetGateway",
"ec2:AssignPrivateIpAddresses",
"ec2:StopInstances",
"ec2:DisassociateRouteTable",
"ec2:ReplaceNetworkAclAssociation",
"ec2:CreateVolume",
"ec2:CancelSpotInstanceRequests",
"ec2:GetPasswordData",
"ec2:DeleteVpc",
"ec2:AssociateAddress",
"ec2:DeleteNetworkAclEntry",
"ec2:RequestSpotInstances",
"ec2:ModifyImageAttribute",
"ec2:GetConsoleOutput",
"ec2:DeleteNetworkAcl",
"ec2:TerminateInstances",
"ec2:DeleteRoute",
"ec2:AllocateAddress",
"ec2:DeleteSecurityGroup",
"ec2:CreateSecurityGroup",
"iam:ListRoles",
"iam:GetRole",
"iam:ListAttachedRolePolicies",
"iam:GetUser",
"iam:GetLoginProfile",
"iam:ListMFADevices",
"iam:ListAccessKeys",
"iam:ListUserPolicies",
"iam:ListAttachedUserPolicies",
"iam:GetAccountPasswordPolicy",
"iam:ListVirtualMFADevices",
"iam:ListUsers",
"iam:ListMFADevices",
"iam:GetPolicy",
"iam:GetPolicyVersion",
"iam:ListPolicy",
"iam:ListEntitiesForPolicy",
"iam:GetAccessKeyLastUsed",
"iam:ListPolicies",
"iam:ListEntitiesForPolicy",
"cloudtrail:DescribeTrails",
"ec2:DescribeVpcs",
"ec2:DescribeSecurityGroups",
"config:DescribeConfigurationRecorders",
"config:DescribeDeliveryChannels",
"s3:GetBucketAcl",
"s3:GetBucketLocation",
"s3:GetBucketLogging",
"s3:GetBucketPolicy",
"s3:GetEncryptionConfiguration",
"cloudwatch:DescribeAlarmsForMetric",
"sns:GetTopicAttributes"
],
"Resource": "*"
}
]
}
EOF
}
resource "aws_iam_instance_profile" "splunk_instance_profile" {
name = "splunk-instance-profile-${random_id.random.hex}"
role = aws_iam_role.splunk_role.name
}