Skip to content

Commit 0fa640e

Browse files
authored
feat: Add support for AWS EC2 VPC Endpoint Connections (#14044)
#### Summary closes: #14030
1 parent 54cecdc commit 0fa640e

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

plugins/source/aws/docs/tables/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
- [aws_ec2_transit_gateway_peering_attachments](../../../../../website/tables/aws/aws_ec2_transit_gateway_peering_attachments.md)
245245
- [aws_ec2_transit_gateway_route_tables](../../../../../website/tables/aws/aws_ec2_transit_gateway_route_tables.md)
246246
- [aws_ec2_transit_gateway_vpc_attachments](../../../../../website/tables/aws/aws_ec2_transit_gateway_vpc_attachments.md)
247+
- [aws_ec2_vpc_endpoint_connections](../../../../../website/tables/aws/aws_ec2_vpc_endpoint_connections.md)
247248
- [aws_ec2_vpc_endpoint_service_configurations](../../../../../website/tables/aws/aws_ec2_vpc_endpoint_service_configurations.md)
248249
- [aws_ec2_vpc_endpoint_services](../../../../../website/tables/aws/aws_ec2_vpc_endpoint_services.md)
249250
- [aws_ec2_vpc_endpoint_service_permissions](../../../../../website/tables/aws/aws_ec2_vpc_endpoint_service_permissions.md)

plugins/source/aws/resources/plugin/tables.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ func getTables() schema.Tables {
282282
ec2.SpotInstanceRequests(),
283283
ec2.Subnets(),
284284
ec2.TransitGateways(),
285+
ec2.VpcEndpointConnections(),
285286
ec2.VpcEndpoints(),
286287
ec2.VpcEndpointServiceConfigurations(),
287288
ec2.VpcEndpointServices(),
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package ec2
2+
3+
import (
4+
"context"
5+
6+
sdkTypes "github.com/cloudquery/plugin-sdk/v4/types"
7+
8+
"github.com/aws/aws-sdk-go-v2/service/ec2"
9+
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
10+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
11+
"github.com/cloudquery/plugin-sdk/v4/schema"
12+
"github.com/cloudquery/plugin-sdk/v4/transformers"
13+
)
14+
15+
func VpcEndpointConnections() *schema.Table {
16+
tableName := "aws_ec2_vpc_endpoint_connections"
17+
return &schema.Table{
18+
Name: tableName,
19+
Description: `https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_VpcEndpointConnection.html`,
20+
Resolver: fetchEc2VpcEndpointConnections,
21+
Multiplex: client.ServiceAccountRegionMultiplexer(tableName, "ec2"),
22+
Transform: transformers.TransformWithStruct(&types.VpcEndpointConnection{}, transformers.WithPrimaryKeys("VpcEndpointConnectionId", "VpcEndpointOwner")),
23+
Columns: []schema.Column{
24+
client.DefaultAccountIDColumn(true),
25+
client.DefaultRegionColumn(true),
26+
{
27+
Name: "tags",
28+
Type: sdkTypes.ExtensionTypes.JSON,
29+
Resolver: client.ResolveTags,
30+
},
31+
},
32+
}
33+
}
34+
func fetchEc2VpcEndpointConnections(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- any) error {
35+
var config ec2.DescribeVpcEndpointConnectionsInput
36+
cl := meta.(*client.Client)
37+
svc := cl.Services(client.AWSServiceEc2).Ec2
38+
// No paginator available
39+
paginator := ec2.NewDescribeVpcEndpointConnectionsPaginator(svc, &config)
40+
41+
for paginator.HasMorePages() {
42+
page, err := paginator.NextPage(ctx, func(options *ec2.Options) {
43+
options.Region = cl.Region
44+
})
45+
if err != nil {
46+
return err
47+
}
48+
res <- page.VpcEndpointConnections
49+
}
50+
return nil
51+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ec2
2+
3+
import (
4+
"testing"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/ec2"
7+
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
8+
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
9+
"github.com/cloudquery/cloudquery/plugins/source/aws/client/mocks"
10+
"github.com/cloudquery/plugin-sdk/v4/faker"
11+
"github.com/golang/mock/gomock"
12+
"github.com/stretchr/testify/require"
13+
)
14+
15+
func buildEc2VpcEndpointConnections(t *testing.T, ctrl *gomock.Controller) client.Services {
16+
m := mocks.NewMockEc2Client(ctrl)
17+
sc := types.VpcEndpointConnection{}
18+
require.NoError(t, faker.FakeObject(&sc))
19+
20+
m.EXPECT().DescribeVpcEndpointConnections(gomock.Any(), gomock.Any(), gomock.Any()).Return(
21+
&ec2.DescribeVpcEndpointConnectionsOutput{
22+
VpcEndpointConnections: []types.VpcEndpointConnection{sc},
23+
}, nil)
24+
return client.Services{
25+
Ec2: m,
26+
}
27+
}
28+
29+
func TestEc2VpcEndpointConnections(t *testing.T) {
30+
client.AwsMockTestHelper(t, VpcEndpointConnections(), buildEc2VpcEndpointConnections, client.TestOptions{})
31+
}

website/pages/docs/plugins/sources/aws/tables.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Table: aws_ec2_vpc_endpoint_connections
2+
3+
This table shows data for Amazon Elastic Compute Cloud (EC2) VPC Endpoint Connections.
4+
5+
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_VpcEndpointConnection.html
6+
7+
The composite primary key for this table is (**account_id**, **region**, **vpc_endpoint_connection_id**, **vpc_endpoint_owner**).
8+
9+
## Columns
10+
11+
| Name | Type |
12+
| ------------- | ------------- |
13+
|_cq_id|`uuid`|
14+
|_cq_parent_id|`uuid`|
15+
|account_id (PK)|`utf8`|
16+
|region (PK)|`utf8`|
17+
|tags|`json`|
18+
|creation_timestamp|`timestamp[us, tz=UTC]`|
19+
|dns_entries|`json`|
20+
|gateway_load_balancer_arns|`list<item: utf8, nullable>`|
21+
|ip_address_type|`utf8`|
22+
|network_load_balancer_arns|`list<item: utf8, nullable>`|
23+
|service_id|`utf8`|
24+
|vpc_endpoint_connection_id (PK)|`utf8`|
25+
|vpc_endpoint_id|`utf8`|
26+
|vpc_endpoint_owner (PK)|`utf8`|
27+
|vpc_endpoint_state|`utf8`|

0 commit comments

Comments
 (0)