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

Added remove_current_attachment_association attribute to ec2_transit_gateway_route_table_association #31452

Conversation

Snappey
Copy link
Contributor

@Snappey Snappey commented May 17, 2023

Description

Allows for disassociating the currently linked Transit Gateway route table for the gateway attachment before associating our new route table by setting the remove_current_attachment_assoication attribute to true (defaults to false).

Currently if you attempt to create a new ec2_transit_gateway_route_table_association with a Gateway Attachment that is already attached to a route table the association resource will fail with Resource.AlreadyExists error code, as far as I can tell this can only be fixed by manually disassociating via console / API and rerunning to bring it into the state or by setting the default_route_table_association attribute to false on the Transit Gateway and manage each attachment manually to prevent automatic association which feels like a lot of overhead for handling edge cases.

I'm not sure if this is the best approach but was suggested as a solution in #16452 and was pretty straight forwards to implement and opt-in, if there is an alternative that is better suited I'm more than happy to take it on. Would very much like to see this solved to allow for easy updating of gateway attachment route tables.

At the moment it does not do any checks to see if the Route Table ID we're associating to is also the target and short circuit in that case, I'm not sure if there is any benefit in doing so? I'm leaning towards a no since each of the attributes are marked to force recreation.

Also I've added the field to the tests, but I'm not sure if that's all I need to do on that front or if any new acceptance tests need to be created for the situation where the attribute is set to true?

Example

resource "aws_ec2_transit_gateway_route_table_association" "example" {
  transit_gateway_attachment_id  = "tgw-attach-00000000"
  transit_gateway_route_table_id = "tgw-rtb-00000000"

  remove_current_attachment_association = true
}

Relations

Closes #16452

References

N/A

Output from Acceptance Testing

I've attempted to run the Acceptance Tests a couple of times and it kept blowing up my machine then crashing mid tests, leaving some dangling resource, if they could be ran for me that'd be much appreciated, thanks.

…gateway_route_table_association

Allows for disassociating the currently linked route table for the gateway attachment before associating our new route table.
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/S Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/transitgateway Issues and PRs that pertain to the transitgateway service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. labels May 17, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome @Snappey 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@Snappey Snappey marked this pull request as ready for review May 17, 2023 18:47
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels May 17, 2023
@aamcatamney
Copy link

Bump +1

@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Jun 7, 2023
@ewbankkit
Copy link
Contributor

@Snappey Thanks for the contribution 🎉 👏.
I renamed the new argument to replace_existing_association to better line up with some similar arguments we have on other resources.

@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jun 8, 2023
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccTransitGateway_serial/RouteTableAssociation' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccTransitGateway_serial/RouteTableAssociation -timeout 180m
=== RUN   TestAccTransitGateway_serial
=== PAUSE TestAccTransitGateway_serial
=== CONT  TestAccTransitGateway_serial
=== RUN   TestAccTransitGateway_serial/RouteTableAssociation
=== RUN   TestAccTransitGateway_serial/RouteTableAssociation/ReplaceExistingAssociation
=== RUN   TestAccTransitGateway_serial/RouteTableAssociation/basic
=== RUN   TestAccTransitGateway_serial/RouteTableAssociation/disappears
--- PASS: TestAccTransitGateway_serial (1334.62s)
    --- PASS: TestAccTransitGateway_serial/RouteTableAssociation (1334.62s)
        --- PASS: TestAccTransitGateway_serial/RouteTableAssociation/ReplaceExistingAssociation (420.73s)
        --- PASS: TestAccTransitGateway_serial/RouteTableAssociation/basic (438.45s)
        --- PASS: TestAccTransitGateway_serial/RouteTableAssociation/disappears (475.44s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	1340.164s

@ewbankkit ewbankkit merged commit cd32ed4 into hashicorp:main Jun 8, 2023
@github-actions github-actions bot added this to the v5.2.0 milestone Jun 8, 2023
@github-actions
Copy link

github-actions bot commented Jun 9, 2023

This functionality has been released in v5.2.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/transitgateway Issues and PRs that pertain to the transitgateway service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

error associating EC2 Transit Gateway Route Table : Resource.AlreadyAssociated
4 participants