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

Commit

Permalink
Lambda functions pages (#575)
Browse files Browse the repository at this point in the history
* added properties to ec2 network ACL

* can scan/delete > 50 lf with ListFunctionsPages
  • Loading branch information
mrkenkeller authored Nov 24, 2020
1 parent 928f315 commit 640ca7d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions resources/ec2-network-acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (

"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/rebuy-de/aws-nuke/pkg/types"
)

type EC2NetworkACL struct {
svc *ec2.EC2
id *string
isDefault *bool
tags []*ec2.Tag
}

func init() {
Expand All @@ -32,6 +34,7 @@ func ListEC2NetworkACLs(sess *session.Session) ([]Resource, error) {
svc: svc,
id: out.NetworkAclId,
isDefault: out.IsDefault,
tags: out.Tags,
})
}

Expand Down Expand Up @@ -59,6 +62,15 @@ func (e *EC2NetworkACL) Remove() error {
return nil
}

func (f *EC2NetworkACL) Properties() types.Properties {
properties := types.NewProperties()
for _, tag := range f.tags {
properties.SetTag(tag.Key, tag.Value)
}
properties.Set("ID", f.id)
return properties
}

func (e *EC2NetworkACL) String() string {
return *e.id
}
13 changes: 11 additions & 2 deletions resources/lambda-functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,23 @@ func init() {
func ListLambdaFunctions(sess *session.Session) ([]Resource, error) {
svc := lambda.New(sess)

functions := make([]*lambda.FunctionConfiguration, 0)

params := &lambda.ListFunctionsInput{}
resp, err := svc.ListFunctions(params)

err := svc.ListFunctionsPages(params, func(page *lambda.ListFunctionsOutput, lastPage bool) bool {
for _, out := range page.Functions {
functions = append(functions, out)
}
return true
})

if err != nil {
return nil, err
}

resources := make([]Resource, 0)
for _, function := range resp.Functions {
for _, function := range functions {
tags, err := svc.ListTags(&lambda.ListTagsInput{
Resource: function.FunctionArn,
})
Expand Down

0 comments on commit 640ca7d

Please sign in to comment.