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

provider/aws: Update Route53 Record to schema v1, normalizing name #6592

Merged
merged 1 commit into from
May 17, 2016

Conversation

catsby
Copy link
Contributor

@catsby catsby commented May 10, 2016

The name attribute will always be normalized to a FQDN, with a trailing "dot"
at the end when returned from the API.

We store the name as it's provided in the configuration, so "www" stays as "www"
and "www.terraformtesting.io." stays as "www.terraformtesting.io.".

The problem here is that if we use a full name as above, and the configuraiton
does not include the trailing dot, the API will return a version that does,
and we'll have a conflict.

This is particularly bad when we have a lifecycle block with
create_before_destroy; the record will get an update posted (which ends up
being a no-op on AWS's side), but then we'll delete the same record immediately
after, resulting in no record at all.

This PR addresses that by trimming the trailing dot from the name when saving
to state. We migrate existing state to match, to avoid false-positive diffs.

This should fix #6511. Running acc tests now, will post when done

The `name` attribute will always be normalized to a FQDN, with a trailing "dot"
at the end when returned from the API.

We store the name as it's provided in the configuration, so "www" stays as "www"
and "www.terraformtesting.io." stays as "www.terraformtesting.io.".

The problem here is that if we use a full name as above, and the configuraiton
does *not* include the trailing dot, the API will return a version that does,
and we'll have a conflict.

This is particularly bad when we have a lifecycle block with
`create_before_destroy`; the record will get an update posted (which ends up
being a no-op on AWS's side), but then we'll delete the same record immediately
after, resulting in no record at all.

This PR addresses that by trimming the trailing dot from the `name` when saving
to state. We migrate existing state to match, to avoid false-positive diffs.
@jen20
Copy link
Contributor

jen20 commented May 17, 2016

Acceptance tests:

make testacc TEST=./builtin/providers/aws TESTARGS="-run TestAccAWSRoute53Record_basic_fqdn"
==> Checking that code complies with gofmt requirements...
/Users/James/Code/go/bin/stringer
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/aws -v -run TestAccAWSRoute53Record_basic_fqdn -timeout 120m
=== RUN   TestAccAWSRoute53Record_basic_fqdn
--- PASS: TestAccAWSRoute53Record_basic_fqdn (110.64s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    110.656s
make testacc TEST=./builtin/providers/aws/ TESTARGS="-run TestAWSRoute53RecordMigrateState"
==> Checking that code complies with gofmt requirements...
/Users/James/Code/go/bin/stringer
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/aws/ -v -run TestAWSRoute53RecordMigrateState -timeout 120m
=== RUN   TestAWSRoute53RecordMigrateState
2016/05/17 12:54:01 [INFO] Found AWS Route53 Record State v0; migrating to v1
2016/05/17 12:54:01 [DEBUG] Attributes before migration: map[string]string{"name":"www.notdomain.com"}
2016/05/17 12:54:01 [DEBUG] Attributes after migration: map[string]string{"name":"www.notdomain.com"}, new name: www.notdomain.com
2016/05/17 12:54:01 [INFO] Found AWS Route53 Record State v0; migrating to v1
2016/05/17 12:54:01 [DEBUG] Attributes before migration: map[string]string{"name":"www"}
2016/05/17 12:54:01 [DEBUG] Attributes after migration: map[string]string{"name":"www"}, new name: www
2016/05/17 12:54:01 [INFO] Found AWS Route53 Record State v0; migrating to v1
2016/05/17 12:54:01 [DEBUG] Attributes before migration: map[string]string{"name":"www.notdomain.com."}
2016/05/17 12:54:01 [DEBUG] Attributes after migration: map[string]string{"name":"www.notdomain.com"}, new name: www.notdomain.com
--- PASS: TestAWSRoute53RecordMigrateState (0.00s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    0.018s

@jen20
Copy link
Contributor

jen20 commented May 17, 2016

LGTM!

@jen20 jen20 merged commit 5500208 into master May 17, 2016
@jen20 jen20 deleted the b-aws-r53-name-state branch May 17, 2016 17:56
@ghost
Copy link

ghost commented Apr 25, 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 Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants