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

Filter main route tables #953

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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