#terraform (2024-12)
Discussions related to Terraform or Terraform Modules
Archive: https://archive.sweetops.com/terraform/
2024-12-01
Not sure which channel to post this. If this isn’t correct spot, just let me know and I’ll move it.
When disabling a transit gateway by setting enabled: false
in hub.yaml
and spoke.yaml
- if the tgw already exists, we’re seeing the following error:
│ Error: stack name pattern '{tenant}-{environment}-{stage}' includes '{environment}', but environment is not provided
│
│ with module.vpc["plat--dev-vpc"].data.utils_component_config.config[0],
│ on .terraform/modules/vpc/modules/remote-state/main.tf line 1, in data "utils_component_config" "config":
│ 1: data "utils_component_config" "config" {
If we trace this back to components/terraform/tgw/[hub/spoke]/.terraform/modules/vpc/modules/remote-state/main.tf
Then to [context-always.tf](http://context-always.tf)
module "always" {
source = "cloudposse/label/null"
version = "0.25.0" # requires Terraform >= 0.13.0
enabled = true
namespace = var.namespace
tenant = var.tenant
environment = var.environment
stage = var.stage
name = var.name
delimiter = var.delimiter
attributes = var.attributes
tags = var.tags
additional_tag_map = var.additional_tag_map
label_order = var.label_order
regex_replace_chars = var.regex_replace_chars
id_length_limit = var.id_length_limit
label_key_case = var.label_key_case
label_value_case = var.label_value_case
descriptor_formats = var.descriptor_formats
labels_as_tags = var.labels_as_tags
context = var.context
}
var.environment
is not defined. However this is nested deep into CP terraform. Have you all seen this issue in the past?
I believe this is a bug with the component and with the remote-state call in particular: https://github.com/cloudposse-terraform-components/aws-tgw-spoke/blob/main/src/remote-state.tf#L12-L19
This module is missing enabled
handling. When not enabled, we don’t care about the remote reference, so we can bypass it like this:
https://github.com/cloudposse-terraform-components/aws-eks-cluster/blob/main/src/remote-state.tf#L19