-
Notifications
You must be signed in to change notification settings - Fork 82
/
config-service.tf
54 lines (42 loc) · 1.59 KB
/
config-service.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
#
# AWS Config Service
#
resource "aws_config_configuration_recorder_status" "main" {
count = var.enable_config_recorder ? 1 : 0
name = var.config_name
is_enabled = true
depends_on = [aws_config_delivery_channel.main]
}
resource "aws_config_delivery_channel" "main" {
count = var.enable_config_recorder ? 1 : 0
name = var.config_name
s3_bucket_name = var.config_logs_bucket
s3_key_prefix = var.config_logs_prefix
s3_kms_key_arn = var.config_logs_bucket_kms_key_arn
sns_topic_arn = var.config_sns_topic_arn
snapshot_delivery_properties {
delivery_frequency = var.config_delivery_frequency
}
depends_on = [aws_config_configuration_recorder.main]
}
resource "aws_config_configuration_recorder" "main" {
count = var.enable_config_recorder ? 1 : 0
name = var.config_name
role_arn = aws_iam_role.main[count.index].arn
recording_group {
all_supported = length(var.resource_types) == 0 ? true : false
include_global_resource_types = length(var.resource_types) == 0 ? var.include_global_resource_types : null
resource_types = length(var.resource_types) == 0 ? null : var.resource_types
}
recording_mode {
recording_frequency = var.config_recording_frequency
dynamic "recording_mode_override" {
for_each = var.config_recording_frequency_overrides
content {
description = recording_mode_override.value.description
resource_types = recording_mode_override.value.resource_types
recording_frequency = recording_mode_override.value.recording_frequency
}
}
}
}