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_route53_record can overwrite existing record not in state #4493

Closed
asafpelegcodes opened this issue May 9, 2018 · 4 comments
Closed
Labels
bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service.

Comments

@asafpelegcodes
Copy link

Running...
Terraform v0.11.7
provider.aws v1.17.0

I have a route53 record that was created manually through the AWS console. Let's say it's for a record with the name something.example.com
Assume the record is an A record with an alias to a load balanacer...

If I apply the following terraform configuration bellow the A record is overwritten. There is no notice about this in the plan about destroying anything or an error saying the record already exists...

provider "aws" {
  version = "~> 1.7"
  region  = "us-east-1"
}

# A RECORD ALIAS internal-factpages-engine-wip-1851635644.us-east-1.elb.amazonaws.com.
resource "aws_route53_record" "www" {
  zone_id = "Z123456789XX"
  name    = "something.example.com"
  type    = "A"

  alias {
    name                   = "internal-something-example-111111111.us-east-1.elb.amazonaws.com"
    zone_id                = "Z123456789XY"
    evaluate_target_health = false
  }
}

My assumption is that terraform should throw an error from AWS that there is a record uniqueness constraint being violated by attempting to create a record with an identical name. It should not silently overwrite the existing record.

@bflad bflad added bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service. labels May 9, 2018
@bflad
Copy link
Contributor

bflad commented May 9, 2018

Hi @asafpelegcodes 👋 Sorry you ran into unexpected behavior here. I'm going to repost my closing comment from #1094 (comment) and close this out as hopefully it answers any questions regarding this -- basically you can use the allow_overwrite flag today and the behavior will be fixed by default in the next major version of the AWS provider.


Contrary to how almost all Terraform resources work, the aws_route53_record resource was incorrectly using the UPSERT action in the Route53 ResourceRecordSet changeset during Terraform resource creation instead of the CREATE action. Its been like this since it was created a few years ago.

In #2926, released in v1.10.0 of the AWS provider, we introduced the allow_override attribute that will allow you to set false that will switch the creation action to CREATE and properly error when you try to overwrite an existing record. It defaults to true currently to not break backwards compatibility.

In the next major version of the AWS provider, we plan to switch the attribute so it defaults to false but potentially will still allow true for the corner cases where UPSERT on creation is desired.

@bflad bflad closed this as completed May 9, 2018
@vivekgkwd
Copy link

allow_overwrite is deprecated , how can I UPSERT route53 records now?

@ruanxuyi
Copy link

allow_overwrite is deprecated , how can I UPSERT route53 records now?

according to https://www.terraform.io/docs/providers/aws/r/route53_record.html i believe allow_overwrite option is still valid at this point. i have no issue of using allow_overwrite option.

@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. service/route53 Issues and PRs that pertain to the route53 service.
Projects
None yet
Development

No branches or pull requests

4 participants