hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.75k stars 9.11k forks source link

Store the state of Transit Gateway VPC attachment #18412

Closed mshakhmaykin closed 8 months ago

mshakhmaykin commented 3 years ago

Community Note

Description

Today, both resource and datasource aws_ec2_transit_gateway_vpc_attachment do not keep the track of the actual state of the attachment. Usually, once attachment is created, it is considered active right away, but there is a possible scenario when it is not yet available, but rather in "pendingAcceptance" state, and therefore cannot be used until accepted by Transit GW owner in the remote AWS account. Once accepted, the state changes to "available".

Because Terraform cannot distinguish between these two attachment states, it wouldn't prevent the attempt of creating routes using this attachment, and the apply would fail by timeout eventually.

The new feature would allow user to use new attribute "attachment_state" in any conditional logic and skip route creation.

New or Affected Resource(s)

Potential Terraform Configuration

data "aws_ec2_transit_gateway" "example" {
  filter {
    name   = "owner_id"
    values = ["1234567890"]
  }
}

resource "aws_ec2_transit_gateway_vpc_attachment" "example" {
  subnet_ids         = ["subnet-abc123456", "subnet-xyz123456"]
  transit_gateway_id = data.aws_ec2_transit_gateway.example.id
  vpc_id             = "vpc-abcdef123456"
}

resource "aws_route" "example" {
  count                  = aws_ec2_transit_gateway_vpc_attachment.example.state == "available" ? 1 : 0
  route_table_id         = "rtb-abc123456"
  destination_cidr_block = "10.0.0.0/24"
  transit_gateway_id     = aws_ec2_transit_gateway_vpc_attachment.example.transit_gateway_id
}

References

github-actions[bot] commented 9 months ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 7 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.