Skip to content

Commit

Permalink
Merge pull request #32664 from sh0e1/b-aws_lightsail_domain-fix-recor…
Browse files Browse the repository at this point in the history
…d-type

r/aws_lightsail_domain_entry: support for AAAA record type
  • Loading branch information
ewbankkit committed Jul 25, 2023
2 parents cc99f0b + d74b7fe commit ec2a8ba
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/32664.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_lightsail_domain_entry: Add support for `AAAA` `type` value
```
1 change: 1 addition & 0 deletions internal/service/lightsail/domain_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func ResourceDomainEntry() *schema.Resource {
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"A",
"AAAA",
"CNAME",
"MX",
"NS",
Expand Down
55 changes: 55 additions & 0 deletions internal/service/lightsail/domain_entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,46 @@ func TestAccLightsailDomainEntry_disappears(t *testing.T) {
})
}

func TestAccLightsailDomainEntry_typeAAAA(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_lightsail_domain_entry.test"
domainName := acctest.RandomDomainName()
domainEntryName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, string(types.RegionNameUsEast1)) },
ErrorCheck: acctest.ErrorCheck(t, strings.ToLower(lightsail.ServiceID)),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckDomainEntryDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccDomainEntryConfig_typeAAAA(domainName, domainEntryName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckDomainEntryExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "domain_name", domainName),
resource.TestCheckResourceAttr(resourceName, "name", domainEntryName),
resource.TestCheckResourceAttr(resourceName, "target", "::1"),
resource.TestCheckResourceAttr(resourceName, "type", "AAAA"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
// Validate that we can import an existing resource using the legacy separator
// Validate that the ID is updated to use the new common separator
{
ResourceName: resourceName,
ImportState: true,
ImportStateIdFunc: testAccDomainEntryStateLegacyIdFunc(resourceName),
ImportStateVerify: true,
Check: resource.TestCheckResourceAttr(resourceName, "id", fmt.Sprintf("%s,%s,%s,%s", domainEntryName, domainName, "AAAA", "::1")),
},
},
})
}

func testAccCheckDomainEntryExists(ctx context.Context, n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -236,6 +276,21 @@ resource "aws_lightsail_domain_entry" "test" {
`, domainName, domainEntryName)
}

func testAccDomainEntryConfig_typeAAAA(domainName string, domainEntryName string) string {
return fmt.Sprintf(`
resource "aws_lightsail_domain" "test" {
domain_name = %[1]q
}
resource "aws_lightsail_domain_entry" "test" {
domain_name = aws_lightsail_domain.test.id
name = %[2]q
type = "AAAA"
target = "::1"
}
`, domainName, domainEntryName)
}

func testAccDomainEntryStateLegacyIdFunc(resourceName string) resource.ImportStateIdFunc {
return func(s *terraform.State) (string, error) {
rs, ok := s.RootModule().Resources[resourceName]
Expand Down

0 comments on commit ec2a8ba

Please sign in to comment.