-
Notifications
You must be signed in to change notification settings - Fork 3
/
firewall_role.tf
62 lines (58 loc) · 1.41 KB
/
firewall_role.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
resource "aws_iam_role" "valtix_fw_role" {
name = "${var.prefix}-firewall-role"
tags = {
Name = "${var.prefix}-firewall-role"
prefix = var.prefix
}
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Principal = {
Service = "ec2.amazonaws.com"
},
Effect = "Allow"
}
]
})
}
resource "aws_iam_role_policy" "valtix_fw_policy" {
name = "${var.prefix}_fw_policy"
role = aws_iam_role.valtix_fw_role.id
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = [
"s3:PutObject",
"s3:ListBucket"
],
Effect = "Allow",
Resource = "arn:aws:s3:::*/*"
},
{
Action = [
"kms:Decrypt"
],
Effect = "Allow",
Resource = "*"
},
{
Action = [
"secretsmanager:GetSecretValue"
],
Effect = "Allow",
Resource = "*"
}
]
})
}
# for instances to use the role, an instance profile must be created and
# instance profile name used on the instance's iam role
# however on the firewall iam role text box you can provide the role
# name or the arn of either the role or the instance profile
resource "aws_iam_instance_profile" "valtix_fw_role" {
name = "${var.prefix}-firewall-role"
role = aws_iam_role.valtix_fw_role.name
}