Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make aws_ec2_transit_gateway_vpc_attachment gracefully handle TGW without default route tables #19279

Open
dmrzzz opened this issue May 7, 2021 · 2 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@dmrzzz
Copy link

dmrzzz commented May 7, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

This is a feature request to implement what @ewbankkit suggested in #13512 (comment)

We probably should change the code so that transit_gateway_default_route_table_propagation and transit_gateway_default_route_table_association have no effect if the transit gateway has no equivalent default route table.

New or Affected Resource(s)

  • aws_ec2_transit_gateway_vpc_attachment

Potential Terraform Configuration

provider "aws" {
  region = "us-west-2"
}

resource "aws_ec2_transit_gateway" "tgw" {
  auto_accept_shared_attachments  = "enable"
  default_route_table_association = "disable"
  default_route_table_propagation = "disable"
}

resource "aws_ec2_transit_gateway_vpc_attachment" "tgw_attach" {
  transit_gateway_id = aws_ec2_transit_gateway.tgw.id
  vpc_id             = aws_vpc.vpc.id
  subnet_ids         = [aws_subnet.subnet.id]

  # wish I didn't need these
  #transit_gateway_default_route_table_association = false
  #transit_gateway_default_route_table_propagation = false
}

resource "aws_vpc" "vpc" {
  cidr_block = "192.168.0.0/16"
}

resource "aws_subnet" "subnet" {
  vpc_id     = aws_vpc.vpc.id
  cidr_block = "192.168.0.0/24"
}

Status Quo

$ terraform -version
Terraform v0.15.1
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.39.0

$ terraform apply -auto-approve
aws_ec2_transit_gateway.tgw: Creating...
aws_vpc.vpc: Creating...
aws_vpc.vpc: Creation complete after 3s [id=vpc-0929d0671d5f6092e]
aws_subnet.subnet: Creating...
aws_subnet.subnet: Creation complete after 2s [id=subnet-0109f5695d9c6c1d9]
aws_ec2_transit_gateway.tgw: Still creating... [10s elapsed]
aws_ec2_transit_gateway.tgw: Still creating... [20s elapsed]
aws_ec2_transit_gateway.tgw: Still creating... [30s elapsed]
aws_ec2_transit_gateway.tgw: Creation complete after 36s [id=tgw-0267f80c7549d3b01]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Creating...
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [10s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [20s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [30s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [40s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [50s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [1m0s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [1m10s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [1m20s elapsed]
aws_ec2_transit_gateway_vpc_attachment.tgw_attach: Still creating... [1m30s elapsed]
╷
│ Error: error updating EC2 Transit Gateway Attachment (tgw-attach-06566e808ef576afc) Route Table () association: error associating EC2 Transit Gateway Route Table () association (tgw-attach-06566e808ef576afc): MissingParameter: Missing required parameter in request: TransitGatewayRouteTableId.
│ 	status code: 400, request id: ad0505de-e1aa-42d7-843e-594485c69040
│ 
│   with aws_ec2_transit_gateway_vpc_attachment.tgw_attach,
│   on main.tf line 11, in resource "aws_ec2_transit_gateway_vpc_attachment" "tgw_attach":
│   11: resource "aws_ec2_transit_gateway_vpc_attachment" "tgw_attach" {
│ 
╵

It works fine (for an attachment in the same AWS account as the TGW) if I explicitly specify

  transit_gateway_default_route_table_association = false
  transit_gateway_default_route_table_propagation = false

but this is not DRY, and also contrasts poorly with the need to avoid specifying those same arguments when creating an attachment from a different AWS account (see #8383).

It would be much nicer for omitting the optional arguments to elicit reasonable default behavior in all cases.

References

@dmrzzz dmrzzz added the enhancement Requests to existing resources that expand the functionality or scope. label May 7, 2021
@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label May 7, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 7, 2021
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 4, 2021
@github-actions
Copy link

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 github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Sep 21, 2023
@dmrzzz
Copy link
Author

dmrzzz commented Sep 21, 2023

Commenting to un-stale-ify.

@github-actions github-actions bot removed the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

2 participants