cloudposse / terraform-aws-transit-gateway

Terraform module to provision AWS Transit Gateway, AWS Resource Access Manager (AWS RAM) Resource, and share the Transit Gateway with the Organization or another AWS Account.
https://cloudposse.com/accelerate
Apache License 2.0
53 stars 47 forks source link

Fix flickering when transit gateway description is not set #32

Open mattock opened 1 year ago

mattock commented 1 year ago

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.
nitrocode commented 1 year ago

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

mergify[bot] commented 6 months ago

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.