provider/aws: Downcase Route 53 record names in statefile
This commit is contained in:
parent
7a24da8c94
commit
d798042475
|
@ -28,6 +28,10 @@ func resourceAwsRoute53Record() *schema.Resource {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
StateFunc: func(v interface{}) string {
|
||||||
|
value := v.(string)
|
||||||
|
return strings.ToLower(value)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"fqdn": &schema.Schema{
|
"fqdn": &schema.Schema{
|
||||||
|
@ -242,6 +246,8 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
StartRecordType: aws.String(d.Get("type").(string)),
|
StartRecordType: aws.String(d.Get("type").(string)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] List resource records sets for zone: %s, opts: %s",
|
||||||
|
zone, lopts)
|
||||||
resp, err := conn.ListResourceRecordSets(lopts)
|
resp, err := conn.ListResourceRecordSets(lopts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -251,7 +257,7 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
found := false
|
found := false
|
||||||
for _, record := range resp.ResourceRecordSets {
|
for _, record := range resp.ResourceRecordSets {
|
||||||
name := cleanRecordName(*record.Name)
|
name := cleanRecordName(*record.Name)
|
||||||
if FQDN(name) != FQDN(*lopts.StartRecordName) {
|
if FQDN(strings.ToLower(name)) != FQDN(strings.ToLower(*lopts.StartRecordName)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.ToUpper(*record.Type) != strings.ToUpper(*lopts.StartRecordType) {
|
if strings.ToUpper(*record.Type) != strings.ToUpper(*lopts.StartRecordType) {
|
||||||
|
@ -279,6 +285,7 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
|
log.Printf("[DEBUG] No matching record found for: %s, removing from state file", en)
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue