Allow empty names in aws_route53_record

Added test for aws_route53_record with empty name

Integrated test for aws_route53_record with empty name

Changed test to use a third-level domain for zone
This commit is contained in:
macheins 2016-07-07 16:01:33 +02:00 committed by stack72
parent 14d82af73a
commit aabb200f2d
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
2 changed files with 36 additions and 1 deletions

View File

@ -695,8 +695,12 @@ func expandRecordName(name, zone string) string {
rn := strings.ToLower(strings.TrimSuffix(name, "."))
zone = strings.TrimSuffix(zone, ".")
if !strings.HasSuffix(rn, zone) {
if len(name) == 0 {
rn = zone
} else {
rn = strings.Join([]string{name, zone}, ".")
}
}
return rn
}

View File

@ -339,6 +339,23 @@ func TestAccAWSRoute53Record_TypeChange(t *testing.T) {
})
}
func TestAccAWSRoute53Record_empty(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "aws_route53_record.empty",
Providers: testAccProviders,
CheckDestroy: testAccCheckRoute53RecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRoute53RecordConfigEmptyName,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53RecordExists("aws_route53_record.empty"),
),
},
},
})
}
func testAccCheckRoute53RecordDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).r53conn
for _, rs := range s.RootModule().Resources {
@ -972,3 +989,17 @@ resource "aws_route53_record" "sample" {
records = ["127.0.0.1", "8.8.8.8"]
}
`
const testAccRoute53RecordConfigEmptyName = `
resource "aws_route53_zone" "main" {
name = "not.example.com"
}
resource "aws_route53_record" "empty" {
zone_id = "${aws_route53_zone.main.zone_id}"
name = ""
type = "A"
ttl = "30"
records = ["127.0.0.1"]
}
`