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

Commit df499d5

Browse files
authored
Filter main route tables (#953)
* Filter main route table * use `Filter` instead of custom method
1 parent 42a68a3 commit df499d5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

resources/ec2-route-tables.go

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package resources
22

33
import (
4+
"fmt"
5+
46
"github.com/aws/aws-sdk-go/aws/session"
57
"github.com/aws/aws-sdk-go/service/ec2"
68
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
@@ -41,6 +43,16 @@ func ListEC2RouteTables(sess *session.Session) ([]Resource, error) {
4143
return resources, nil
4244
}
4345

46+
func (i *EC2RouteTable) Filter() error {
47+
48+
for _, association := range i.routeTable.Associations {
49+
if *association.Main {
50+
return fmt.Errorf("Main RouteTables cannot be deleted")
51+
}
52+
}
53+
return nil
54+
}
55+
4456
func (e *EC2RouteTable) Remove() error {
4557
params := &ec2.DeleteRouteTableInput{
4658
RouteTableId: e.routeTable.RouteTableId,

0 commit comments

Comments
 (0)