diff --git a/aws/data_source_aws_vpc_endpoint.go b/aws/data_source_aws_vpc_endpoint.go index 5b22bd94567d..d09812b3813b 100644 --- a/aws/data_source_aws_vpc_endpoint.go +++ b/aws/data_source_aws_vpc_endpoint.go @@ -47,6 +47,10 @@ func dataSourceAwsVpcEndpoint() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, + "owner_id": { + Type: schema.TypeString, + Computed: true, + }, "policy": { Type: schema.TypeString, Computed: true, @@ -176,6 +180,7 @@ func dataSourceAwsVpcEndpointRead(d *schema.ResourceData, meta interface{}) erro if err != nil { return fmt.Errorf("error setting network_interface_ids: %s", err) } + d.Set("owner_id", vpce.OwnerId) policy, err := structure.NormalizeJsonString(aws.StringValue(vpce.PolicyDocument)) if err != nil { return fmt.Errorf("policy contains an invalid JSON: %s", err) diff --git a/aws/data_source_aws_vpc_endpoint_test.go b/aws/data_source_aws_vpc_endpoint_test.go index e34065c56293..1bfccb09b5b4 100644 --- a/aws/data_source_aws_vpc_endpoint_test.go +++ b/aws/data_source_aws_vpc_endpoint_test.go @@ -29,6 +29,7 @@ func TestAccDataSourceAwsVpcEndpoint_gatewayBasic(t *testing.T) { resource.TestCheckResourceAttr(datasourceName, "private_dns_enabled", "false"), resource.TestCheckResourceAttr(datasourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(datasourceName, "tags.%", "0"), + testAccCheckResourceAttrAccountID(datasourceName, "owner_id"), ), }, }, @@ -56,6 +57,7 @@ func TestAccDataSourceAwsVpcEndpoint_byId(t *testing.T) { resource.TestCheckResourceAttr(datasourceName, "private_dns_enabled", "false"), resource.TestCheckResourceAttr(datasourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(datasourceName, "tags.%", "0"), + testAccCheckResourceAttrAccountID(datasourceName, "owner_id"), ), }, }, @@ -84,6 +86,7 @@ func TestAccDataSourceAwsVpcEndpoint_gatewayWithRouteTableAndTags(t *testing.T) resource.TestCheckResourceAttr(datasourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(datasourceName, "tags.%", "1"), resource.TestCheckResourceAttr(datasourceName, "tags.Name", rName), + testAccCheckResourceAttrAccountID(datasourceName, "owner_id"), ), }, }, @@ -112,6 +115,7 @@ func TestAccDataSourceAwsVpcEndpoint_interface(t *testing.T) { resource.TestCheckResourceAttr(datasourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(datasourceName, "tags.%", "1"), resource.TestCheckResourceAttr(datasourceName, "tags.Name", rName), + testAccCheckResourceAttrAccountID(datasourceName, "owner_id"), ), }, }, diff --git a/aws/resource_aws_vpc_endpoint.go b/aws/resource_aws_vpc_endpoint.go index dc7ab25b4db6..86c2434f8850 100644 --- a/aws/resource_aws_vpc_endpoint.go +++ b/aws/resource_aws_vpc_endpoint.go @@ -56,6 +56,10 @@ func resourceAwsVpcEndpoint() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, + "owner_id": { + Type: schema.TypeString, + Computed: true, + }, "policy": { Type: schema.TypeString, Optional: true, @@ -247,6 +251,7 @@ func resourceAwsVpcEndpointRead(d *schema.ResourceData, meta interface{}) error if err != nil { return fmt.Errorf("error setting network_interface_ids: %s", err) } + d.Set("owner_id", vpce.OwnerId) policy, err := structure.NormalizeJsonString(aws.StringValue(vpce.PolicyDocument)) if err != nil { return fmt.Errorf("policy contains an invalid JSON: %s", err) diff --git a/aws/resource_aws_vpc_endpoint_test.go b/aws/resource_aws_vpc_endpoint_test.go index f3b5974a7aa7..01bb046cd27d 100644 --- a/aws/resource_aws_vpc_endpoint_test.go +++ b/aws/resource_aws_vpc_endpoint_test.go @@ -104,6 +104,7 @@ func TestAccAWSVpcEndpoint_gatewayBasic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "private_dns_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, }, @@ -139,6 +140,7 @@ func TestAccAWSVpcEndpoint_gatewayWithRouteTableAndPolicyAndTags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.Environment", "test"), resource.TestCheckResourceAttr(resourceName, "tags.Usage", "original"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, { @@ -157,6 +159,7 @@ func TestAccAWSVpcEndpoint_gatewayWithRouteTableAndPolicyAndTags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), resource.TestCheckResourceAttr(resourceName, "tags.Usage", "changed"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, { @@ -254,6 +257,7 @@ func TestAccAWSVpcEndpoint_interfaceBasic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "private_dns_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, }, @@ -285,6 +289,7 @@ func TestAccAWSVpcEndpoint_interfaceWithSubnetAndSecurityGroup(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, { @@ -301,6 +306,7 @@ func TestAccAWSVpcEndpoint_interfaceWithSubnetAndSecurityGroup(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "private_dns_enabled", "true"), resource.TestCheckResourceAttr(resourceName, "requester_managed", "false"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, { @@ -338,6 +344,7 @@ func TestAccAWSVpcEndpoint_interfaceNonAWSService(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "state", "available"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), ), }, }, diff --git a/website/docs/d/vpc_endpoint.html.markdown b/website/docs/d/vpc_endpoint.html.markdown index 6759291f2778..360fcf631f74 100644 --- a/website/docs/d/vpc_endpoint.html.markdown +++ b/website/docs/d/vpc_endpoint.html.markdown @@ -43,6 +43,7 @@ In addition to all arguments above, the following attributes are exported: * `cidr_blocks` - The list of CIDR blocks for the exposed AWS service. Applicable for endpoints of type `Gateway`. * `dns_entry` - The DNS entries for the VPC Endpoint. Applicable for endpoints of type `Interface`. DNS blocks are documented below. * `network_interface_ids` - One or more network interfaces for the VPC Endpoint. Applicable for endpoints of type `Interface`. +* `owner_id` - The ID of the AWS account that owns the VPC endpoint. * `policy` - The policy document associated with the VPC Endpoint. Applicable for endpoints of type `Gateway`. * `prefix_list_id` - The prefix list ID of the exposed AWS service. Applicable for endpoints of type `Gateway`. * `private_dns_enabled` - Whether or not the VPC is associated with a private hosted zone - `true` or `false`. Applicable for endpoints of type `Interface`. diff --git a/website/docs/r/vpc_endpoint.html.markdown b/website/docs/r/vpc_endpoint.html.markdown index 03c6d8c06f84..9a96bea1774f 100644 --- a/website/docs/r/vpc_endpoint.html.markdown +++ b/website/docs/r/vpc_endpoint.html.markdown @@ -123,6 +123,7 @@ In addition to all arguments above, the following attributes are exported: * `cidr_blocks` - The list of CIDR blocks for the exposed AWS service. Applicable for endpoints of type `Gateway`. * `dns_entry` - The DNS entries for the VPC Endpoint. Applicable for endpoints of type `Interface`. DNS blocks are documented below. * `network_interface_ids` - One or more network interfaces for the VPC Endpoint. Applicable for endpoints of type `Interface`. +* `owner_id` - The ID of the AWS account that owns the VPC endpoint. * `prefix_list_id` - The prefix list ID of the exposed AWS service. Applicable for endpoints of type `Gateway`. * `requester_managed` - Whether or not the VPC Endpoint is being managed by its service - `true` or `false`. * `state` - The state of the VPC endpoint.