Skip to content

Commit

Permalink
Add computed 'owner_id' attribute to VPC Endpoint resource and data s…
Browse files Browse the repository at this point in the history
…ource.
  • Loading branch information
Kit Ewbank authored and Kit Ewbank committed Jun 10, 2019
1 parent d5f72ee commit cb4eeb2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aws/data_source_aws_vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions aws/data_source_aws_vpc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions aws/resource_aws_vpc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"),
),
},
{
Expand All @@ -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"),
),
},
{
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"),
),
},
{
Expand All @@ -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"),
),
},
{
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/vpc_endpoint.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/vpc_endpoint.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cb4eeb2

Please sign in to comment.