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:
parent
14d82af73a
commit
aabb200f2d
|
@ -695,7 +695,11 @@ func expandRecordName(name, zone string) string {
|
||||||
rn := strings.ToLower(strings.TrimSuffix(name, "."))
|
rn := strings.ToLower(strings.TrimSuffix(name, "."))
|
||||||
zone = strings.TrimSuffix(zone, ".")
|
zone = strings.TrimSuffix(zone, ".")
|
||||||
if !strings.HasSuffix(rn, zone) {
|
if !strings.HasSuffix(rn, zone) {
|
||||||
rn = strings.Join([]string{name, zone}, ".")
|
if len(name) == 0 {
|
||||||
|
rn = zone
|
||||||
|
} else {
|
||||||
|
rn = strings.Join([]string{name, zone}, ".")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rn
|
return rn
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
func testAccCheckRoute53RecordDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).r53conn
|
conn := testAccProvider.Meta().(*AWSClient).r53conn
|
||||||
for _, rs := range s.RootModule().Resources {
|
for _, rs := range s.RootModule().Resources {
|
||||||
|
@ -972,3 +989,17 @@ resource "aws_route53_record" "sample" {
|
||||||
records = ["127.0.0.1", "8.8.8.8"]
|
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"]
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
Loading…
Reference in New Issue