generated from GSA/grace-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.tf
61 lines (51 loc) · 1.66 KB
/
config.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
resource "aws_iam_role" "config" {
name = var.config_role_name
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "config.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
POLICY
}
resource "aws_iam_role_policy_attachment" "config" {
role = aws_iam_role.config.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSConfigRole"
}
resource "aws_iam_role_policy_attachment" "organization" {
role = aws_iam_role.config.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSConfigRoleForOrganizations"
}
resource "aws_config_configuration_recorder" "config" {
count = var.config_recorder_enable ? 1 : 0
name = var.config_recorder_name
role_arn = aws_iam_role.config.arn
recording_group {
all_supported = var.config_recorder_group_all_supported
include_global_resource_types = var.config_recorder_group_include_global
}
}
resource "aws_config_delivery_channel" "config" {
count = var.config_recorder_enable ? 1 : 0
name = var.config_delivery_name
s3_bucket_name = var.config_delivery_bucket
s3_key_prefix = var.config_delivery_bucket_prefix
snapshot_delivery_properties {
delivery_frequency = var.config_delivery_frequency
}
depends_on = ["aws_config_configuration_recorder.config"]
}
resource "aws_config_configuration_recorder_status" "config" {
count = var.config_recorder_enable ? 1 : 0
name = aws_config_configuration_recorder.config.0.name
is_enabled = var.config_recorder_enabled
depends_on = ["aws_config_delivery_channel.config"]
}