provider/aws: Fix issue with Route53 and zero weighted records
This commit is contained in:
parent
2a7576068f
commit
f68a351fba
|
@ -64,9 +64,13 @@ func resourceAwsRoute53Record() *schema.Resource {
|
||||||
ConflictsWith: []string{"alias"},
|
ConflictsWith: []string{"alias"},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Weight uses a special sentinel value to indicate it's presense.
|
||||||
|
// Because 0 is a valid value for Weight, we default to -1 so that any
|
||||||
|
// inclusion of a weight (zero or not) will be a usable value
|
||||||
"weight": &schema.Schema{
|
"weight": &schema.Schema{
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Default: -1,
|
||||||
},
|
},
|
||||||
|
|
||||||
"set_identifier": &schema.Schema{
|
"set_identifier": &schema.Schema{
|
||||||
|
@ -171,8 +175,8 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
ChangeBatch: changeBatch,
|
ChangeBatch: changeBatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[DEBUG] Creating resource records for zone: %s, name: %s",
|
log.Printf("[DEBUG] Creating resource records for zone: %s, name: %s\n\n%s",
|
||||||
zone, *rec.Name)
|
zone, *rec.Name, req)
|
||||||
|
|
||||||
wait := resource.StateChangeConf{
|
wait := resource.StateChangeConf{
|
||||||
Pending: []string{"rejected"},
|
Pending: []string{"rejected"},
|
||||||
|
@ -292,7 +296,12 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("ttl", record.TTL)
|
d.Set("ttl", record.TTL)
|
||||||
|
// Only set the weight if it's non-nil, otherwise we end up with a 0 weight
|
||||||
|
// which has actual contextual meaning with Route 53 records
|
||||||
|
// See http://docs.aws.amazon.com/fr_fr/Route53/latest/APIReference/API_ChangeResourceRecordSets_Examples.html
|
||||||
|
if record.Weight != nil {
|
||||||
d.Set("weight", record.Weight)
|
d.Set("weight", record.Weight)
|
||||||
|
}
|
||||||
d.Set("set_identifier", record.SetIdentifier)
|
d.Set("set_identifier", record.SetIdentifier)
|
||||||
d.Set("failover", record.Failover)
|
d.Set("failover", record.Failover)
|
||||||
d.Set("health_check_id", record.HealthCheckId)
|
d.Set("health_check_id", record.HealthCheckId)
|
||||||
|
@ -439,8 +448,9 @@ func resourceAwsRoute53RecordBuildSet(d *schema.ResourceData, zoneName string) (
|
||||||
rec.SetIdentifier = aws.String(v.(string))
|
rec.SetIdentifier = aws.String(v.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("weight"); ok {
|
w := d.Get("weight").(int)
|
||||||
rec.Weight = aws.Int64(int64(v.(int)))
|
if w > -1 {
|
||||||
|
rec.Weight = aws.Int64(int64(w))
|
||||||
}
|
}
|
||||||
|
|
||||||
return rec, nil
|
return rec, nil
|
||||||
|
|
Loading…
Reference in New Issue