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]
}
availability_zone_groups = {}
}
ERRO[0072] Module has finished with an error: 1 error occurred:
INFO[0072]
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
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.
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
resource "aws_ebs_default_kms_key" "this" {
aws_ebs_encryption_by_default.this will be created
resource "aws_ebs_encryption_by_default" "this" {
aws_ec2_image_block_public_access.this will be created
resource "aws_ec2_image_block_public_access" "this" {
aws_ec2_instance_metadata_defaults.this[0] will be created
resource "aws_ec2_instance_metadata_defaults" "this" {
aws_ec2_serial_console_access.this will be created
resource "aws_ec2_serial_console_access" "this" {
aws_resourceexplorer2_index.this[0] will be created
resource "aws_resourceexplorer2_index" "this" {
module.resource_group[0].aws_resourcegroups_group.this will be created
resource "aws_resourcegroups_group" "this" {
arn = (known after apply)
description = "Managed by Terraform."
id = (known after apply)
name = "terraform-aws-account...ap-southeast-4"
tags = {
tags_all = {
resource_query {
Plan: 7 to add, 0 to change, 0 to destroy.
Changes to Outputs:
vpc = {
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
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