Skip to content

Commit

Permalink
Merge pull request #39659 from danielewood/f/vpc_endpoint_service_dat…
Browse files Browse the repository at this point in the history
…a_source_additions

d/vpc_endpoint_service: add output of private_dns_names
  • Loading branch information
jar-b authored Oct 10, 2024
2 parents c6b0c29 + 2af3dc4 commit 2d0d06b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/39659.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
data-source/aws_vpc_endpoint_service: Add `private_dns_names` attribute
```
12 changes: 12 additions & 0 deletions internal/service/ec2/vpc_endpoint_service_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func dataSourceVPCEndpointService() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"private_dns_names": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"service": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -187,6 +192,13 @@ func dataSourceVPCEndpointServiceRead(ctx context.Context, d *schema.ResourceDat
d.Set("manages_vpc_endpoints", sd.ManagesVpcEndpoints)
d.Set(names.AttrOwner, sd.Owner)
d.Set("private_dns_name", sd.PrivateDnsName)

privateDnsNames := make([]string, len(sd.PrivateDnsNames))
for i, privateDnsDetail := range sd.PrivateDnsNames {
privateDnsNames[i] = aws.ToString(privateDnsDetail.PrivateDnsName)
}
d.Set("private_dns_names", privateDnsNames)

d.Set("service_id", serviceID)
d.Set(names.AttrServiceName, serviceName)
if len(sd.ServiceType) > 0 {
Expand Down
4 changes: 4 additions & 0 deletions internal/service/ec2/vpc_endpoint_service_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestAccVPCEndpointServiceDataSource_ServiceType_gateway(t *testing.T) {
resource.TestCheckResourceAttr(datasourceName, "manages_vpc_endpoints", acctest.CtFalse),
resource.TestCheckResourceAttr(datasourceName, names.AttrOwner, "amazon"),
resource.TestCheckResourceAttr(datasourceName, "private_dns_name", ""),
resource.TestCheckResourceAttr(datasourceName, "private_dns_names.#", acctest.Ct0),
testAccCheckResourceAttrRegionalReverseDNSService(datasourceName, names.AttrServiceName, "dynamodb"),
resource.TestCheckResourceAttr(datasourceName, "service_type", "Gateway"),
acctest.CheckResourceAttrGreaterThanValue(datasourceName, "supported_ip_address_types.#", 0),
Expand Down Expand Up @@ -96,6 +97,7 @@ func TestAccVPCEndpointServiceDataSource_custom(t *testing.T) {
resource.TestCheckResourceAttrPair(datasourceName, "manages_vpc_endpoints", resourceName, "manages_vpc_endpoints"),
acctest.CheckResourceAttrAccountID(datasourceName, names.AttrOwner),
resource.TestCheckResourceAttrPair(datasourceName, "private_dns_name", resourceName, "private_dns_name"),
resource.TestCheckResourceAttrPair(datasourceName, "private_dns_names.#", resourceName, "private_dns_names.#"),
resource.TestCheckResourceAttr(datasourceName, "service_type", "Interface"),
resource.TestCheckResourceAttrPair(datasourceName, "supported_ip_address_types.#", resourceName, "supported_ip_address_types.#"),
resource.TestCheckResourceAttrPair(datasourceName, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent),
Expand Down Expand Up @@ -127,6 +129,7 @@ func TestAccVPCEndpointServiceDataSource_Custom_filter(t *testing.T) {
resource.TestCheckResourceAttrPair(datasourceName, "manages_vpc_endpoints", resourceName, "manages_vpc_endpoints"),
acctest.CheckResourceAttrAccountID(datasourceName, names.AttrOwner),
resource.TestCheckResourceAttrPair(datasourceName, "private_dns_name", resourceName, "private_dns_name"),
resource.TestCheckResourceAttrPair(datasourceName, "private_dns_names.#", resourceName, "private_dns_names.#"),
resource.TestCheckResourceAttr(datasourceName, "service_type", "Interface"),
resource.TestCheckResourceAttrPair(datasourceName, "supported_ip_address_types.#", resourceName, "supported_ip_address_types.#"),
resource.TestCheckResourceAttrPair(datasourceName, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent),
Expand Down Expand Up @@ -158,6 +161,7 @@ func TestAccVPCEndpointServiceDataSource_CustomFilter_tags(t *testing.T) {
resource.TestCheckResourceAttrPair(datasourceName, "manages_vpc_endpoints", resourceName, "manages_vpc_endpoints"),
acctest.CheckResourceAttrAccountID(datasourceName, names.AttrOwner),
resource.TestCheckResourceAttrPair(datasourceName, "private_dns_name", resourceName, "private_dns_name"),
resource.TestCheckResourceAttrPair(datasourceName, "private_dns_names.#", resourceName, "private_dns_names.#"),
resource.TestCheckResourceAttr(datasourceName, "service_type", "Interface"),
resource.TestCheckResourceAttrPair(datasourceName, "supported_ip_address_types.#", resourceName, "supported_ip_address_types.#"),
resource.TestCheckResourceAttrPair(datasourceName, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent),
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/vpc_endpoint_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ This data source exports the following attributes in addition to the arguments a
* `manages_vpc_endpoints` - Whether or not the service manages its VPC endpoints - `true` or `false`.
* `owner` - AWS account ID of the service owner or `amazon`.
* `private_dns_name` - Private DNS name for the service.
* `private_dns_names` - Private DNS names assigned to the VPC endpoint service.
* `service_id` - ID of the endpoint service.
* `supported_ip_address_types` - The supported IP address types.
* `tags` - Map of tags assigned to the resource.
Expand Down

0 comments on commit 2d0d06b

Please sign in to comment.