This repository has been archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
iam.tf
67 lines (61 loc) · 1.45 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
resource "aws_key_pair" "default" {
key_name = "${var.role}"
public_key = "${var.root_key_pair_public_key}"
}
resource "aws_iam_role" "default" {
name = "${var.role}.${var.region}.i.${var.environment}.${var.dns["domain_name"]}"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}
resource "aws_iam_instance_profile" "default" {
name = "${var.role}.${var.region}.i.${var.environment}.${var.dns["domain_name"]}"
role = "${var.role}.${var.region}.i.${var.environment}.${var.dns["domain_name"]}"
depends_on = ["aws_iam_role.default"]
}
resource "aws_iam_role_policy" "default" {
name = "${var.role}.${var.region}.i.${var.environment}.${var.dns["domain_name"]}"
role = "${aws_iam_role.default.name}"
depends_on = ["aws_iam_role.default"]
lifecycle {
create_before_destroy = true
}
policy = <<EOF
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeAddresses",
"ec2:DescribeInstances",
"ec2:DescribeVolumes",
"ec2:DescribeVolumeStatus",
"ec2:AttachVolume",
"ec2:DetachVolume"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": "*"
}
]
}
EOF
}