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 recreates wildcard record every time #501

Closed
philk opened this issue Oct 22, 2014 · 6 comments
Closed

aws_route53_record recreates wildcard record every time #501

philk opened this issue Oct 22, 2014 · 6 comments
Assignees

Comments

@philk
Copy link
Contributor

philk commented Oct 22, 2014

I'm trying to create a wildcard record like this:

resource "aws_route53_record" "wildcard_domain_com" {
  zone_id = "${aws_route53_zone.domain_com.zone_id}"
  name = "*.domain.com"
  type = "A"
  ttl = "300"
  records = ["IP"]
}

Totally works fine and shows up in my .tfstate file. When I refresh (or attempt to apply with a refresh) the refresh deletes the entry from my .tfstate file causing the record to get recreated on apply (not a duplicate, just overwritten). Tried it with CNAME type and same result.

I would guess it has something to do with the API returning a strange response. aws route53 list-resource-record-sets returns \\052.domain.com instead of *.domain.com as expected:

{
            "ResourceRecords": [
                {
                    "Value": "domain.com"
                }
            ],
            "Type": "CNAME",
            "Name": "\\052.domain.com.",
            "TTL": 300
        }
@delitescere
Copy link

Unescaping problem. It's no surprise that the octal ASCII value for asterisk is 052.

@delitescere
Copy link

I was going to fix this myself, @mitchellh but alas I can't even build terraform from current master HEAD.

# github.com/hashicorp/terraform/builtin/providers/aws
builtin/providers/aws/resource_aws_autoscaling_group.go:244: g.LoadBalancerNames[0].LoadBalancerName undefined (type string has no field or method LoadBalancerName)
builtin/providers/aws/resource_aws_launch_configuration.go:156: lc.SecurityGroups[0].SecurityGroup undefined (type string has no field or method SecurityGroup)
builtin/providers/aws/structure.go:137: undefined: autoscaling.SecurityGroup
builtin/providers/aws/structure.go:146: undefined: autoscaling.AvailabilityZone
builtin/providers/aws/structure.go:155: undefined: autoscaling.LoadBalancerName
make: *** [updatedeps] Error 2

I was thinking of adding this to resource_aws_route53_record_test.go:

const testAccRoute53RecordConfig = `
resource "aws_route53_zone" "main" {
    name = "notexample.com"
}

resource "aws_route53_record" "default" {
    zone_id = "${aws_route53_zone.main.zone_id}"
    name = "www.notexample.com"
    type = "A"
    ttl = "30"
    records = ["127.0.0.1", "127.0.0.27"]
}

resource "aws_route53_record" "wildcard" {
    zone_id = "${aws_route53_zone.main.zone_id}"
    name = "*.notexample.com"
    type = "A"
    ttl = "30"
    records = ["127.0.0.1"]
}
`

and using an incantation with Unquote on the s.Attributes["name"] in resource_aws_route53_record.go.

@pearkes pearkes self-assigned this Feb 26, 2015
catsby added a commit that referenced this issue Mar 17, 2015
Fixes a bug in Route53 and wildcard entries. Refs #501.
Also fixes:
- an issue in the library where we don't fully wait for the results, because the
  error code/condition changed with the migration to aws-sdk-go
- a limitation in the test, where we only consider the first record returned
@catsby
Copy link
Contributor

catsby commented Mar 17, 2015

Thanks for reporting this @delitescere – sorry for the silence. I have a fix in PR #1222 , though it's kind of ugly (manually searching for \\052 feels gross)

@catsby catsby assigned catsby and unassigned pearkes Mar 17, 2015
@catsby
Copy link
Contributor

catsby commented Mar 17, 2015

cc @philk too, since he's the original reporter

@catsby
Copy link
Contributor

catsby commented Mar 17, 2015

Hey @philk and @delitescere – #1222 was just merged into master, so I'm closing this. Thanks again!

@catsby catsby closed this as completed Mar 17, 2015
@ghost
Copy link

ghost commented May 4, 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 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.

@ghost ghost locked and limited conversation to collaborators May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants