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

add data source for aws_route53_resolver_firewall_domain_list #25509

Merged
3 changes: 3 additions & 0 deletions .changelog/25509.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-data-source
aws_route53_resolver_firewall_domain_list
```
7 changes: 4 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,10 @@ func Provider() *schema.Provider {
"aws_route53_traffic_policy_document": route53.DataSourceTrafficPolicyDocument(),
"aws_route53_zone": route53.DataSourceZone(),

"aws_route53_resolver_endpoint": route53resolver.DataSourceEndpoint(),
"aws_route53_resolver_rule": route53resolver.DataSourceRule(),
"aws_route53_resolver_rules": route53resolver.DataSourceRules(),
"aws_route53_resolver_endpoint": route53resolver.DataSourceEndpoint(),
"aws_route53_resolver_firewall_domain_list": route53resolver.DataSourceResolverFirewallDomainList(),
"aws_route53_resolver_rule": route53resolver.DataSourceRule(),
"aws_route53_resolver_rules": route53resolver.DataSourceRules(),

"aws_canonical_user_id": s3.DataSourceCanonicalUserID(),
"aws_s3_bucket": s3.DataSourceBucket(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package route53resolver

import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/route53resolver"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
)

func DataSourceResolverFirewallDomainList() *schema.Resource {
silvaalbert marked this conversation as resolved.
Show resolved Hide resolved
return &schema.Resource{
Read: dataSourceResolverFirewallDomainListRead,

Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Required: true,
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
"creation_time": {
Type: schema.TypeString,
Computed: true,
},
"creator_request_id": {
Type: schema.TypeString,
Computed: true,
},
"domain_count": {
Type: schema.TypeInt,
Computed: true,
},
"name": {
Type: schema.TypeString,
Computed: true,
},
"managed_owner_name": {
Type: schema.TypeString,
Computed: true,
},
"modification_time": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"status_message": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func dataSourceResolverFirewallDomainListRead(d *schema.ResourceData, meta interface{}) error {
silvaalbert marked this conversation as resolved.
Show resolved Hide resolved
conn := meta.(*conns.AWSClient).Route53ResolverConn

input := &route53resolver.GetFirewallDomainListInput{
FirewallDomainListId: aws.String(d.Get("id").(string)),
}

output, err := conn.GetFirewallDomainList(input)

if err != nil {
return fmt.Errorf("error getting Route53 Firewall Domain List: %w", err)
}

if output == nil {
return fmt.Errorf("no Route53 Firewall Domain List found matching criteria; try different search")
silvaalbert marked this conversation as resolved.
Show resolved Hide resolved
}

d.SetId(aws.StringValue(output.FirewallDomainList.Id))
ewbankkit marked this conversation as resolved.
Show resolved Hide resolved
d.Set("arn", output.FirewallDomainList.Arn)
d.Set("creation_time", output.FirewallDomainList.CreationTime)
d.Set("creator_request_id", output.FirewallDomainList.CreatorRequestId)
d.Set("domain_count", output.FirewallDomainList.DomainCount)
d.Set("name", output.FirewallDomainList.Name)
d.Set("managed_owner_name", output.FirewallDomainList.ManagedOwnerName)
d.Set("modification_time", output.FirewallDomainList.ModificationTime)
d.Set("status", output.FirewallDomainList.Status)
d.Set("status_message", output.FirewallDomainList.StatusMessage)

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package route53resolver_test

import (
"regexp"
"testing"

"github.com/aws/aws-sdk-go/service/route53resolver"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
)

func TestAccRoute53ResolverFirewallDomainListDataSource_basic(t *testing.T) {
dataSourceName := "data.aws_route53_resolver_firewall_domain_list.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, route53resolver.EndpointsID),
ProviderFactories: acctest.ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccFirewallDomainListDataSourceConfig_basic(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(dataSourceName, "id"),
acctest.MatchResourceAttrRegionalARN(dataSourceName, "arn", "route53resolver", regexp.MustCompile(`firewall-domain-list/.+`)),
resource.TestCheckResourceAttrSet(dataSourceName, "creation_time"),
resource.TestCheckResourceAttrSet(dataSourceName, "creator_request_id"),
resource.TestCheckResourceAttrSet(dataSourceName, "domain_count"),
resource.TestCheckResourceAttrSet(dataSourceName, "modification_time"),
resource.TestCheckResourceAttrSet(dataSourceName, "name"),
resource.TestMatchResourceAttr(dataSourceName, "status", regexp.MustCompile(`COMPLETE|COMPLETE_IMPORT_FAILED|IMPORTING|DELETING`)),
resource.TestCheckResourceAttrSet(dataSourceName, "status_message"),
),
},
},
})
}

func testAccFirewallDomainListDataSourceConfig_basic() string {
return `
resource "aws_route53_resolver_firewall_domain_list" "test" {
name = "example"
domains = ["example.com.", "test.com."]
}

data "aws_route53_resolver_firewall_domain_list" "test" {
id = aws_route53_resolver_firewall_domain_list.test.id
}

`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
subcategory: "Route 53 Resolver"
layout: "aws"
page_title: "AWS: aws_route53_resolver_firewall_domain_list"
description: |-
Retrieves the specified firewall domain list.
---

# Data Source: aws_route53_resolver_firewall_domain_list

`aws_route53_resolver_firewall_domain_list` Retrieves the specified firewall domain list.

This data source allows to retrieve details about a specific a Route 53 Resolver DNS Firewall domain list.

## Example Usage

The following example shows how to get a firewall domain list from its id.

```terraform
data "aws_route53_resolver_firewall_domain_list" "example" {
id = "rslvr-fdl-example"
}
```

## Argument Reference

* `id` - (Required) The ID of the domain list.

The following attribute is additionally exported:

* `arn` - The Amazon Resource Name (ARN) of the firewall domain list.
* `creation_time` - The date and time that the domain list was created, in Unix time format and Coordinated Universal Time (UTC).
* `creator_request_id` - A unique string defined by you to identify the request.
* `domain_count` - The number of domain names that are specified in the domain list.
* `name` - The name of the domain list.
* `managed_owner_name` - The owner of the list, used only for lists that are not managed by you.
* `modification_time` - The date and time that the domain list was last modified, in Unix time format and Coordinated Universal Time (UTC).
* `status` - The status of the domain list.
* `status_message` - Additional information about the status of the list, if available.