Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Filter main route tables (#953)
Browse files Browse the repository at this point in the history
* Filter main route table
* use `Filter` instead of custom method
  • Loading branch information
leighpascoe authored Aug 15, 2023
1 parent 42a68a3 commit df499d5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions resources/ec2-route-tables.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package resources

import (
"fmt"

"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
Expand Down Expand Up @@ -41,6 +43,16 @@ func ListEC2RouteTables(sess *session.Session) ([]Resource, error) {
return resources, nil
}

func (i *EC2RouteTable) Filter() error {

for _, association := range i.routeTable.Associations {
if *association.Main {
return fmt.Errorf("Main RouteTables cannot be deleted")
}
}
return nil
}

func (e *EC2RouteTable) Remove() error {
params := &ec2.DeleteRouteTableInput{
RouteTableId: e.routeTable.RouteTableId,
Expand Down

0 comments on commit df499d5

Please sign in to comment.