Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
feat: transit gateway (#53)
Browse files Browse the repository at this point in the history
* feat: transit gateway

* fix: tgw tests
  • Loading branch information
James Quigley committed Apr 30, 2021
1 parent 83c4c88 commit a92cc96
Show file tree
Hide file tree
Showing 7 changed files with 760 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const DefaultConfigYaml = `
- name: ec2.route_tables
- name: ec2.security_groups
- name: ec2.subnets
- name: ec2.transit_gateways
- name: ec2.vpc_peering_connections
- name: ec2.vpcs
- name: ecs.clusters
Expand Down
70 changes: 70 additions & 0 deletions client/mocks/builders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,76 @@ func buildEc2Subnets(t *testing.T, ctrl *gomock.Controller) client.Services {
}
}

func buildEc2TransitGateways(t *testing.T, ctrl *gomock.Controller) client.Services {
m := mocks.NewMockEc2Client(ctrl)
tgw := ec2Types.TransitGateway{}
err := faker.FakeData(&tgw)
if err != nil {
t.Fatal(err)
}

tgwvpca := ec2Types.TransitGatewayVpcAttachment{}
err = faker.FakeData(&tgwvpca)
if err != nil {
t.Fatal(err)
}

tgwpeera := ec2Types.TransitGatewayPeeringAttachment{}
err = faker.FakeData(&tgwpeera)
if err != nil {
t.Fatal(err)
}

tgwrt := ec2Types.TransitGatewayRouteTable{}
err = faker.FakeData(&tgwrt)
if err != nil {
t.Fatal(err)
}

tgwmcd := ec2Types.TransitGatewayMulticastDomain{}
err = faker.FakeData(&tgwmcd)
if err != nil {
t.Fatal(err)
}

tgwa := ec2Types.TransitGatewayAttachment{}
err = faker.FakeData(&tgwa)
if err != nil {
t.Fatal(err)
}

m.EXPECT().DescribeTransitGatewayVpcAttachments(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&ec2.DescribeTransitGatewayVpcAttachmentsOutput{
TransitGatewayVpcAttachments: []ec2Types.TransitGatewayVpcAttachment{tgwvpca},
}, nil)

m.EXPECT().DescribeTransitGatewayPeeringAttachments(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&ec2.DescribeTransitGatewayPeeringAttachmentsOutput{
TransitGatewayPeeringAttachments: []ec2Types.TransitGatewayPeeringAttachment{tgwpeera},
}, nil)

m.EXPECT().DescribeTransitGatewayRouteTables(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&ec2.DescribeTransitGatewayRouteTablesOutput{
TransitGatewayRouteTables: []ec2Types.TransitGatewayRouteTable{tgwrt},
}, nil)

m.EXPECT().DescribeTransitGatewayMulticastDomains(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&ec2.DescribeTransitGatewayMulticastDomainsOutput{
TransitGatewayMulticastDomains: []ec2Types.TransitGatewayMulticastDomain{tgwmcd},
}, nil)
m.EXPECT().DescribeTransitGatewayAttachments(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&ec2.DescribeTransitGatewayAttachmentsOutput{
TransitGatewayAttachments: []ec2Types.TransitGatewayAttachment{tgwa},
}, nil)
m.EXPECT().DescribeTransitGateways(gomock.Any(), gomock.Any(), gomock.Any()).Return(
&ec2.DescribeTransitGatewaysOutput{
TransitGateways: []ec2Types.TransitGateway{tgw},
}, nil)
return client.Services{
EC2: m,
}
}

func buildEc2Vpcs(t *testing.T, ctrl *gomock.Controller) client.Services {
m := mocks.NewMockEc2Client(ctrl)
l := ec2Types.Vpc{}
Expand Down
5 changes: 5 additions & 0 deletions client/mocks/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func TestResources(t *testing.T) {
mockBuilder: buildEc2Subnets,
mainTable: resources.Ec2Subnets(),
},
{
resource: "ec2.transit_gateways",
mockBuilder: buildEc2TransitGateways,
mainTable: resources.Ec2TransitGateways(),
},
{
resource: "ec2.vpcs",
mockBuilder: buildEc2Vpcs,
Expand Down
120 changes: 120 additions & 0 deletions client/mocks/services.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions client/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,23 @@ type DirectconnectClient interface {
type Ec2Client interface {
DescribeByoipCidrs(ctx context.Context, params *ec2.DescribeByoipCidrsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeByoipCidrsOutput, error)
DescribeCustomerGateways(ctx context.Context, params *ec2.DescribeCustomerGatewaysInput, optFns ...func(*ec2.Options)) (*ec2.DescribeCustomerGatewaysOutput, error)
DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)
DescribeFlowLogs(ctx context.Context, params *ec2.DescribeFlowLogsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeFlowLogsOutput, error)
DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)
DescribeInstances(ctx context.Context, params *ec2.DescribeInstancesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)
DescribeInternetGateways(ctx context.Context, params *ec2.DescribeInternetGatewaysInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInternetGatewaysOutput, error)
DescribeNatGateways(ctx context.Context, params *ec2.DescribeNatGatewaysInput, optFns ...func(*ec2.Options)) (*ec2.DescribeNatGatewaysOutput, error)
DescribeNetworkAcls(ctx context.Context, params *ec2.DescribeNetworkAclsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeNetworkAclsOutput, error)
DescribeSubnets(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)
DescribeVpcs(ctx context.Context, params *ec2.DescribeVpcsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcsOutput, error)
DescribeRouteTables(ctx context.Context, params *ec2.DescribeRouteTablesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRouteTablesOutput, error)
DescribeSecurityGroups(ctx context.Context, params *ec2.DescribeSecurityGroupsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)
DescribeSubnets(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)
DescribeTransitGatewayAttachments(ctx context.Context, params *ec2.DescribeTransitGatewayAttachmentsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTransitGatewayAttachmentsOutput, error)
DescribeTransitGatewayMulticastDomains(ctx context.Context, params *ec2.DescribeTransitGatewayMulticastDomainsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTransitGatewayMulticastDomainsOutput, error)
DescribeTransitGatewayRouteTables(ctx context.Context, params *ec2.DescribeTransitGatewayRouteTablesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTransitGatewayRouteTablesOutput, error)
DescribeTransitGatewayPeeringAttachments(ctx context.Context, params *ec2.DescribeTransitGatewayPeeringAttachmentsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTransitGatewayPeeringAttachmentsOutput, error)
DescribeTransitGateways(ctx context.Context, params *ec2.DescribeTransitGatewaysInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTransitGatewaysOutput, error)
DescribeTransitGatewayVpcAttachments(ctx context.Context, params *ec2.DescribeTransitGatewayVpcAttachmentsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeTransitGatewayVpcAttachmentsOutput, error)
DescribeVpcPeeringConnections(ctx context.Context, params *ec2.DescribeVpcPeeringConnectionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcPeeringConnectionsOutput, error)
DescribeInstances(ctx context.Context, params *ec2.DescribeInstancesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)
DescribeVpcs(ctx context.Context, params *ec2.DescribeVpcsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcsOutput, error)
}

type EcrClient interface {
Expand Down
Loading

0 comments on commit a92cc96

Please sign in to comment.