Merge pull request #3574 from hashicorp/b-aws-r53-name-fix
provider/aws: Downcase Route 53 record names in statefile
This commit is contained in:
commit
dbc008e330
|
@ -28,6 +28,10 @@ func resourceAwsRoute53Record() *schema.Resource {
|
|||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
StateFunc: func(v interface{}) string {
|
||||
value := v.(string)
|
||||
return strings.ToLower(value)
|
||||
},
|
||||
},
|
||||
|
||||
"fqdn": &schema.Schema{
|
||||
|
@ -192,12 +196,13 @@ func resourceAwsRoute53RecordCreate(d *schema.ResourceData, meta interface{}) er
|
|||
// Generate an ID
|
||||
vars := []string{
|
||||
zone,
|
||||
d.Get("name").(string),
|
||||
strings.ToLower(d.Get("name").(string)),
|
||||
d.Get("type").(string),
|
||||
}
|
||||
if v, ok := d.GetOk("set_identifier"); ok {
|
||||
vars = append(vars, v.(string))
|
||||
}
|
||||
|
||||
d.SetId(strings.Join(vars, "_"))
|
||||
|
||||
// Wait until we are done
|
||||
|
@ -242,6 +247,8 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
|||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -251,7 +258,7 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
|||
found := false
|
||||
for _, record := range resp.ResourceRecordSets {
|
||||
name := cleanRecordName(*record.Name)
|
||||
if FQDN(name) != FQDN(*lopts.StartRecordName) {
|
||||
if FQDN(strings.ToLower(name)) != FQDN(strings.ToLower(*lopts.StartRecordName)) {
|
||||
continue
|
||||
}
|
||||
if strings.ToUpper(*record.Type) != strings.ToUpper(*lopts.StartRecordType) {
|
||||
|
@ -279,6 +286,7 @@ func resourceAwsRoute53RecordRead(d *schema.ResourceData, meta interface{}) erro
|
|||
}
|
||||
|
||||
if !found {
|
||||
log.Printf("[DEBUG] No matching record found for: %s, removing from state file", en)
|
||||
d.SetId("")
|
||||
}
|
||||
|
||||
|
@ -440,7 +448,7 @@ func cleanRecordName(name string) string {
|
|||
// If it does not, add the zone name to form a fully qualified name
|
||||
// and keep AWS happy.
|
||||
func expandRecordName(name, zone string) string {
|
||||
rn := strings.TrimSuffix(name, ".")
|
||||
rn := strings.ToLower(strings.TrimSuffix(name, "."))
|
||||
zone = strings.TrimSuffix(zone, ".")
|
||||
if !strings.HasSuffix(rn, zone) {
|
||||
rn = strings.Join([]string{name, zone}, ".")
|
||||
|
|
|
@ -291,7 +291,7 @@ func testAccCheckRoute53RecordExists(n string) resource.TestCheckFunc {
|
|||
// rec := resp.ResourceRecordSets[0]
|
||||
for _, rec := range resp.ResourceRecordSets {
|
||||
recName := cleanRecordName(*rec.Name)
|
||||
if FQDN(recName) == FQDN(en) && *rec.Type == rType {
|
||||
if FQDN(strings.ToLower(recName)) == FQDN(strings.ToLower(en)) && *rec.Type == rType {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ resource "aws_route53_zone" "main" {
|
|||
|
||||
resource "aws_route53_record" "default" {
|
||||
zone_id = "${aws_route53_zone.main.zone_id}"
|
||||
name = "www.notexample.com"
|
||||
name = "www.NOTexamplE.com"
|
||||
type = "A"
|
||||
ttl = "30"
|
||||
records = ["127.0.0.1", "127.0.0.27"]
|
||||
|
|
Loading…
Reference in New Issue