forked from hashicorp/microservices-architecture-on-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
46 lines (42 loc) · 1.25 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
# Consul Instance Role
resource "aws_iam_role" "consul_instance" {
name_prefix = "${local.project_tag}-role-"
assume_role_policy = data.aws_iam_policy_document.instance_trust_policy.json
}
## Consul Instance Trust Policy
data "aws_iam_policy_document" "instance_trust_policy" {
statement {
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
actions = [
"sts:AssumeRole"
]
}
}
## Consul Instance Permissions Policy
data "aws_iam_policy_document" "instance_permissions_policy" {
statement {
sid = "DescribeInstances" # change this to describe instances...
effect = "Allow"
actions = [
"ec2:DescribeInstances"
]
resources = [
"*"
]
}
}
## Consul Instance Role <> Policy Attachment
resource "aws_iam_role_policy" "consul_instance_policy" {
name_prefix = "${local.project_tag}-instance-policy-"
role = aws_iam_role.consul_instance.id
policy = data.aws_iam_policy_document.instance_permissions_policy.json
}
## Consul Instance Profile <> Role Attachment
resource "aws_iam_instance_profile" "consul_instance_profile" {
name_prefix = "${local.project_tag}-instance-profile-"
role = aws_iam_role.consul_instance.name
}