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

Lambda functions pages #575

Merged
merged 2 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
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-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