From b0d033fbe11e18eb66bd1185b3449ea5b8cc165c Mon Sep 17 00:00:00 2001 From: alemuro Date: Tue, 9 May 2023 16:17:35 +0200 Subject: [PATCH] Support for TGW Attachment Peering resources Support for removing TGW Attachment Peering resources, as only VPC attachments where supported before. --- resources/ec2-tgw-attachments.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resources/ec2-tgw-attachments.go b/resources/ec2-tgw-attachments.go index ca7dc3696..84cae7559 100644 --- a/resources/ec2-tgw-attachments.go +++ b/resources/ec2-tgw-attachments.go @@ -52,6 +52,21 @@ func (e *EC2TGWAttachment) Remove() error { // as part of TGW to delete VPN attachments. return fmt.Errorf("VPN attachment") } + + // Execute different API calls depending on the resource type. + if *e.tgwa.ResourceType == "peering" { + params := &ec2.DeleteTransitGatewayPeeringAttachmentInput{ + TransitGatewayAttachmentId: e.tgwa.TransitGatewayAttachmentId, + } + + _, err := e.svc.DeleteTransitGatewayPeeringAttachment(params) + if err != nil { + return err + } + + return nil + } + params := &ec2.DeleteTransitGatewayVpcAttachmentInput{ TransitGatewayAttachmentId: e.tgwa.TransitGatewayAttachmentId, }