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

Renaming Route53 resource throws error #15786

Closed
Deku-shrub opened this issue Oct 22, 2020 · 2 comments
Closed

Renaming Route53 resource throws error #15786

Deku-shrub opened this issue Oct 22, 2020 · 2 comments
Labels
service/route53 Issues and PRs that pertain to the route53 service.

Comments

@Deku-shrub
Copy link
Contributor

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 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

12.26

Affected Resource(s)

  • aws_route53

Terraform Configuration Files

resource "aws_route53_record" "test_dns_record" {
  zone_id = "XXXXXXXXXXXX"
  name = "test"
  type = "A"
  ttl = "300"
  records = ["8.8.8.8"]
}

then change to e.g.

resource "aws_route53_record" "test_changed_name_dns_record" {
  zone_id = "XXXXXXXXXXXX"
  name = "test"
  type = "A"
  ttl = "300"
  records = ["8.8.8.8"]
}

Debug Output

  # aws_route53_record.test1_dns_record will be created
  + resource "aws_route53_record" "test1_dns_record" {
      + allow_overwrite = (known after apply)
      + fqdn            = (known after apply)
      + id              = (known after apply)
      + name            = "test"
      + records         = [
          + "8.8.8.8",
        ]
      + ttl             = 300
      + type            = "A"
      + zone_id         = "XXXXXXXXXXXX"
    }
  # aws_route53_record.test_dns_record will be destroyed
  - resource "aws_route53_record" "test_dns_record" {
      - fqdn    = "test.domain.fqdm" -> null
      - id      = "XXXXXXXXXXXX" -> null
      - name    = "test" -> null
      - records = [
          - "8.8.8.8",
        ] -> null
      - ttl     = 300 -> null
      - type    = "A" -> null
      - zone_id = "XXXXXXXXXXXX" -> null
    }
Plan: 1 to add, 0 to change, 1 to destroy.
Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.
  Enter a value: yes
aws_route53_record.test_dns_record: Destroying... [id=XXXXXXXXXXXX_test_A]
aws_route53_record.test1_dns_record: Creating...
aws_route53_record.test_dns_record: Still destroying... [id=XXXXXXXXXXXX_test_A, 10s elapsed]
aws_route53_record.test_dns_record: Still destroying... [id=XXXXXXXXXXXX_test_A, 20s elapsed]
aws_route53_record.test_dns_record: Still destroying... [id=XXXXXXXXXXXX_test_A, 30s elapsed]
aws_route53_record.test_dns_record: Destruction complete after 32s
Error: [ERR]: Error building changeset: InvalidChangeBatch: [Tried to create resource record set [name='test.domain.fqdm', type='A'] but it already exists]
        status code: 400, request id: 2788df36-5022-4b9d-9984-dc68c2e1e64c```

### Expected Behavior

Resource recreated

### Actual Behavior

Resource destroyed, not recreated

### Steps to Reproduce

Create aws_route53_record resource, apply
Rename that aws_route53_record's name, apply
@ghost ghost added the service/route53 Issues and PRs that pertain to the route53 service. label Oct 22, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 22, 2020
@ewbankkit
Copy link
Contributor

ewbankkit commented Oct 22, 2020

@Deku-shrub Thanks for raising this issue.
As the new resource has a new name, Terraform will treat the old and new resources as being independent and will act on them in parallel, destroying the old R53 record and creating the new in parallel and effectively a race condition is being hit.
See https://discuss.hashicorp.com/t/destroy-before-create/3980 for some details.
The way I would approach such a resource renaming would be to use the terraform state mv CLI command to rename the resource in state and then rename in the HCL code.

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Oct 22, 2020
@ghost
Copy link

ghost commented Nov 21, 2020

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 Nov 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/route53 Issues and PRs that pertain to the route53 service.
Projects
None yet
Development

No branches or pull requests

2 participants