aws_ec2_transit_gateway_peering_attachment wants to replace if no `options` block is supplied
Terraform and AWS Provider Version
OpenTofu v1.12.6
on linux_amd64
+ provider registry.opentofu.org/hashicorp/aws v6.66.0Affected Resource(s) or Data Source(s)
aws_ec2_transit_gateway_peering_attachment
Expected Behavior
I should be able to leave off the optional options block without terraform wanting to replace (destroy and create) the resource.
Actual Behavior
I created a aws_ec2_transit_gateway_peering_attachment, and didn't specify the optional options block.
Today, terraform started saying it needed to replace the resource, because in AWS it had an options block, but the configuration didn't.
Relevant Error/Panic Output
n/a
Sample Terraform Configuration
Click to expand configurationresource "aws_ec2_transit_gateway_peering_attachment" "main" {
region = var.region
peer_account_id = var.dest.owner_id
peer_region = var.peer_region
peer_transit_gateway_id = var.dest.id
transit_gateway_id = var.src.id
tags = {
Name = var.attachment_name
}
}Steps to Reproduce
- Apply the above config (or use an existing resource with the options block)
- Run a plan (possibly it only happens in some regions, I'm not sure)
Debug Logging
GenAI / LLM Assisted Development
n/a
Important Facts and References
I am highly suspicious that this started happening because AWS started returning an empty Options object in the API responses (at least in some regions), whereas previously the Options were either null, or missing in that case.
The provider should probably treat an empty options as equivalent to no options.
This was also mentioned in #41360, but this seems like it is a different (although possibly related) issue.
Workaround
It is possible to workaround this by adding an ignore_changes for the options.
lifecycle {
ignore_changes = [options]
}Would you like to implement a fix?
No response
Source: hashicorp/terraform-provider-aws