Skip to content
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

r/aws_lightsail_domain_entry: support for AAAA record type #32664

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: Support for AAAA record type
```
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
Loading