From 167ceb6b5c403111e0f456bafe077471cf92cabe Mon Sep 17 00:00:00 2001 From: Michael Handler Date: Mon, 29 Jan 2018 18:53:58 -0800 Subject: [PATCH] Don't mangle DNS aliases: Trim{Prefix,Suffix} not Trim{Left,Right}. --- aws/resource_aws_route53_record.go | 9 +++------ aws/resource_aws_route53_record_test.go | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/aws/resource_aws_route53_record.go b/aws/resource_aws_route53_record.go index d3c414b7714..7884b8a9fb3 100644 --- a/aws/resource_aws_route53_record.go +++ b/aws/resource_aws_route53_record.go @@ -900,12 +900,9 @@ func nilString(s string) *string { } func normalizeAwsAliasName(alias interface{}) string { - input := alias.(string) - output := strings.ToLower(input) - if strings.HasPrefix(output, "dualstack.") { - output = strings.TrimLeft(output, "dualstack.") - } - return strings.TrimRight(output, ".") + input := strings.ToLower(alias.(string)) + output := strings.TrimPrefix(input, "dualstack.") + return strings.TrimSuffix(output, ".") } func parseRecordId(id string) [4]string { diff --git a/aws/resource_aws_route53_record_test.go b/aws/resource_aws_route53_record_test.go index 317fa0b83cd..cb54d39b437 100644 --- a/aws/resource_aws_route53_record_test.go +++ b/aws/resource_aws_route53_record_test.go @@ -59,6 +59,8 @@ func TestNormalizeAwsAliasName(t *testing.T) { {"www.nonexample.com", "www.nonexample.com"}, {"www.nonexample.com.", "www.nonexample.com"}, {"dualstack.name-123456789.region.elb.amazonaws.com", "name-123456789.region.elb.amazonaws.com"}, + {"dualstack.test-987654321.region.elb.amazonaws.com", "test-987654321.region.elb.amazonaws.com"}, + {"dualstacktest.com", "dualstacktest.com"}, {"NAME-123456789.region.elb.amazonaws.com", "name-123456789.region.elb.amazonaws.com"}, }