- minor wording update and link to docs

- fix error checking
- update debug log on migration
- remove regression test because the attribute is renamed
This commit is contained in:
clint shryock 2016-05-31 15:24:46 -05:00
parent 97fbeaf59f
commit d89a240885
3 changed files with 10 additions and 67 deletions

View File

@ -73,7 +73,7 @@ func resourceAwsRoute53Record() *schema.Resource {
"weight": &schema.Schema{
Type: schema.TypeInt,
Optional: true,
Removed: "Now implemented as weighted_routing_policy; see docs",
Removed: "Now implemented as weighted_routing_policy; Please see https://www.terraform.io/docs/providers/aws/r/route53_record.html",
},
"set_identifier": &schema.Schema{
@ -151,7 +151,6 @@ func resourceAwsRoute53Record() *schema.Resource {
"region": &schema.Schema{
Type: schema.TypeString,
Required: true,
Optional: false,
},
},
},
@ -382,9 +381,8 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
v := []map[string]interface{}{{
"type": aws.StringValue(record.Failover),
}}
d.Set("failover_routing_policy", v)
if err != nil {
return fmt.Errorf("[DEBUG] Error setting records for: %s, error: %#v", d.Id(), err)
if err := d.Set("failover_routing_policy", v); err != nil {
return fmt.Errorf("[DEBUG] Error setting failover records for: %s, error: %#v", d.Id(), err)
}
}
@ -394,9 +392,8 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
"country": aws.StringValue(record.GeoLocation.CountryCode),
"subdivision": aws.StringValue(record.GeoLocation.SubdivisionCode),
}}
d.Set("geolocation_routing_policy", v)
if err != nil {
return fmt.Errorf("[DEBUG] Error setting records for: %s, error: %#v", d.Id(), err)
if err := d.Set("geolocation_routing_policy", v); err != nil {
return fmt.Errorf("[DEBUG] Error setting gelocation records for: %s, error: %#v", d.Id(), err)
}
}
@ -404,9 +401,8 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
v := []map[string]interface{}{{
"region": aws.StringValue(record.Region),
}}
d.Set("latency_routing_policy", v)
if err != nil {
return fmt.Errorf("[DEBUG] Error setting records for: %s, error: %#v", d.Id(), err)
if err := d.Set("latency_routing_policy", v); err != nil {
return fmt.Errorf("[DEBUG] Error setting latency records for: %s, error: %#v", d.Id(), err)
}
}
@ -414,9 +410,8 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
v := []map[string]interface{}{{
"weight": aws.Int64Value((record.Weight)),
}}
d.Set("weighted_routing_policy", v)
if err != nil {
return fmt.Errorf("[DEBUG] Error setting records for: %s, error: %#v", d.Id(), err)
if err := d.Set("weighted_routing_policy", v); err != nil {
return fmt.Errorf("[DEBUG] Error setting weighted records for: %s, error: %#v", d.Id(), err)
}
}

View File

@ -15,7 +15,7 @@ func resourceAwsRoute53RecordMigrateState(
log.Println("[INFO] Found AWS Route53 Record State v0; migrating to v1")
return migrateRoute53RecordStateV0toV1(is)
case 1:
log.Println("[INFO] Found AWS Route53 Record State v0; migrating to v1")
log.Println("[INFO] Found AWS Route53 Record State v1; migrating to v2")
return migrateRoute53RecordStateV1toV2(is)
default:
return is, fmt.Errorf("Unexpected schema version: %d", v)

View File

@ -336,58 +336,6 @@ func TestAccAWSRoute53Record_TypeChange(t *testing.T) {
})
}
// Test record deletion out of band and make sure we render a new plan
// Part of regression test(s) for https://github.com/hashicorp/terraform/pull/4892
func TestAccAWSRoute53Record_planUpdate(t *testing.T) {
var zone route53.GetHostedZoneOutput
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRoute53RecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRoute53RecordConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53RecordExists("aws_route53_record.default"),
testAccCheckRoute53ZoneExists("aws_route53_zone.main", &zone),
),
},
resource.TestStep{
Config: testAccRoute53RecordConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53DeleteRecord("aws_route53_record.default", &zone),
),
ExpectNonEmptyPlan: true,
},
resource.TestStep{
Config: testAccRoute53RecordNoConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53ZoneExists("aws_route53_zone.main", &zone),
),
},
},
})
}
func testAccCheckRoute53DeleteRecord(n string, zone *route53.GetHostedZoneOutput) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No hosted zone ID is set")
}
// Manually set the weight to 0 to replicate a record created in Terraform
// pre-0.6.9
rs.Primary.Attributes["weight"] = "0"
return nil
}
}
func testAccCheckRoute53RecordDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).r53conn
for _, rs := range s.RootModule().Resources {