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

Terraform import aws_route53_record fails if identifier has an underscore #16213

Closed
ghost opened this issue Nov 16, 2020 · 5 comments · Fixed by #21556
Closed

Terraform import aws_route53_record fails if identifier has an underscore #16213

ghost opened this issue Nov 16, 2020 · 5 comments · Fixed by #21556
Assignees
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/route53 Issues and PRs that pertain to the route53 service.
Milestone

Comments

@ghost
Copy link

ghost commented Nov 16, 2020

This issue was originally opened by @vonschnappi as hashicorp/terraform#26930. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.13.5

Affected Resource

aws_route53_record

Terraform Configuration Files

resource "aws_route53_record" "tf_record_company_com_CNAME" {
    zone_id = "XXXXXXXXXXX"
    name    = "record.company.com."
    type    = "CNAME"
    ttl     = "300"
    records = ["record.company.com"]
    identifier = "id_01"
}

Expected Behavior

Terraform should be able to import route53 records whose identifier contains an underscore, for example id_01.

Actual Behavior

Terraform exits with an error:

aws_route53_record.tf_record_company__com_CNAME: Importing from ID "XXXXXXXXXXX_record.company.com_CNAME_id_01"...
aws_route53_record.tf_record_company__com_CNAME: Import prepared!
  Prepared aws_route53_record for import
aws_route53_record.tf_record_company_com_CNAME: Refreshing state... [id=XXXXXXXXXXX_recrord.company.com_CNAME_id_01]

Error: InvalidInput: 1 validation error detected: Value 'id' at 'startRecordType' failed to satisfy constraint: Member must 
satisfy enum value set: [AAAA, A, CAA, NS, SOA, SPF, MX, PTR, CNAME, DS, TXT, SRV, NAPTR]
        status code: 400, request id: XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX

Steps to Reproduce

Please list the full steps required to reproduce the issue, for example:

  1. Create a simple route53 record of type A with a record id that has an underscore, e.g. id_01.
  2. Create a resource block to represent this route53 record inside a main.tf config file.
  3. Run terraform init.
  4. Run terraform import aws_route53_record.tf_record_company_com_A XXXXXXXXXXX_ record.company.com_A_id_01.

References

It seems that this issue has already been raised and solved

@ghost ghost added bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service. labels Nov 16, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 16, 2020
@gdavison gdavison added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 17, 2020
@crawforde
Copy link

Any movement on this issue? I need to import 600+ DNS records and this problem is really grinding things to a halt.

@jzakrzeski
Copy link

jzakrzeski commented Sep 3, 2021

I have run into this same problem, but it's weird.

ZXXXXXXXXXX__9d9fd8s98df989d8fsd_A imports fine, the name has a leading underscore.
ZXXXXXXXXXX_dfhdiucdiusdiufyudysfd._domainkey_TXT will fail as it tries to parse domainkey as the record type instead of part of the name.

@jferris
Copy link

jferris commented Sep 5, 2021

If you downgrade to version 3.56 of the AWS provider, imports with underscores will complete successfully. After importing, you can upgrade the provider again without issue. It looks like the regression was introduced in #13453.

terraform {
  required_providers {
    aws = { version = "3.56" }
  }
}
% terraform import 'module.domain_identity.aws_route53_record.dkim[0]' 'Zxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx._domainkey.xxxxxxxxxxx.com_CNAME'

Acquiring state lock. This may take a few moments...
module.domain_identity.aws_route53_record.dkim[0]: Importing from ID "Zxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx._domainkey.xxxxxxxxxxx.com_CNAME"...
module.domain_identity.aws_route53_record.dkim[0]: Import prepared!
  Prepared aws_route53_record for import
module.domain_identity.aws_route53_record.dkim[0]: Refreshing state... [id=Zxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx._domainkey.xxxxxxxxxxx.com_CNAME]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Releasing state lock. This may take a few moments...

@github-actions
Copy link

This functionality has been released in v3.72.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 issue 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 similar to this, 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 May 19, 2022
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/route53 Issues and PRs that pertain to the route53 service.
Projects
None yet
4 participants