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

aws_dx_gateway_association_proposal recreated #9209

Closed
saliceti opened this issue Jul 2, 2019 · 17 comments · Fixed by #12482
Closed

aws_dx_gateway_association_proposal recreated #9209

saliceti opened this issue Jul 2, 2019 · 17 comments · Fixed by #12482
Labels
bug Addresses a defect in current functionality. service/directconnect Issues and PRs that pertain to the directconnect service.
Milestone

Comments

@saliceti
Copy link

saliceti commented Jul 2, 2019

Terraform bug

It happens when associating a virtual private gateway with a direct connect gateway in a separate account (See AWS doc). There is a terraform resource for the proposal. But this resource is not permanent, so terraform will try to recreate it.

Terraform Version

  • terraform 0.11.10
  • terraform-provider-aws 2.12.0

Affected Resource(s)

  • aws_dx_gateway_association_proposal
  • aws_dx_gateway_association

Terraform Configuration Files

resource "aws_dx_gateway_association_proposal" "dcgw_association_proposal" {
  depends_on                  = ["aws_vpn_gateway_attachment.vpn_attachment"]
  dx_gateway_id               = "${local.dcgw_id}"
  dx_gateway_owner_account_id = "${local.shared_services_account_id}"
  associated_gateway_id       = "${aws_vpn_gateway.vpn_gw.id}"
}

resource "aws_dx_gateway_association" "dcgw_association" {
  provider = "aws.shared_services"

  proposal_id                         = "${aws_dx_gateway_association_proposal.dcgw_association_proposal.id}"
  dx_gateway_id                       = "${local.dcgw_id}"
  associated_gateway_owner_account_id = "${local.account_id}"

  timeouts {
    delete = "30m"
    create = "30m"
  }
}

Expected Behavior

  • Apply: create proposal, associate in other account, networks are connected
  • Any apply after that: No change

Actual Behavior

  • Apply: create proposal, associate in other account
  • Apply immediately: No change
  • Apply after a few days once the proposal has been removed by AWS: create proposal, force recreation of association, networks are disconnected for up to 20min -> DOWNTIME

Steps to Reproduce

  1. terraform apply
  2. Wait for a few days or delete the proposal (Example)
  3. terraform plan: shows creation of the proposal and recreation of the association

Important Factoids

Raised a support case with AWS to understand the behaviour. Here is the response:

I relayed the same question to the service team and they have informed me that the proposal will be available as long as the "accepter" has not accepted the proposal. Once the proposal is accepted, it will disappear after some time. There is no defined time duration as to how long the proposal is available after acceptance through CLI. As we use a distributed and eventual consistency model, I would highly recommend you to not use the time the proposal remains in the CLI output after acceptance to make any design, architectural, or application decisions.

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 2, 2019
@bflad bflad added bug Addresses a defect in current functionality. service/directconnect Issues and PRs that pertain to the directconnect service. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 2, 2019
@ewbankkit
Copy link
Contributor

A solution here may be to modify the behavior of the aws_dx_gateway_association.proposal_id attribute so that on update if the new proposal was for the same Direct Connect gateway/associated gateway pair that no new association is created.
Maybe even allow the new value to be empty on update.
I think this could be achieved via a CustomizeDiffFunc.

@ewbankkit
Copy link
Contributor

@saliceti How urgent is this to address? Thanks.

@saliceti
Copy link
Author

We stopped using this resource and replaced it with boto code triggered by a provisionner.
It’s ugly but it works. So it’s not urgent anymore. Thanks.

@saliceti
Copy link
Author

To be honest this resource is not useful in the current state. If no plan is made to fix it soon it should be removed in the meantime.

@josephschadlick
Copy link

I've just run into this problem as well. I tend to agree with @saliceti - this resource should be fixed or removed, as this bug is not obvious and has the potential to cause outages.

@acarrasquillo
Copy link

Just ran into this issue too. Terraform created a new proposal and detached the VPC from the Direct Connect Gateway.

@SureshGoli123
Copy link

