tedilabs / terraform-aws-account

🌳 A sustainable Terraform Package which creates Account & IAM resources on AWS
https://registry.terraform.io/modules/tedilabs/account/aws
Apache License 2.0
45 stars 10 forks source link

[BUG]: ap-southeast-4 region missing from region module locals #118

Open tac-ap opened 2 weeks ago

tac-ap commented 2 weeks ago

Is there an existing issue for this?

Description of the bug

When attempting to assign a kms key as the default ebs encryption key in the ap-southeast-4 region, I get the following error:

Error: Invalid index

on outputs.tf line 8, in output "code": 8: value = local.region_codes[data.aws_region.this.id] ├──────────────── │ data.aws_region.this.id is "ap-southeast-4" │ local.region_codes is object with 25 attributes

it appears to be due to the referenced locals not including the region provided: locals { region = data.aws_region.this.name region_codes = { "us-east-1" = "use1" "us-east-2" = "use2" "us-west-1" = "usw1" "us-west-2" = "usw2" "af-south-1" = "afs1" "ap-east-1" = "ape1" "ap-northeast-1" = "apne1" "ap-northeast-2" = "apne2" "ap-northeast-3" = "apne3" "ap-southeast-1" = "apse1" "ap-southeast-2" = "apse2" "ap-southeast-3" = "apse3" "ap-south-1" = "aps1" "ca-central-1" = "cac1" "eu-central-1" = "euc1" "eu-west-1" = "euw1" "eu-west-2" = "euw2" "eu-west-3" = "euw3" "eu-north-1" = "eun1" "eu-south-1" = "eus1" "me-south-1" = "mes1" "sa-east-1" = "sae1" "cn-north-1" = "cn1" "us-gov-west-1" = "usgw1" "us-gov-east-1" = "usge1" } }

the output "code" then fails due to the current region not being included in the locals.

output "code" { description = "The short code of the current region." value = local.region_codes[data.aws_region.this.id] }

Steps To Reproduce

Using terragrunt:

terraform { source = "tfr:///tedilabs/account/aws//modules/region?version=0.30.4" }

inputs = { ebs_default_encryption = { enabled = true kms_key = "" } }

terragrunt run-all plan --terragrunt-non-interactive

data.aws_region.this: Reading... data.aws_region.this: Read complete after 0s [id=ap-southeast-4]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

Terraform planned the following actions, but then encountered a problem:

aws_ebs_default_kms_key.this[0] will be created

Plan: 7 to add, 0 to change, 0 to destroy.

Changes to Outputs:

The given key does not identify an element in this collection value.

We have two deployment regions (ap-southeast-2 and ap-southeast-4). The ap-southeast-2 region deployments complete successfully.

Which version of the app are you using?

1.0.0

github-actions[bot] commented 2 weeks ago

:wave: Welcome! Looks like this is your first issue.

Hey, thanks for your contribution! Please give us a bit of time to review it. 😄

Be sure to follow the issue template!