@@ -82,7 +82,7 @@ func ResourceZone() *schema.Resource {
82
82
Type : schema .TypeString ,
83
83
Required : true ,
84
84
ForceNew : true ,
85
- StateFunc : TrimTrailingPeriod ,
85
+ StateFunc : NormalizeZoneName ,
86
86
ValidateFunc : validation .StringLenBetween (1 , 1024 ),
87
87
},
88
88
"name_servers" : {
@@ -209,7 +209,7 @@ func resourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interfac
209
209
d .Set ("delegation_set_id" , "" )
210
210
// To be consistent with other AWS services (e.g. ACM) that do not accept a trailing period,
211
211
// we remove the suffix from the Hosted Zone Name returned from the API
212
- d .Set ("name" , TrimTrailingPeriod (aws .StringValue (output .HostedZone .Name )))
212
+ d .Set ("name" , NormalizeZoneName (aws .StringValue (output .HostedZone .Name )))
213
213
d .Set ("zone_id" , CleanZoneID (aws .StringValue (output .HostedZone .Id )))
214
214
215
215
var nameServers []string
@@ -549,11 +549,14 @@ func CleanZoneID(ID string) string {
549
549
return strings .TrimPrefix (ID , "/hostedzone/" )
550
550
}
551
551
552
- // TrimTrailingPeriod is used to remove the trailing period
553
- // of "name" or "domain name" attributes often returned from
554
- // the Route53 API or provided as user input.
552
+ // NormalizeZoneName is used to remove the trailing period
553
+ // and apply consistent casing to "name" or "domain name"
554
+ // attributes returned from the Route53 API or provided as
555
+ // user input.
556
+ //
555
557
// The single dot (".") domain name is returned as-is.
556
- func TrimTrailingPeriod (v interface {}) string {
558
+ // Uppercase letters are converted to lowercase.
559
+ func NormalizeZoneName (v interface {}) string {
557
560
var str string
558
561
switch value := v .(type ) {
559
562
case * string :
@@ -568,7 +571,7 @@ func TrimTrailingPeriod(v interface{}) string {
568
571
return str
569
572
}
570
573
571
- return strings .TrimSuffix (str , "." )
574
+ return strings .ToLower ( strings . TrimSuffix (str , "." ) )
572
575
}
573
576
574
577
func findNameServers (ctx context.Context , conn * route53.Route53 , zoneId string , zoneName string ) ([]string , error ) {
0 commit comments