I have also ran into this issue. It should be fixed as soon as possible. Anywork around for now?

@huddy
Copy link

huddy commented Feb 17, 2020

We're also seeing this issue, we would prefer to avoid any messy work arounds obviously :)

blckct added a commit to blckct/terraform-provider-aws that referenced this issue Mar 3, 2020
ewbankkit pushed a commit to ewbankkit/terraform-provider-aws that referenced this issue Mar 5, 2020
@ewbankkit
Copy link
Contributor

ewbankkit commented Mar 19, 2020

Looking at this some more the possibility I see is to change ForceNew to false for the proposal_id attribute of the aws_dx_gateway_association.
This would mean that once a DX Gateway Association has been created, any change to the proposal_id would not trigger a recreation of the resource.

@sporokh
Copy link

sporokh commented Mar 31, 2020

Same issue for me using the latest terraform version 0.12.24. Basically aws_dx_gateway_association_proposal removed by AWS itself within 1-3 days, so the actual id of the resource is no longer in AWS, which forces new creation.
Lifecycle ignore_changes is not helping either. The resource is literally unusable. Any estimates on the fix?

@hhh0505
Copy link

hhh0505 commented Apr 1, 2020

I'm experiencing the same issue with terraform version 0.12.24. We need a fix ASAP, this is causing downtime if we need to add or change any resoucres.

@piyat
Copy link

piyat commented Jun 15, 2020

Encountered this too, going to omit until fixed.

@mattparkes
Copy link

Does anyone know if this has been fixed? It's still causing us a lot of grief.

@hhh0505
Copy link

hhh0505 commented Jan 11, 2021

Does anyone know if this has been fixed? It's still causing us a lot of grief.

Nope the PR is still open, I've been waiting months for this to get fixed

@gerl1ng
Copy link

gerl1ng commented Jan 28, 2021

I worked around the proposal recreation like this for now. It's not nice but it's at least usable.

variable "proposal_id" {
  default = ""
}

resource "aws_dx_gateway_association_proposal" "proposal" {
  count    = var.proposal_id == "" ? 1 : 0
  provider = aws.vgw

  dx_gateway_id               = var.dx_gateway_id
  dx_gateway_owner_account_id = data.aws_caller_identity.nethub.account_id
  associated_gateway_id       = aws_vpn_gateway.vgw.id
}

resource "aws_dx_gateway_association" "association" {
  provider = aws.nethub

  dx_gateway_id                       = var.dx_gateway_id
  associated_gateway_owner_account_id = data.aws_caller_identity.vgw.account_id

  # IMPORTANT: Set the proposal_id variable in the module call after the initial assocation was created.
  # Otherwise the connection will be recreated with a connectivity downtime of 30 minutes.
  proposal_id = var.proposal_id == "" ? aws_dx_gateway_association_proposal.proposal[0].id : var.proposal_id
  # Another safety-net implemented so the connectivity will not be lost by a recreation of the association. Overwrite to false if deletion is intendet
  lifecycle {
    prevent_destroy = true
  }
}

output "proposal_id" {
  value = var.proposal_id == "" ? aws_dx_gateway_association_proposal.proposal[0].id : var.proposal_id
}

After the initial association is created one needs to update the variable proposal_id to the output value. The proposal will not be recreated in the future and the association is not recreated either.

I did not test this yet with a new association, ony with associations that the proposal_id has been deleted by AWS.

ewbankkit pushed a commit to ewbankkit/terraform-provider-aws that referenced this issue Feb 12, 2021
ewbankkit pushed a commit to ewbankkit/terraform-provider-aws that referenced this issue Feb 12, 2021
@github-actions github-actions bot added this to the v3.29.0 milestone Feb 17, 2021
@ghost
Copy link

ghost commented Feb 19, 2021

This has been released in version 3.29.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 for triage. Thanks!

@ghost
Copy link

ghost commented Mar 20, 2021

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/directconnect Issues and PRs that pertain to the directconnect service.
Projects
None yet