Skip to content

Commit

Permalink
feat(ec2-internet-gateway-attachment): filter shared resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Jan 31, 2025
1 parent 12879db commit 5e3b70d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions resources/ec2-internet-gateway-attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package resources

import (
"context"
"errors"
"fmt"

"github.com/gotidy/ptr"
Expand Down Expand Up @@ -77,6 +78,7 @@ func (l *EC2InternetGatewayAttachmentLister) List(_ context.Context, o interface

type EC2InternetGatewayAttachment struct {
svc *ec2.EC2
accountID *string
vpcID *string
vpcOwnerID *string
vpcTags []*ec2.Tag
Expand All @@ -86,6 +88,14 @@ type EC2InternetGatewayAttachment struct {
defaultVPC bool
}

func (r *EC2InternetGatewayAttachment) Filter() error {
if ptr.ToString(r.igwOwnerID) != ptr.ToString(r.accountID) {
return errors.New("not owned by account, likely shared")
}

return nil
}

func (r *EC2InternetGatewayAttachment) Remove(_ context.Context) error {
params := &ec2.DetachInternetGatewayInput{
VpcId: r.vpcID,
Expand Down

0 comments on commit 5e3b70d

Please sign in to comment.