-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
99 lines (81 loc) · 1.98 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
# Vault Instance Role
resource "aws_iam_instance_profile" "vault" {
name = "vault"
role = aws_iam_role.vault.name
}
resource "aws_iam_role" "vault" {
name = "vault"
description = "Vault"
assume_role_policy = data.aws_iam_policy_document.vault_trust.json
}
data "aws_iam_policy_document" "vault_trust" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role_policy" "vault" {
name = "vault"
role = aws_iam_role.vault.name
policy = data.aws_iam_policy_document.vault_role.json
}
data "aws_iam_policy_document" "vault_role" {
statement {
sid = "AllowAssumeRole"
actions = ["sts:AssumeRole"]
resources = ["*"]
}
# Used by the AWS authentication backend
statement {
sid = "AllowIAMAuth"
actions = [
"ec2:DescribeInstances",
"iam:GetInstanceProfile",
"iam:GetUser",
"iam:GetRole",
"sts:GetCallerIdentity",
]
resources = ["*"]
}
statement {
sid = "AllowLogging"
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams",
]
resources = ["arn:aws:logs:*:*:*"]
}
statement {
sid = "AllowS3ListAllBuckets"
actions = ["s3:ListAllMyBuckets"]
resources = ["*"]
}
statement {
sid = "AllowS3AccessToAssetsBucket"
actions = ["*"]
resources = [
"arn:aws:s3:::${aws_s3_bucket.vault.id}",
"arn:aws:s3:::${aws_s3_bucket.vault.id}/*",
]
}
statement {
sid = "AllowKMSUse"
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
]
resources = ["arn:aws:kms:*:*:alias/aws/s3"]
}
}
resource "aws_iam_role_policy_attachment" "vault_dynamodb" {
role = aws_iam_role.vault.name
policy_arn = "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
}