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

11510 supports setting private_dns_name on resource_aws_vpc_endpoint_… #12246

Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions aws/resource_aws_vpc_endpoint_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func resourceAwsVpcEndpointService() *schema.Resource {
},
"private_dns_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
craigedmunds marked this conversation as resolved.
Show resolved Hide resolved
},
"service_name": {
Expand Down Expand Up @@ -96,6 +97,10 @@ func resourceAwsVpcEndpointServiceCreate(d *schema.ResourceData, meta interface{
TagSpecifications: ec2TagSpecificationsFromMap(d.Get("tags").(map[string]interface{}), "vpc-endpoint-service"),
}

if v, ok := d.GetOk("private_dns_name"); ok {
req.PrivateDnsName = aws.String(v.(string))
}

log.Printf("[DEBUG] Creating VPC Endpoint Service configuration: %#v", req)
resp, err := conn.CreateVpcEndpointServiceConfiguration(req)
if err != nil {
Expand Down
44 changes: 44 additions & 0 deletions aws/resource_aws_vpc_endpoint_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,33 @@ func TestAccAWSVpcEndpointService_basic(t *testing.T) {
})
}

func TestAccAWSVpcEndpointService_PrivateDnsName(t *testing.T) {
var svcCfg ec2.ServiceConfiguration
resourceName := "aws_vpc_endpoint_service.test"
rName1 := acctest.RandomWithPrefix("tf-acc-test")
rName2 := acctest.RandomWithPrefix("tf-acc-test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVpcEndpointServiceDestroy,
Steps: []resource.TestStep{
{
Config: testAccVpcEndpointServiceConfig_privateDnsName(rName1, rName2),
Check: resource.ComposeTestCheckFunc(
testAccCheckVpcEndpointServiceExists(resourceName, &svcCfg),
resource.TestCheckResourceAttr(resourceName, "private_dns_name", "vpce.domain"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSVpcEndpointService_AllowedPrincipals(t *testing.T) {
var svcCfg ec2.ServiceConfiguration
resourceName := "aws_vpc_endpoint_service.test"
Expand Down Expand Up @@ -373,6 +400,23 @@ resource "aws_vpc_endpoint_service" "test" {
`))
}

func testAccVpcEndpointServiceConfig_privateDnsName(rName1, rName2 string) string {
return composeConfig(
testAccVpcEndpointServiceConfig_base(rName1, rName2),
fmt.Sprintf(`
resource "aws_vpc_endpoint_service" "test" {
acceptance_required = true

network_load_balancer_arns = [
"${aws_lb.test1.arn}",
"${aws_lb.test2.arn}",
]

private_dns_name = "vpce.domain"
}
`))
}

func testAccVpcEndpointServiceConfig_allowedPrincipals(rName1, rName2 string) string {
return composeConfig(
testAccVpcEndpointServiceConfig_base(rName1, rName2),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/vpc_endpoint_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The given filters must match exactly one VPC endpoint service whose data will be

* `service` - (Optional) The common name of an AWS service (e.g. `s3`).
* `service_name` - (Optional) The service name that is specified when creating a VPC endpoint. For AWS services the service name is usually in the form `com.amazonaws.<region>.<service>` (the SageMaker Notebook service is an exception to this rule, the service name is in the form `aws.sagemaker.<region>.notebook`).
* `private_dns_name` - (Optional) The private DNS name for the service.
craigedmunds marked this conversation as resolved.
Show resolved Hide resolved
* `filter` - (Optional) Configuration block(s) for filtering. Detailed below.
* `tags` - (Optional) A map of tags, each pair of which must exactly match a pair on the desired VPC Endpoint Service.

Expand All @@ -81,7 +82,6 @@ In addition to all arguments above, the following attributes are exported:
* `base_endpoint_dns_names` - The DNS names for the service.
* `manages_vpc_endpoints` - Whether or not the service manages its VPC endpoints - `true` or `false`.
* `owner` - The AWS account ID of the service owner or `amazon`.
* `private_dns_name` - The private DNS name for the service.
* `service_id` - The ID of the endpoint service.
* `service_type` - The service type, `Gateway` or `Interface`.
* `tags` - A map of tags assigned to the resource.
Expand Down