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

resource aws_dx_gateway_association timing out #14328

Open devikadesai opened 4 years ago

devikadesai commented 4 years ago

While creating a cross-account association, I created an aws_dx_gateway_association_proposal resource in the AWS account and then to accept the proposal in the AWS account that owns the Direct Connect Gateway, I was creating an aws_dx_gateway_association resource with the proposal_id attributes.

I noticed, it wasn't able to accept association till 45 minutes and timed out

aws_dx_gateway_association.accept_dx_gateway_proposal[0]: Still creating... [42m20s elapsed] aws_dx_gateway_association.accept_dx_gateway_proposal[0]: Still creating... [42m30s elapsed] aws_dx_gateway_association.accept_dx_gateway_proposal[0]: Still creating... [42m40s elapsed]

Error: error waiting for Direct Connect gateway association to become available: timeout while waiting for state to become 'associated' (last state: 'associating', timeout: 45m0s)

Then i retry my same terraform code - got another error in second run

Error: error accepting Direct Connect gateway association proposal: DirectConnectClientException: Direct Connect Gateway Association Proposal has been accepted!

It says the proposal has been accepted, but in the first error "waiting for state to become 'associated' " then how come it accepted.

it looks like it is getting accepted .. but somehow the status is not changing till 45 mins(for the first run) thats it has accepted.. so in the next run it fails with - error: Direct Connect Gateway Association Proposal -- has been accepted already !!

I changed my (aws) provider: version to 2.59.0 and everything ran fine but not for version 2.69.0

Is it a known issue? how can i workaround this??

ljluestc commented 11 months ago

resource "aws_dx_gateway_association" "accept_dx_gateway_proposal" {
  # Your other attributes here

  count = 10  # Set the number of retries
  depends_on = [aws_dx_gateway_association_proposal.create_proposal]  # Ensure it depends on the proposal resource

  provisioner "local-exec" {
    command = "echo 'Waiting for DX gateway association to become associated'"
  }

  lifecycle {
    create_before_destroy = true
  }
}

# Delay between retries
resource "null_resource" "delay" {
  count = 9  # Number of retries minus 1
  triggers = {
    # Wait for 5 minutes before retrying (adjust as needed)
    wait_for = "${timestamp() + 300}"
  }

  provisioner "local-exec" {
    command = "echo 'Waiting for retry...'"
  }
}