provider/aws: aws_route53_record alias refresh manually updated record
Fixes #9108 When an aws_route53_record alias is created with terraform and then modified via cli or console, terraform wasn't picking up the changes. I had the following config: ``` resource "aws_route53_record" "alias" { zone_id = "${aws_route53_zone.main.zone_id}" name = "www" type = "A" alias { zone_id = "${aws_elb.main.zone_id}" name = "${aws_elb.main.dns_name}" evaluate_target_health = true } } ``` I changed the evaluate_health_target on the AWS console and terraform plan showed me this: ``` % terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_route53_zone.main: Refreshing state... (ID: Z32Z9B1UPAIP6X) aws_elb.main: Refreshing state... (ID: foobar-terraform-elb-1111) aws_route53_record.alias: Refreshing state... (ID: Z32Z9B1UPAIP6X_www_A) No changes. Infrastructure is up-to-date. This means that Terraform could not detect any differences between your configuration and the real physical resources that exist. As a result, Terraform doesn't need to do anything. ``` When rebuilding the provider with the changes in the PR, a terraform plan then looks as follows: ``` % terraform plan [WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider. If you did not expect to see this message you will need to remove the old plugin. See https://www.terraform.io/docs/internals/internal-plugins.html [WARN] /Users/stacko/Code/go/bin/terraform-provider-azurerm overrides an internal plugin for azurerm-provider. If you did not expect to see this message you will need to remove the old plugin. See https://www.terraform.io/docs/internals/internal-plugins.html Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_route53_zone.main: Refreshing state... (ID: Z32Z9B1UPAIP6X) aws_elb.main: Refreshing state... (ID: foobar-terraform-elb-1111) aws_route53_record.alias: Refreshing state... (ID: Z32Z9B1UPAIP6X_www_A) The Terraform execution plan has been generated and is shown below. Resources are shown in alphabetical order for quick scanning. Green resources will be created (or destroyed and then created if an existing resource exists), yellow resources are being changed in-place, and red resources will be destroyed. Cyan entries are data sources to be read. Note: You didn't specify an "-out" parameter to save this plan, so when "apply" is called, Terraform can't guarantee this is what will execute. ~ aws_route53_record.alias alias.1050468691.evaluate_target_health: "" => "true" alias.1050468691.name: "" => "foobar-terraform-elb-1111-522021794.us-west-2.elb.amazonaws.com" alias.1050468691.zone_id: "" => "Z1H1FL5HABSF5" alias.2906616344.evaluate_target_health: "false" => "false" alias.2906616344.name: "foobar-terraform-elb-1111-522021794.us-west-2.elb.amazonaws.com." => "" alias.2906616344.zone_id: "Z1H1FL5HABSF5" => "" Plan: 0 to add, 1 to change, 0 to destroy. ``` the apply then changed the target back to true ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSRoute53Record_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2016/09/29 18:17:23 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSRoute53Record_ -timeout 120m === RUN TestAccAWSRoute53Record_basic --- PASS: TestAccAWSRoute53Record_basic (120.63s) === RUN TestAccAWSRoute53Record_basic_fqdn --- PASS: TestAccAWSRoute53Record_basic_fqdn (131.81s) === RUN TestAccAWSRoute53Record_txtSupport --- PASS: TestAccAWSRoute53Record_txtSupport (128.40s) === RUN TestAccAWSRoute53Record_spfSupport --- PASS: TestAccAWSRoute53Record_spfSupport (120.06s) === RUN TestAccAWSRoute53Record_generatesSuffix --- PASS: TestAccAWSRoute53Record_generatesSuffix (114.02s) === RUN TestAccAWSRoute53Record_wildcard --- PASS: TestAccAWSRoute53Record_wildcard (165.54s) === RUN TestAccAWSRoute53Record_failover --- PASS: TestAccAWSRoute53Record_failover (118.10s) === RUN TestAccAWSRoute53Record_weighted_basic --- PASS: TestAccAWSRoute53Record_weighted_basic (128.10s) === RUN TestAccAWSRoute53Record_alias --- PASS: TestAccAWSRoute53Record_alias (132.62s) === RUN TestAccAWSRoute53Record_s3_alias --- PASS: TestAccAWSRoute53Record_s3_alias (132.12s) === RUN TestAccAWSRoute53Record_weighted_alias --- PASS: TestAccAWSRoute53Record_weighted_alias (237.92s) === RUN TestAccAWSRoute53Record_geolocation_basic --- PASS: TestAccAWSRoute53Record_geolocation_basic (121.95s) === RUN TestAccAWSRoute53Record_latency_basic --- PASS: TestAccAWSRoute53Record_latency_basic (123.40s) === RUN TestAccAWSRoute53Record_TypeChange --- PASS: TestAccAWSRoute53Record_TypeChange (198.24s) === RUN TestAccAWSRoute53Record_empty --- PASS: TestAccAWSRoute53Record_empty (119.68s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws2092.597s ```
This commit is contained in:
parent
88c3554dda
commit
ae2b8d45db
|
@ -374,15 +374,14 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
|||
}
|
||||
|
||||
if alias := record.AliasTarget; alias != nil {
|
||||
if _, ok := d.GetOk("alias"); !ok {
|
||||
d.Set("alias", []interface{}{
|
||||
map[string]interface{}{
|
||||
"zone_id": *alias.HostedZoneId,
|
||||
"name": *alias.DNSName,
|
||||
"evaluate_target_health": *alias.EvaluateTargetHealth,
|
||||
},
|
||||
})
|
||||
}
|
||||
name := strings.TrimSuffix(*alias.DNSName, ".")
|
||||
d.Set("alias", []interface{}{
|
||||
map[string]interface{}{
|
||||
"zone_id": *alias.HostedZoneId,
|
||||
"name": name,
|
||||
"evaluate_target_health": *alias.EvaluateTargetHealth,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
d.Set("ttl", record.TTL)
|
||||
|
|
Loading…
Reference in New Issue