Skip to content

Commit de7274d

Browse files
isumegiimre-sumegi
authored andcommitted
CB-29626 - CloudHaunter could not delete some VPCs and load balancers with dependencies
1 parent 2a0791a commit de7274d

2 files changed

Lines changed: 228 additions & 8 deletions

File tree

aws/aws.go

Lines changed: 126 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,8 @@ func (p awsProvider) TerminateResources(resources *types.ResourceContainer) []er
535535
log.Debug("[AWS] Delete resources")
536536
elbClients := p.getElbClientsByRegion()
537537
ec2Clients, _ := p.getEc2AndCTClientsByRegion()
538+
deleteLoadBalancersErr := deleteLoadBalancers(elbClients, ec2Clients, resources.Get(p.GetCloudType()))
538539
deleteVpcsErr := deleteVpcs(ec2Clients, resources.Get(p.GetCloudType()))
539-
deleteLoadBalancersErr := deleteLoadBalancers(elbClients, resources.Get(p.GetCloudType()))
540540
return append(deleteVpcsErr, deleteLoadBalancersErr...)
541541
}
542542

@@ -580,7 +580,7 @@ func deleteVpcs(ec2Clients map[string]ec2Client, resources []*types.Resource) []
580580
return errs
581581
}
582582

583-
func deleteLoadBalancers(elbClients map[string]elbClient, resources []*types.Resource) []error {
583+
func deleteLoadBalancers(elbClients map[string]elbClient, ec2Clients map[string]ec2Client, resources []*types.Resource) []error {
584584
regionLoadBalancers := map[string][]*types.Resource{}
585585
for _, resource := range resources {
586586
if resource.ResourceType == types.LoadBalancer {
@@ -593,7 +593,7 @@ func deleteLoadBalancers(elbClients map[string]elbClient, resources []*types.Res
593593
wg.Add(len(regionLoadBalancers))
594594

595595
for r, lb := range regionLoadBalancers {
596-
go func(region string, elbClient elbClient, loadBalancers []*types.Resource) {
596+
go func(region string, elbClient elbClient, ec2Client ec2Client, loadBalancers []*types.Resource) {
597597
defer wg.Done()
598598
for _, loadBalancer := range loadBalancers {
599599
if ctx.DryRun {
@@ -603,6 +603,23 @@ func deleteLoadBalancers(elbClients map[string]elbClient, resources []*types.Res
603603
if elbExistsErr != nil {
604604
errChan <- elbExistsErr
605605
} else if elbExists {
606+
log.Infof("[AWS] Deleting endpoint services of load balancer: %s in region: %s", loadBalancer.ID, region)
607+
endpointServices, err := ec2Client.DescribeVpcEndpointServiceConfigurations(&ec2.DescribeVpcEndpointServiceConfigurationsInput{})
608+
if err != nil {
609+
log.Errorf("[AWS] Failed to list endpoint services of load balancer: %s, err: %s", loadBalancer.ID, err)
610+
errChan <- err
611+
}
612+
for _, endpointService := range endpointServices.ServiceConfigurations {
613+
if containsID(endpointService.NetworkLoadBalancerArns, &loadBalancer.ID) {
614+
_, err = ec2Client.DeleteVpcEndpointServiceConfigurations(&ec2.DeleteVpcEndpointServiceConfigurationsInput{
615+
ServiceIds: []*string{endpointService.ServiceId},
616+
})
617+
if err != nil {
618+
log.Errorf("[AWS] Failed to delete endpoint service: %s, err: %s", *endpointService.ServiceId, err)
619+
errChan <- err
620+
}
621+
}
622+
}
606623
deleteErr := deleteLoadBalancer(elbClient, "N/A", loadBalancer.ID, region)
607624
if deleteErr != nil {
608625
errChan <- deleteErr
@@ -612,7 +629,7 @@ func deleteLoadBalancers(elbClients map[string]elbClient, resources []*types.Res
612629
}
613630
}
614631
}
615-
}(r, elbClients[r], lb)
632+
}(r, elbClients[r], ec2Clients[r], lb)
616633
}
617634

618635
go func() {
@@ -711,7 +728,7 @@ func (p awsProvider) StopInstances(instances *types.InstanceContainer) []error {
711728
for _, inst := range instanceChunk {
712729
if inst.Ephemeral {
713730
// could be that the instance is already removed due to failed suspend API call
714-
if containsInstanceID(instanceIDs, &inst.ID) {
731+
if containsID(instanceIDs, &inst.ID) {
715732
log.Infof("[AWS] Spot instance will be terminated: %s:%s", inst.ID, instIDNames[inst.ID])
716733
spotInstanceIDs = append(spotInstanceIDs, &inst.ID)
717734
instanceIDs = removeInstance(instanceIDs, &inst.ID)
@@ -1094,6 +1111,56 @@ func deleteVpcWithDependencies(ec2Client ec2Client, stackName string, vpcId stri
10941111
}
10951112
}
10961113

1114+
log.Infof("[AWS] Deleting NAT gateways of VPC: %s in stack: %s, region: %s", vpcId, stackName, region)
1115+
1116+
natGateways, err := ec2Client.DescribeNatGateways(&ec2.DescribeNatGatewaysInput{
1117+
Filter: []*ec2.Filter{vpcIdFilter},
1118+
})
1119+
1120+
if err != nil {
1121+
log.Errorf("[AWS] Failed to list NAT gateways of VPC: %s in stack: %s, err: %s", vpcId, stackName, err)
1122+
return err
1123+
}
1124+
for _, natGateway := range natGateways.NatGateways {
1125+
_, err = ec2Client.DeleteNatGateway(&ec2.DeleteNatGatewayInput{
1126+
NatGatewayId: natGateway.NatGatewayId,
1127+
})
1128+
if err != nil {
1129+
log.Errorf("[AWS] Failed to delete NAT gateway: %s in stack: %s, err: %s", *natGateway.NatGatewayId, stackName, err)
1130+
return err
1131+
}
1132+
}
1133+
1134+
log.Infof("[AWS] Deleting network interface IDs of VPC: %s in stack: %s, region: %s", vpcId, stackName, region)
1135+
1136+
networkInterfaceIds, err := ec2Client.DescribeNetworkInterfaces(&ec2.DescribeNetworkInterfacesInput{
1137+
Filters: []*ec2.Filter{vpcIdFilter},
1138+
})
1139+
1140+
if err != nil {
1141+
log.Errorf("[AWS] Failed to list network interface IDs of VPC: %s in stack: %s, err: %s", vpcId, stackName, err)
1142+
return err
1143+
}
1144+
for _, eni := range networkInterfaceIds.NetworkInterfaces {
1145+
if eni.Attachment != nil && eni.Attachment.AttachmentId != nil {
1146+
_, err = ec2Client.DetachNetworkInterface(&ec2.DetachNetworkInterfaceInput{
1147+
AttachmentId: eni.Attachment.AttachmentId,
1148+
Force: aws.Bool(true),
1149+
})
1150+
if err != nil {
1151+
log.Errorf("[AWS] Failed to detach network interface ID: %s in stack: %s, err: %s", *eni.NetworkInterfaceId, stackName, err)
1152+
return err
1153+
}
1154+
}
1155+
_, err = ec2Client.DeleteNetworkInterface(&ec2.DeleteNetworkInterfaceInput{
1156+
NetworkInterfaceId: eni.NetworkInterfaceId,
1157+
})
1158+
if err != nil {
1159+
log.Errorf("[AWS] Failed to delete network interface ID: %s in stack: %s, err: %s", *eni.NetworkInterfaceId, stackName, err)
1160+
return err
1161+
}
1162+
}
1163+
10971164
log.Infof("[AWS] Deleting internet gateways of VPC: %s in stack: %s, region: %s", vpcId, stackName, region)
10981165

10991166
attachmentVpcIdFilter := &ec2.Filter{}
@@ -1126,6 +1193,26 @@ func deleteVpcWithDependencies(ec2Client ec2Client, stackName string, vpcId stri
11261193
}
11271194
}
11281195

1196+
log.Infof("[AWS] Deleting egress-only internet gateways of VPC: %s in stack: %s, region: %s", vpcId, stackName, region)
1197+
1198+
eigws, err := ec2Client.DescribeEgressOnlyInternetGateways(&ec2.DescribeEgressOnlyInternetGatewaysInput{
1199+
Filters: []*ec2.Filter{attachmentVpcIdFilter},
1200+
})
1201+
if err != nil {
1202+
log.Errorf("[AWS] Failed to list egress-only internet gateways of VPC: %s in stack: %s, err: %s", vpcId, stackName, err)
1203+
return err
1204+
}
1205+
1206+
for _, eigw := range eigws.EgressOnlyInternetGateways {
1207+
_, err = ec2Client.DeleteEgressOnlyInternetGateway(&ec2.DeleteEgressOnlyInternetGatewayInput{
1208+
EgressOnlyInternetGatewayId: eigw.EgressOnlyInternetGatewayId,
1209+
})
1210+
if err != nil {
1211+
log.Errorf("[AWS] Failed to delete egress-only internet gateway: %s in stack: %s, err: %s", *eigw.EgressOnlyInternetGatewayId, stackName, err)
1212+
return err
1213+
}
1214+
}
1215+
11291216
log.Infof("[AWS] Deleting route tables of VPC: %s in stack: %s, region: %s", vpcId, stackName, region)
11301217

11311218
rts, err := ec2Client.DescribeRouteTables(&ec2.DescribeRouteTablesInput{
@@ -1214,9 +1301,30 @@ func deleteVpcWithDependencies(ec2Client ec2Client, stackName string, vpcId stri
12141301
log.Errorf("[AWS] Failed to list security groups of VPC: %s in stack: %s, err: %s", vpcId, stackName, err)
12151302
return err
12161303
}
1304+
for _, securityGroup := range securityGroups.SecurityGroups {
1305+
if len(securityGroup.IpPermissions) > 0 {
1306+
_, err := ec2Client.RevokeSecurityGroupIngress(&ec2.RevokeSecurityGroupIngressInput{
1307+
GroupId: securityGroup.GroupId,
1308+
IpPermissions: securityGroup.IpPermissions,
1309+
})
1310+
if err != nil {
1311+
log.Errorf("[AWS] Failed to revoke ingress rules for security group: %s in stack: %s, err: %s", *securityGroup.GroupId, stackName, err)
1312+
return err
1313+
}
1314+
}
1315+
if len(securityGroup.IpPermissionsEgress) > 0 {
1316+
_, err := ec2Client.RevokeSecurityGroupEgress(&ec2.RevokeSecurityGroupEgressInput{
1317+
GroupId: securityGroup.GroupId,
1318+
IpPermissions: securityGroup.IpPermissionsEgress,
1319+
})
1320+
if err != nil {
1321+
log.Errorf("[AWS] Failed to revoke egress rules for security group: %s in stack: %s, err: %s", *securityGroup.GroupId, stackName, err)
1322+
return err
1323+
}
1324+
}
1325+
}
12171326
for _, securityGroup := range securityGroups.SecurityGroups {
12181327
if *securityGroup.GroupName == "default" {
1219-
// the default subnet can not be deleted
12201328
continue
12211329
}
12221330
_, err = ec2Client.DeleteSecurityGroup(&ec2.DeleteSecurityGroupInput{
@@ -1580,24 +1688,35 @@ type ec2Client interface {
15801688
DetachVolume(input *ec2.DetachVolumeInput) (*ec2.VolumeAttachment, error)
15811689
DescribeVpcs(input *ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error)
15821690
DescribeVpcEndpoints(input *ec2.DescribeVpcEndpointsInput) (*ec2.DescribeVpcEndpointsOutput, error)
1691+
DescribeVpcEndpointServiceConfigurations(input *ec2.DescribeVpcEndpointServiceConfigurationsInput) (*ec2.DescribeVpcEndpointServiceConfigurationsOutput, error)
15831692
DeleteVpcEndpoints(input *ec2.DeleteVpcEndpointsInput) (*ec2.DeleteVpcEndpointsOutput, error)
1693+
DeleteVpcEndpointServiceConfigurations(input *ec2.DeleteVpcEndpointServiceConfigurationsInput) (*ec2.DeleteVpcEndpointServiceConfigurationsOutput, error)
15841694
DeleteVpc(input *ec2.DeleteVpcInput) (*ec2.DeleteVpcOutput, error)
15851695
DescribeSubnets(input *ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error)
15861696
DeleteSubnet(input *ec2.DeleteSubnetInput) (*ec2.DeleteSubnetOutput, error)
15871697
DescribeInternetGateways(input *ec2.DescribeInternetGatewaysInput) (*ec2.DescribeInternetGatewaysOutput, error)
1698+
DescribeEgressOnlyInternetGateways(input *ec2.DescribeEgressOnlyInternetGatewaysInput) (*ec2.DescribeEgressOnlyInternetGatewaysOutput, error)
1699+
DescribeNatGateways(input *ec2.DescribeNatGatewaysInput) (*ec2.DescribeNatGatewaysOutput, error)
1700+
DescribeNetworkInterfaces(input *ec2.DescribeNetworkInterfacesInput) (*ec2.DescribeNetworkInterfacesOutput, error)
15881701
DetachInternetGateway(input *ec2.DetachInternetGatewayInput) (*ec2.DetachInternetGatewayOutput, error)
1702+
DetachNetworkInterface(input *ec2.DetachNetworkInterfaceInput) (*ec2.DetachNetworkInterfaceOutput, error)
15891703
DeleteInternetGateway(input *ec2.DeleteInternetGatewayInput) (*ec2.DeleteInternetGatewayOutput, error)
1704+
DeleteEgressOnlyInternetGateway(input *ec2.DeleteEgressOnlyInternetGatewayInput) (*ec2.DeleteEgressOnlyInternetGatewayOutput, error)
15901705
DescribeRouteTables(input *ec2.DescribeRouteTablesInput) (*ec2.DescribeRouteTablesOutput, error)
15911706
DeleteRouteTable(input *ec2.DeleteRouteTableInput) (*ec2.DeleteRouteTableOutput, error)
1707+
DeleteNatGateway(input *ec2.DeleteNatGatewayInput) (*ec2.DeleteNatGatewayOutput, error)
15921708
DescribeNetworkAcls(input *ec2.DescribeNetworkAclsInput) (*ec2.DescribeNetworkAclsOutput, error)
15931709
DeleteNetworkAcl(input *ec2.DeleteNetworkAclInput) (*ec2.DeleteNetworkAclOutput, error)
1710+
DeleteNetworkInterface(input *ec2.DeleteNetworkInterfaceInput) (*ec2.DeleteNetworkInterfaceOutput, error)
15941711
DescribeSecurityGroups(input *ec2.DescribeSecurityGroupsInput) (*ec2.DescribeSecurityGroupsOutput, error)
15951712
DeleteSecurityGroup(input *ec2.DeleteSecurityGroupInput) (*ec2.DeleteSecurityGroupOutput, error)
15961713
DisassociateRouteTable(input *ec2.DisassociateRouteTableInput) (*ec2.DisassociateRouteTableOutput, error)
15971714
TerminateInstances(input *ec2.TerminateInstancesInput) (*ec2.TerminateInstancesOutput, error)
15981715
WaitUntilInstanceTerminated(input *ec2.DescribeInstancesInput) error
15991716
DescribeAddresses(input *ec2.DescribeAddressesInput) (*ec2.DescribeAddressesOutput, error)
16001717
ReleaseAddress(input *ec2.ReleaseAddressInput) (*ec2.ReleaseAddressOutput, error)
1718+
RevokeSecurityGroupIngress(input *ec2.RevokeSecurityGroupIngressInput) (*ec2.RevokeSecurityGroupIngressOutput, error)
1719+
RevokeSecurityGroupEgress(input *ec2.RevokeSecurityGroupEgressInput) (*ec2.RevokeSecurityGroupEgressOutput, error)
16011720
}
16021721

16031722
type cfClient interface {
@@ -2412,7 +2531,7 @@ func removeInstance(originalIDs []*string, instanceID *string) (instanceIDs []*s
24122531
return
24132532
}
24142533

2415-
func containsInstanceID(instanceIDs []*string, instanceID *string) bool {
2534+
func containsID(instanceIDs []*string, instanceID *string) bool {
24162535
found := false
24172536
for _, ID := range instanceIDs {
24182537
if *ID == *instanceID {

aws/aws_test.go

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,15 @@ func TestDeleteVpcs(t *testing.T) {
218218

219219
assert.Equal(t, "DescribeVpcEndpoints", <-operationChannel)
220220
assert.Equal(t, "DeleteVpcEndpoints:vpc-endpoint-id-1,vpc-endpoint-id-2", <-operationChannel)
221+
assert.Equal(t, "DescribeNatGateways", <-operationChannel)
222+
assert.Equal(t, "DeleteNatGateway:ngw-id-1", <-operationChannel)
223+
assert.Equal(t, "DescribeNetworkInterfaces", <-operationChannel)
224+
assert.Equal(t, "DeleteNetworkInterface:eni-id-1", <-operationChannel)
221225
assert.Equal(t, "DescribeInternetGateways", <-operationChannel)
222226
assert.Equal(t, "DetachInternetGateway:igw1", <-operationChannel)
223227
assert.Equal(t, "DeleteInternetGateway:igw1", <-operationChannel)
228+
assert.Equal(t, "DescribeEgressOnlyInternetGateways", <-operationChannel)
229+
assert.Equal(t, "DeleteEgressOnlyInternetGateway:eigw-id-1", <-operationChannel)
224230
assert.Equal(t, "DescribeRouteTables", <-operationChannel)
225231
assert.Equal(t, "DeleteRouteTable:routeTable1", <-operationChannel)
226232
assert.Equal(t, "DescribeSubnets", <-operationChannel)
@@ -271,6 +277,9 @@ func TestDeleteLoadBalancers(t *testing.T) {
271277
elbClients := map[string]elbClient{
272278
"eu-central-1": mockElbClient{operationChannel: operationChannel},
273279
}
280+
ec2Clients := map[string]ec2Client{
281+
"eu-central-1": mockEc2Client{operationChannel: operationChannel},
282+
}
274283
lbs := []*types.Resource{
275284
{
276285
ID: "lb-1",
@@ -287,10 +296,12 @@ func TestDeleteLoadBalancers(t *testing.T) {
287296
go func() {
288297
defer close(operationChannel)
289298

290-
deleteLoadBalancers(elbClients, lbs)
299+
deleteLoadBalancers(elbClients, ec2Clients, lbs)
291300
}()
292301

293302
assert.Equal(t, "ModifyLoadBalancerAttributes:lb-1", <-operationChannel)
303+
assert.Equal(t, "DescribeVpcEndpointServiceConfigurations", <-operationChannel)
304+
assert.Equal(t, "DeleteVpcEndpointServiceConfigurations:service-id-1", <-operationChannel)
294305
assert.Equal(t, "DeleteLoadBalancer:lb-1", <-operationChannel)
295306
}
296307

@@ -333,9 +344,15 @@ func TestRemoveCfStack(t *testing.T) {
333344
assert.Equal(t, "ModifyDBInstance", <-operationChannel)
334345
assert.Equal(t, "DescribeVpcEndpoints", <-operationChannel)
335346
assert.Equal(t, "DeleteVpcEndpoints:vpc-endpoint-id-1,vpc-endpoint-id-2", <-operationChannel)
347+
assert.Equal(t, "DescribeNatGateways", <-operationChannel)
348+
assert.Equal(t, "DeleteNatGateway:ngw-id-1", <-operationChannel)
349+
assert.Equal(t, "DescribeNetworkInterfaces", <-operationChannel)
350+
assert.Equal(t, "DeleteNetworkInterface:eni-id-1", <-operationChannel)
336351
assert.Equal(t, "DescribeInternetGateways", <-operationChannel)
337352
assert.Equal(t, "DetachInternetGateway:igw1", <-operationChannel)
338353
assert.Equal(t, "DeleteInternetGateway:igw1", <-operationChannel)
354+
assert.Equal(t, "DescribeEgressOnlyInternetGateways", <-operationChannel)
355+
assert.Equal(t, "DeleteEgressOnlyInternetGateway:eigw-id-1", <-operationChannel)
339356
assert.Equal(t, "DescribeRouteTables", <-operationChannel)
340357
assert.Equal(t, "DeleteRouteTable:routeTable1", <-operationChannel)
341358
assert.Equal(t, "DescribeSubnets", <-operationChannel)
@@ -509,6 +526,21 @@ func (t mockEc2Client) DetachInternetGateway(input *ec2.DetachInternetGatewayInp
509526
return nil, nil
510527
}
511528

529+
func (t mockEc2Client) DetachNetworkInterface(input *ec2.DetachNetworkInterfaceInput) (*ec2.DetachNetworkInterfaceOutput, error) {
530+
t.operationChannel <- "DetachNetworkInterface:" + *input.AttachmentId
531+
return nil, nil
532+
}
533+
534+
func (t mockEc2Client) RevokeSecurityGroupEgress(input *ec2.RevokeSecurityGroupEgressInput) (*ec2.RevokeSecurityGroupEgressOutput, error) {
535+
t.operationChannel <- "RevokeSecurityGroupEgress:" + *input.GroupId
536+
return nil, nil
537+
}
538+
539+
func (t mockEc2Client) RevokeSecurityGroupIngress(input *ec2.RevokeSecurityGroupIngressInput) (*ec2.RevokeSecurityGroupIngressOutput, error) {
540+
t.operationChannel <- "RevokeSecurityGroupIngress:" + *input.GroupId
541+
return nil, nil
542+
}
543+
512544
func (t mockEc2Client) DetachVolume(input *ec2.DetachVolumeInput) (*ec2.VolumeAttachment, error) {
513545
t.operationChannel <- "DetachVolume"
514546
return nil, nil
@@ -599,6 +631,30 @@ func (t mockEc2Client) DeleteInternetGateway(input *ec2.DeleteInternetGatewayInp
599631
return nil, nil
600632
}
601633

634+
func (t mockEc2Client) DeleteEgressOnlyInternetGateway(input *ec2.DeleteEgressOnlyInternetGatewayInput) (*ec2.DeleteEgressOnlyInternetGatewayOutput, error) {
635+
t.operationChannel <- "DeleteEgressOnlyInternetGateway:" + *input.EgressOnlyInternetGatewayId
636+
return nil, nil
637+
}
638+
639+
func (t mockEc2Client) DeleteNatGateway(input *ec2.DeleteNatGatewayInput) (*ec2.DeleteNatGatewayOutput, error) {
640+
t.operationChannel <- "DeleteNatGateway:" + *input.NatGatewayId
641+
return nil, nil
642+
}
643+
644+
func (t mockEc2Client) DeleteNetworkInterface(input *ec2.DeleteNetworkInterfaceInput) (*ec2.DeleteNetworkInterfaceOutput, error) {
645+
t.operationChannel <- "DeleteNetworkInterface:" + *input.NetworkInterfaceId
646+
return nil, nil
647+
}
648+
649+
func (t mockEc2Client) DeleteVpcEndpointServiceConfigurations(input *ec2.DeleteVpcEndpointServiceConfigurationsInput) (*ec2.DeleteVpcEndpointServiceConfigurationsOutput, error) {
650+
ids := []string{}
651+
for _, id := range input.ServiceIds {
652+
ids = append(ids, *id)
653+
}
654+
t.operationChannel <- "DeleteVpcEndpointServiceConfigurations:" + strings.Join(ids, ",")
655+
return nil, nil
656+
}
657+
602658
func (t mockEc2Client) DeleteNetworkAcl(input *ec2.DeleteNetworkAclInput) (*ec2.DeleteNetworkAclOutput, error) {
603659
t.operationChannel <- "DeleteNetworkAcl:" + *input.NetworkAclId
604660
return nil, nil
@@ -623,6 +679,51 @@ func (t mockEc2Client) DescribeSubnets(input *ec2.DescribeSubnetsInput) (*ec2.De
623679
}, nil
624680
}
625681

682+
func (t mockEc2Client) DescribeEgressOnlyInternetGateways(input *ec2.DescribeEgressOnlyInternetGatewaysInput) (*ec2.DescribeEgressOnlyInternetGatewaysOutput, error) {
683+
t.operationChannel <- "DescribeEgressOnlyInternetGateways"
684+
return &ec2.DescribeEgressOnlyInternetGatewaysOutput{
685+
EgressOnlyInternetGateways: []*ec2.EgressOnlyInternetGateway{
686+
{
687+
EgressOnlyInternetGatewayId: &(&types.S{S: "eigw-id-1"}).S,
688+
},
689+
},
690+
}, nil
691+
}
692+
693+
func (t mockEc2Client) DescribeNatGateways(input *ec2.DescribeNatGatewaysInput) (*ec2.DescribeNatGatewaysOutput, error) {
694+
t.operationChannel <- "DescribeNatGateways"
695+
return &ec2.DescribeNatGatewaysOutput{
696+
NatGateways: []*ec2.NatGateway{
697+
{
698+
NatGatewayId: &(&types.S{S: "ngw-id-1"}).S,
699+
},
700+
},
701+
}, nil
702+
}
703+
704+
func (t mockEc2Client) DescribeNetworkInterfaces(input *ec2.DescribeNetworkInterfacesInput) (*ec2.DescribeNetworkInterfacesOutput, error) {
705+
t.operationChannel <- "DescribeNetworkInterfaces"
706+
return &ec2.DescribeNetworkInterfacesOutput{
707+
NetworkInterfaces: []*ec2.NetworkInterface{
708+
{
709+
NetworkInterfaceId: &(&types.S{S: "eni-id-1"}).S,
710+
},
711+
},
712+
}, nil
713+
}
714+
715+
func (t mockEc2Client) DescribeVpcEndpointServiceConfigurations(input *ec2.DescribeVpcEndpointServiceConfigurationsInput) (*ec2.DescribeVpcEndpointServiceConfigurationsOutput, error) {
716+
t.operationChannel <- "DescribeVpcEndpointServiceConfigurations"
717+
return &ec2.DescribeVpcEndpointServiceConfigurationsOutput{
718+
ServiceConfigurations: []*ec2.ServiceConfiguration{
719+
{
720+
ServiceId: &(&types.S{S: "service-id-1"}).S,
721+
NetworkLoadBalancerArns: []*string{&(&types.S{S: "lb-1"}).S},
722+
},
723+
},
724+
}, nil
725+
}
726+
626727
func (t mockEc2Client) DeleteSubnet(input *ec2.DeleteSubnetInput) (*ec2.DeleteSubnetOutput, error) {
627728
t.operationChannel <- "DeleteSubnet:" + *input.SubnetId
628729
return nil, nil

0 commit comments

Comments
 (0)