-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource/aws_route53_record: Suppress uppercase alias name diff #3119
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,24 @@ func TestExpandRecordName(t *testing.T) { | |
} | ||
} | ||
|
||
func TestNormalizeAwsAliasName(t *testing.T) { | ||
cases := []struct { | ||
Input, Output string | ||
}{ | ||
{"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"}, | ||
{"NAME-123456789.region.elb.amazonaws.com", "name-123456789.region.elb.amazonaws.com"}, | ||
} | ||
|
||
for _, tc := range cases { | ||
actual := normalizeAwsAliasName(tc.Input) | ||
if actual != tc.Output { | ||
t.Fatalf("input: %s\noutput: %s", tc.Input, actual) | ||
} | ||
} | ||
} | ||
|
||
func TestParseRecordId(t *testing.T) { | ||
cases := []struct { | ||
Input, Zone, Name, Type, Set string | ||
|
@@ -280,6 +298,25 @@ func TestAccAWSRoute53Record_alias(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSRoute53Record_aliasUppercase(t *testing.T) { | ||
rs := acctest.RandString(10) | ||
config := fmt.Sprintf(testAccRoute53ElbAliasRecordUppercase, rs) | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
IDRefreshName: "aws_route53_record.alias", | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckRoute53RecordDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckRoute53RecordExists("aws_route53_record.alias"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSRoute53Record_s3_alias(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
|
@@ -968,6 +1005,36 @@ resource "aws_elb" "main" { | |
} | ||
` | ||
|
||
const testAccRoute53ElbAliasRecordUppercase = ` | ||
resource "aws_route53_zone" "main" { | ||
name = "notexample.com" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know other zones are static (so far), but can you randomize the name here, please? We can address others in a separate PR in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You got it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha! You'll love this. We actually hardcode it in the exists/destroy functions too: https://github.com/terraform-providers/terraform-provider-aws/blob/b-aws_route53_record-alias-name-diffsuppressfunc/aws/resource_aws_route53_record_test.go#L586 Its all or nothing 👎 -- I will get that nitpick merged though 👍 |
||
} | ||
|
||
resource "aws_route53_record" "alias" { | ||
zone_id = "${aws_route53_zone.main.zone_id}" | ||
name = "www" | ||
type = "A" | ||
|
||
alias { | ||
zone_id = "${aws_elb.main.zone_id}" | ||
name = "${aws_elb.main.dns_name}" | ||
evaluate_target_health = true | ||
} | ||
} | ||
|
||
resource "aws_elb" "main" { | ||
name = "FOOBAR-TERRAFORM-ELB-%s" | ||
availability_zones = ["us-west-2a"] | ||
|
||
listener { | ||
instance_port = 80 | ||
instance_protocol = "http" | ||
lb_port = 80 | ||
lb_protocol = "http" | ||
} | ||
} | ||
` | ||
|
||
const testAccRoute53AliasRecord = ` | ||
resource "aws_route53_zone" "main" { | ||
name = "notexample.com" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole function can be reduced to a single line:
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 good catch