terraform-aws-transit-gateway icon indicating copy to clipboard operation
terraform-aws-transit-gateway copied to clipboard

Fix flickering when transit gateway description is not set

Open mattock opened this issue 2 years ago • 2 comments

what

This PR fixes flickering on every Terraform run when var.transit_gateway_description is unset.

The problem is caused by the leading space in the description: something that AWS APIs accept without erroring out or warning, but which gets removed or ignored. Hence Terraform tries to "fix" the situation on every run.

why

Without this change this happens on every Terraform run if var.transit_gateway_description is not defined:

Terraform will perform the following actions:                                                             

  # module.transit_gateway.aws_ec2_transit_gateway.default[0] will be updated in-place                    
  ~ resource "aws_ec2_transit_gateway" "default" {   
      ~ description                     = "Transit Gateway" -> " Transit Gateway"                         
        id                              = "tgw-07987d7d0a101968b"                                         
        tags                            = {}         
        # (11 unchanged attributes hidden)           
    }                                                

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

With this change applied things work as expected:

No changes. Your infrastructure matches the configuration.

mattock avatar Jan 17 '23 12:01 mattock

The solution is to provide at least one of the context null label inputs such as name

A better fix for people who do not want to use name would be to use a join(" ", compact([module.this.id, "Transit Gateway"])). The description should probably be its own exposed input with the same default value Transit Gateway as it is today

nitrocode avatar Jan 17 '23 14:01 nitrocode

Thanks @mattock for creating this pull request!

A maintainer will review your changes shortly. Please don't be discouraged if it takes a while.

While you wait, make sure to review our contributor guidelines.

[!TIP]

Need help or want to ask for a PR review to be expedited?

Join us on Slack in the #pr-reviews channel.

mergify[bot] avatar Mar 09 '24 04:03 mergify[bot]