Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
tac-ap opened this issue Jun 23, 2024 · 1 comment
Open
1 task done

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

tac-ap opened this issue Jun 23, 2024 · 1 comment
Labels
⚠️ bug Categorize bug reports.

Comments

@tac-ap
Copy link

tac-ap commented Jun 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

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:

  • create

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" {
    • id = (known after apply)
    • key_arn = "arn:aws:kms:ap-southeast-4:000000000000:key/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
      }

aws_ebs_encryption_by_default.this will be created

  • resource "aws_ebs_encryption_by_default" "this" {
    • enabled = true
    • id = (known after apply)
      }

aws_ec2_image_block_public_access.this will be created

  • resource "aws_ec2_image_block_public_access" "this" {
    • id = (known after apply)
    • state = "block-new-sharing"
      }

aws_ec2_instance_metadata_defaults.this[0] will be created

  • resource "aws_ec2_instance_metadata_defaults" "this" {
    • http_endpoint = "enabled"
    • http_put_response_hop_limit = 1
    • http_tokens = "required"
    • id = (known after apply)
    • instance_metadata_tags = "no-preference"
      }

aws_ec2_serial_console_access.this will be created

  • resource "aws_ec2_serial_console_access" "this" {
    • enabled = false
    • id = (known after apply)
      }

aws_resourceexplorer2_index.this[0] will be created

  • resource "aws_resourceexplorer2_index" "this" {
    • arn = (known after apply)
    • id = (known after apply)
    • tags = {
      • "Name" = "ap-southeast-4"
      • "module.terraform.io/full-name" = "terraform-aws-account/."
      • "module.terraform.io/instance" = "ap-southeast-4"
      • "module.terraform.io/name" = "."
      • "module.terraform.io/package" = "terraform-aws-account"
      • "module.terraform.io/version" = "0.30.4"
        }
    • tags_all = {
      • "Name" = "ap-southeast-4"
      • "module.terraform.io/full-name" = "terraform-aws-account/."
      • "module.terraform.io/instance" = "ap-southeast-4"
      • "module.terraform.io/name" = "."
      • "module.terraform.io/package" = "terraform-aws-account"
      • "module.terraform.io/version" = "0.30.4"
        }
    • type = "LOCAL"
      }

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 = {

      • "Name" = "terraform-aws-account...ap-southeast-4"
      • "module.terraform.io/full-name" = "terraform-aws-account/."
      • "module.terraform.io/instance" = "ap-southeast-4"
      • "module.terraform.io/name" = "."
      • "module.terraform.io/package" = "terraform-aws-account"
      • "module.terraform.io/version" = "0.30.4"
        }
    • tags_all = {

      • "Name" = "terraform-aws-account...ap-southeast-4"
      • "module.terraform.io/full-name" = "terraform-aws-account/."
      • "module.terraform.io/instance" = "ap-southeast-4"
      • "module.terraform.io/name" = "."
      • "module.terraform.io/package" = "terraform-aws-account"
      • "module.terraform.io/version" = "0.30.4"
        }
    • resource_query {

      • query = jsonencode(
        {
        + ResourceTypeFilters = [
        + "AWS::AllSupported",
        ]
        + TagFilters = [
        + {
        + Key = "module.terraform.io/full-name"
        + Values = [
        + "terraform-aws-account/.",
        ]
        },
        + {
        + Key = "module.terraform.io/instance"
        + Values = [
        + "ap-southeast-4",
        ]
        },
        + {
        + Key = "module.terraform.io/name"
        + Values = [
        + ".",
        ]
        },
        + {
        + Key = "module.terraform.io/package"
        + Values = [
        + "terraform-aws-account",
        ]
        },
        + {
        + Key = "module.terraform.io/version"
        + Values = [
        + "0.30.4",
        ]
        },
        ]
        }
        )
      • type = "TAG_FILTERS_1_0"
        }
        }

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

Changes to Outputs:

  • cloudwdatch = {
    • oam_sink = null
      }
  • description = "Asia Pacific (Melbourne)"
  • ebs = {
    • default_encryption = {
      • enabled = true
      • kms_key = "arn:aws:kms:ap-southeast-4:000000000000:key/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
        }
        }
  • ec2 = {
    • ami_public_access_enabled = false
    • instance_metadata_defaults = {
      • http_enabled = true
      • http_put_response_hop_limit = 1
      • http_token_required = true
      • instance_tags_enabled = null
        }
    • serial_console_enabled = false
      }
  • guardduty = {
    • delegated_administrator = null
      }
  • id = "ap-southeast-4"
  • inspector = {
    • delegated_administrator = null
      }
  • macie = {
    • delegated_administrator = null
      }
  • name = "ap-southeast-4"
  • resource_explorer = {
    • enabled = true
    • index_arn = (known after apply)
    • index_type = "LOCAL"
    • views = {}
      }
  • service_quotas = {}
  • vpc = {
    • 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.

Which version of the app are you using?

1.0.0

@tac-ap tac-ap added the ⚠️ bug Categorize bug reports. label Jun 23, 2024
Copy link

👋 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ bug Categorize bug reports.
Projects
None yet
Development

No branches or pull requests

1 participant