-
Notifications
You must be signed in to change notification settings - Fork 2
/
iam.tf
46 lines (39 loc) · 1.12 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
//--------------------------------------------------------------------
// Resources
## tfe Server IAM Config
resource "aws_iam_instance_profile" "tfe-server" {
name = "${var.environment_name}-instance-profile"
role = aws_iam_role.tfe-server.name
}
resource "aws_iam_role" "tfe-server" {
name = "${var.environment_name}-role"
assume_role_policy = data.aws_iam_policy_document.assume_role.json
}
resource "aws_iam_role_policy" "tfe-server" {
name = "${var.environment_name}-role-policy"
role = aws_iam_role.tfe-server.id
policy = data.aws_iam_policy_document.tfe-server.json
}
//--------------------------------------------------------------------
// Data Sources
data "aws_iam_policy_document" "assume_role" {
statement {
effect = "Allow"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
# Should narrow this policy down to the bucket
data "aws_iam_policy_document" "tfe-server" {
statement {
sid = "S3TFEStateStorage"
effect = "Allow"
actions = [
"s3:*",
]
resources = ["*"]
}
}