Skip to content

Commit 91d1ea5

Browse files
committed
feat(config-recorder): support aws provider v6
1 parent e3694b7 commit 91d1ea5

File tree

8 files changed

+66
-37
lines changed

8 files changed

+66
-37
lines changed

modules/config-recorder/README.md

Lines changed: 23 additions & 22 deletions
Large diffs are not rendered by default.

modules/config-recorder/aggregator.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# Authorization for Aggregators
33
###################################################
44

5+
# TODO: Not yet support `region` for AWS provider v6
56
resource "aws_config_aggregate_authorization" "this" {
67
for_each = {
78
for aggregator in var.authorized_aggregators :
89
"${aggregator.account}:${aggregator.region}" => aggregator
910
}
1011

11-
account_id = each.value.account
12-
region = each.value.region
12+
account_id = each.value.account
13+
authorized_aws_region = each.value.region
1314

1415
tags = merge(
1516
local.module_tags,
@@ -29,6 +30,8 @@ resource "aws_config_configuration_aggregator" "account" {
2930
aggregation.name => aggregation
3031
}
3132

33+
region = var.region
34+
3235
name = each.key
3336

3437
account_aggregation_source {
@@ -53,6 +56,8 @@ resource "aws_config_configuration_aggregator" "account" {
5356
resource "aws_config_configuration_aggregator" "organization" {
5457
count = var.organization_aggregation.enabled ? 1 : 0
5558

59+
region = var.region
60+
5661
name = var.organization_aggregation.name
5762

5863
organization_aggregation_source {

modules/config-recorder/iam.tf

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module "role__recorder" {
1313
count = var.default_service_role.enabled ? 1 : 0
1414

1515
source = "tedilabs/account/aws//modules/iam-role"
16-
version = "~> 0.28.0"
16+
version = "~> 0.32.0"
1717

1818
name = coalesce(
1919
var.default_service_role.name,
@@ -39,9 +39,11 @@ module "role__recorder" {
3939
var.default_service_role.inline_policies
4040
)
4141

42-
force_detach_policies = true
43-
resource_group_enabled = false
44-
module_tags_enabled = false
42+
force_detach_policies = true
43+
resource_group = {
44+
enabled = false
45+
}
46+
module_tags_enabled = false
4547

4648
tags = merge(
4749
local.module_tags,
@@ -53,7 +55,7 @@ module "role__aggregator" {
5355
count = var.organization_aggregation.enabled && var.default_organization_aggregator_role.enabled ? 1 : 0
5456

5557
source = "tedilabs/account/aws//modules/iam-role"
56-
version = "~> 0.28.0"
58+
version = "~> 0.32.0"
5759

5860
name = coalesce(
5961
var.default_organization_aggregator_role.name,
@@ -74,9 +76,11 @@ module "role__aggregator" {
7476
)
7577
inline_policies = var.default_organization_aggregator_role.inline_policies
7678

77-
force_detach_policies = true
78-
resource_group_enabled = false
79-
module_tags_enabled = false
79+
force_detach_policies = true
80+
resource_group = {
81+
enabled = false
82+
}
83+
module_tags_enabled = false
8084

8185
tags = merge(
8286
local.module_tags,

modules/config-recorder/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ locals {
6060
###################################################
6161

6262
resource "aws_config_configuration_recorder" "this" {
63+
region = var.region
64+
6365
name = var.name
6466
role_arn = (var.default_service_role.enabled
6567
? module.role__recorder[0].arn
@@ -101,6 +103,8 @@ resource "aws_config_configuration_recorder" "this" {
101103
}
102104

103105
resource "aws_config_configuration_recorder_status" "this" {
106+
region = var.region
107+
104108
name = aws_config_configuration_recorder.this.name
105109
is_enabled = var.enabled
106110

@@ -110,6 +114,8 @@ resource "aws_config_configuration_recorder_status" "this" {
110114
}
111115

112116
resource "aws_config_retention_configuration" "this" {
117+
region = var.region
118+
113119
retention_period_in_days = var.retention_period
114120
}
115121

@@ -119,6 +125,8 @@ resource "aws_config_retention_configuration" "this" {
119125
###################################################
120126

121127
resource "aws_config_delivery_channel" "this" {
128+
region = var.region
129+
122130
name = aws_config_configuration_recorder.this.name
123131

124132
s3_bucket_name = var.delivery_channels.s3_bucket.name

modules/config-recorder/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
output "region" {
2+
description = "The AWS region this module resources resides in."
3+
value = aws_config_configuration_recorder.this.region
4+
}
5+
16
output "name" {
27
description = "The name of the recorder."
38
value = aws_config_configuration_recorder.this.name

modules/config-recorder/resource-group.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module "resource_group" {
1616

1717
count = (var.resource_group.enabled && var.module_tags_enabled) ? 1 : 0
1818

19+
region = var.region
20+
1921
name = local.resource_group_name
2022
description = var.resource_group.description
2123

modules/config-recorder/variables.tf

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
variable "region" {
2+
description = "(Optional) The region in which to create the module resources. If not provided, the module resources will be created in the provider's configured region."
3+
type = string
4+
default = null
5+
nullable = true
6+
}
7+
18
variable "name" {
29
description = "(Optional) The name of the recorder. Defaults to `default`. Changing it recreates the resource."
310
type = string
@@ -269,9 +276,6 @@ variable "module_tags_enabled" {
269276
# Resource Group
270277
###################################################
271278

272-
273-
274-
275279
variable "resource_group" {
276280
description = <<EOF
277281
(Optional) A configurations of Resource Group for this module. `resource_group` as defined below.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.6"
2+
required_version = ">= 1.12"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.39"
7+
version = ">= 6.12"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)