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

dx_gateway association import throws error #8956

Closed
aacecandev opened this issue Jun 12, 2019 · 5 comments · Fixed by #8970
Closed

dx_gateway association import throws error #8956

aacecandev opened this issue Jun 12, 2019 · 5 comments · Fixed by #8970
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/directconnect Issues and PRs that pertain to the directconnect service.
Milestone

Comments

@aacecandev
Copy link

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 "me too" comments, 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

Terraform Version

Terraform v0.11.14

The detected bug behaves different depending on the aws provider version

  • provider.aws v2.11.0 -> works OK
  • provider.aws v2.12.0 to v2.14.0 -> BUG

Affected Resource(s)

  • aws_dx_gateway
  • aws_dx_gateway_association

Terraform Configuration Files

resource "aws_dx_connection" "my-conn" {
  name      = "conn-name"
  bandwidth = "1Gbps"
  location  = "location"

  tags = "${map(
      ...
  )}"
}

resource "aws_dx_gateway" "my-dx-gw" {
  name            = "dxg-name"
  amazon_side_asn = "64512"
}

resource "aws_dx_gateway_association" "my-dx-gw-association" {
  dx_gateway_id         = "${aws_dx_gateway.dxgw-control.id}"
  associated_gateway_id = "${data.terraform_remote_state.remote_state_vpc.vpc_private_gateway_id}"
}

Debug Output

Importing the resource and making a terraform plan later using v2.11.0 would throw the following result

https://gist.github.com/aacecandev/3c15b3848126bc4b09a2c5c0cff4fde2#file-planl

Also, using v2.<12-13-14>.0 and making the same operation would fail importing the existing resources (I think it is related to some concat doing bad it's job but I'm don't feel comfortable yet with GO)

https://gist.github.com/aacecandev/e314042e8915ab32b302d91e52d46edf

Expected Behavior

Terraform's AWS latetest provider version should import successfully the current existing dx_gateway infrastructure, so when doing a terrafom plan, anything should be marked to destroy

Actual Behavior

I can import sucessfully a dx_gateway_association using provider's v2.11.0, :

  • v2.11.0 -> aws_dx_gateway_association.dxgw-control
  • v2.14.0 ->

aws_dx_gateway.dxgw-control: Importing from ID "313449a8-7ef4-4018-b78a-47c7db25f359"...
aws_dx_gateway.dxgw-control: Import complete!
Imported aws_dx_gateway (ID: 313449a8-7ef4-4018-b78a-47c7db25f359)
Imported aws_dx_gateway_association (ID: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0248c762c28e26447)
Imported aws_dx_gateway_association (ID: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0e7f7af297281a5ab)
Imported aws_dx_gateway_association (ID: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0af34dba6dc9bbd1f)
aws_dx_gateway_association.dxgw-control-1: Refreshing state... (ID: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0e7f7af297281a5ab)
aws_dx_gateway_association.dxgw-control: Refreshing state... (ID: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0248c762c28e26447)
aws_dx_gateway_association.dxgw-control-2: Refreshing state... (ID: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0af34dba6dc9bbd1f)
aws_dx_gateway.dxgw-control: Refreshing state... (ID: 313449a8-7ef4-4018-b78a-47c7db25f359)

Error: aws_dx_gateway.dxgw-control (import id: 313449a8-7ef4-4018-b78a-47c7db25f359): 3 errors occurred:
* import aws_dx_gateway_association.dxgw-control-2 result: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0af34dba6dc9bbd1f: aws_dx_gateway_association.dxgw-control-2: error reading Direct Connect gateway association (ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0af34dba6dc9bbd1f): DirectConnectClientException: Association ID has an invalid format.
status code: 400, request id: 59c133da-8cf9-11e9-9323-cdbafefc00ac
* import aws_dx_gateway_association.dxgw-control result: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0248c762c28e26447: aws_dx_gateway_association.dxgw-control: error reading Direct Connect gateway association (ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0248c762c28e26447): DirectConnectClientException: Association ID has an invalid format.
status code: 400, request id: 59c15aeb-8cf9-11e9-9323-cdbafefc00ac
* import aws_dx_gateway_association.dxgw-control-1 result: ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0e7f7af297281a5ab: aws_dx_gateway_association.dxgw-control-1: error reading Direct Connect gateway association (ga-313449a8-7ef4-4018-b78a-47c7db25f359vgw-0e7f7af297281a5ab): DirectConnectClientException: Association ID has an invalid format.
status code: 400, request id: 59c133d9-8cf9-11e9-9323-cdbafefc00ac

Steps to Reproduce

  1. log to your AWS account -> aws-vault
  2. terraform init
  3. terraform import dx_gateway
  4. terraform plan
@ewbankkit
Copy link
Contributor

@aacecandev Sorry about the problem here.
It looks like I missed updating the resource import code in aws_dx_gateway that also imports associations when implementing #8528.
The symptom (error message) is similar to #8773 and the solution should be similar.
As a workaround you should be able to pin the AWS provider version to 2.11.0 as it looks like your associated gateway is a VGW.

@ewbankkit
Copy link
Contributor

The acceptance tests for aws_dx_gateway show the error:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsDxGateway_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAwsDxGateway_ -timeout 120m
=== RUN   TestAccAwsDxGateway_importBasic
=== PAUSE TestAccAwsDxGateway_importBasic
=== RUN   TestAccAwsDxGateway_importComplex
=== PAUSE TestAccAwsDxGateway_importComplex
=== RUN   TestAccAwsDxGateway_basic
=== PAUSE TestAccAwsDxGateway_basic
=== CONT  TestAccAwsDxGateway_importBasic
=== CONT  TestAccAwsDxGateway_basic
=== CONT  TestAccAwsDxGateway_importComplex
--- PASS: TestAccAwsDxGateway_basic (39.35s)
--- PASS: TestAccAwsDxGateway_importBasic (42.12s)
--- FAIL: TestAccAwsDxGateway_importComplex (1408.90s)
    testing.go:568: Step 1 error: 2 problems:
        
        - error reading Direct Connect gateway association (ga-70e3def4-f9ae-41b5-81b0-add441cfeabavgw-00390591958ada8c6): DirectConnectClientException: Association ID  has an invalid format.
                status code: 400, request id: c471cce1-8d3b-11e9-818c-29febb0b2708
        - error reading Direct Connect gateway association (ga-70e3def4-f9ae-41b5-81b0-add441cfeabavgw-0fd030f037255fd03): DirectConnectClientException: Association ID  has an invalid format.
                status code: 400, request id: c4715881-8d3b-11e9-afd5-038f18e4c385
FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       1408.986s
make: *** [testacc] Error 1

@bflad bflad added bug Addresses a defect in current functionality. service/directconnect Issues and PRs that pertain to the directconnect service. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. labels Jun 13, 2019
@bflad bflad added this to the v2.16.0 milestone Jun 13, 2019
@bflad
Copy link
Contributor

bflad commented Jun 18, 2019

The fix for this regression has been merged and will release with version 2.16.0 of the Terraform AWS Provider, likely later this week.

@bflad
Copy link
Contributor

bflad commented Jun 20, 2019

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

@ghost
Copy link

ghost commented Nov 3, 2019

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 and limited conversation to collaborators Nov 3, 2019
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. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/directconnect Issues and PRs that pertain to the directconnect service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants