From 529f885845e2bdcf42df69adb8d5ded6d0abaffa Mon Sep 17 00:00:00 2001 From: Aleix Murtra Date: Wed, 2 Aug 2023 10:26:13 +0200 Subject: [PATCH] Support for TGW Attachment Peering resources (#996) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support for removing TGW Attachment Peering resources, as only VPC attachments where supported before. Co-authored-by: Björn Häuser --- 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, }