-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
102 lines (79 loc) · 1.81 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
data "aws_iam_policy_document" "ec2_assumerole" {
statement {
actions = [
"sts:AssumeRole",
]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
effect = "Allow"
}
}
data "aws_iam_policy_document" "poudriere" {
statement {
actions = [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation",
]
resources = ["arn:aws:s3:::*"]
}
statement {
actions = [
"s3:ListBucket",
]
resources = ["arn:aws:s3:::${var.pkg_s3_bucket}"]
}
statement {
actions = [
"s3:*",
]
resources = ["arn:aws:s3:::${var.pkg_s3_bucket}", "arn:aws:s3:::${var.pkg_s3_bucket}/*"]
}
statement {
actions = [
"s3:GetObject",
]
resources = ["arn:aws:s3:::${var.signing_s3_key}"]
}
statement {
actions = [
"ec2:Describe*",
]
resources = ["*"]
effect = "Allow"
}
statement {
actions = [
"autoscaling:SetDesiredCapacity",
]
resources = ["*"]
condition {
test = "StringEquals"
variable = "autoscaling:ResourceTag/role"
values = [
"poudriere",
]
}
effect = "Allow"
}
}
resource "aws_iam_instance_profile" "poudriere" {
name_prefix = "poudriere"
role = "${aws_iam_role.poudriere.name}"
}
resource "aws_iam_role" "poudriere" {
name_prefix = "poudriere"
path = "/"
assume_role_policy = "${data.aws_iam_policy_document.ec2_assumerole.json}"
}
resource "aws_iam_policy" "poudriere" {
name_prefix = "poudriere"
description = "poudriere access to s3 and ec2"
policy = "${data.aws_iam_policy_document.poudriere.json}"
}
resource "aws_iam_policy_attachment" "poudriere" {
name = "poudriere"
roles = ["${aws_iam_role.poudriere.name}"]
policy_arn = "${aws_iam_policy.poudriere.arn}"
}