Skip to content

Commit

Permalink
route53 zone datesource - arn
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Aug 22, 2021
1 parent 3b1c246 commit b14e2b9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .changelog/20652.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:enhancement
resource/aws_route53_zone: Add `arn` attribute
```

```release-note:enhancement
resource/aws_route53_zone: Add plan time validation for `comment`
```

```release-note:enhancement
data-source/aws_route53_zone: Add `arn` attribute
```
12 changes: 12 additions & 0 deletions aws/data_source_aws_route53_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
Expand All @@ -15,6 +16,10 @@ func dataSourceAwsRoute53Zone() *schema.Resource {
Read: dataSourceAwsRoute53ZoneRead,

Schema: map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Computed: true,
},
"zone_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -190,6 +195,13 @@ func dataSourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("error setting tags: %w", err)
}

arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: "route53",
Resource: fmt.Sprintf("hostedzone/%s", d.Id()),
}.String()
d.Set("arn", arn)

return nil
}

Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_route53_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestAccAWSRoute53ZoneDataSource_id(t *testing.T) {
{
Config: testAccDataSourceAwsRoute53ZoneConfigId(fqdn),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(resourceName, "arn", dataSourceName, "arn"),
resource.TestCheckResourceAttrPair(resourceName, "id", dataSourceName, "id"),
resource.TestCheckResourceAttrPair(resourceName, "name", dataSourceName, "name"),
resource.TestCheckResourceAttrPair(resourceName, "name_servers.#", dataSourceName, "name_servers.#"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/route53_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ the selected Hosted Zone.

The following attribute is additionally exported:

* `arn` - The Amazon Resource Name (ARN) of the Hosted Zone.
* `caller_reference` - Caller Reference of the Hosted Zone.
* `comment` - The comment field of the Hosted Zone.
* `name_servers` - The list of DNS name servers for the Hosted Zone.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/route53_zone.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The following arguments are supported:

In addition to all arguments above, the following attributes are exported:

* `arn` - The Amazon Resource Name (ARN) of the zone.
* `arn` - The Amazon Resource Name (ARN) of the Hosted Zone.
* `zone_id` - The Hosted Zone ID. This can be referenced by zone records.
* `name_servers` - A list of name servers in associated (or default) delegation set.
Find more about delegation sets in [AWS docs](https://docs.aws.amazon.com/Route53/latest/APIReference/actions-on-reusable-delegation-sets.html).
Expand Down

0 comments on commit b14e2b9

Please sign in to comment.