Skip to content

Commit

Permalink
🧹 Add a safeguard when trying to initialize a lambda function resource
Browse files Browse the repository at this point in the history
Signed-off-by: Preslav <preslav@mondoo.com>
  • Loading branch information
preslavgerchev committed Jun 19, 2024
1 parent 5b8ffd6 commit f0fcc35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions providers/aws/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
conn = connection.NewMockConnection(connId, asset, conf)

case string(awsec2ebsconn.EBSConnectionType):
// An EBS connection is a wrapper around a FilesystemConnection
// To make sure the connection is later handled by the os provider, override the type
conf.Type = "filesystem"
conn, err = awsec2ebsconn.NewAwsEbsConnection(connId, conf, asset)
default:
conn, err = connection.NewAwsConnection(connId, asset, conf)
Expand Down
11 changes: 10 additions & 1 deletion providers/aws/resources/aws_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,18 @@ func initAwsLambdaFunction(runtime *plugin.Runtime, args map[string]*llx.RawData
args["arn"] = llx.StringData(ids.arn)
}
}

name := args["name"]
region := args["region"]
if name == nil {
return nil, nil, errors.New("name required to fetch lambda function")
}
if region == nil {
return nil, nil, errors.New("region required to fetch lambda function")
}
var arnVal string
if args["arn"] == nil {
arnVal = getLambdaArn(args["name"].String(), args["region"].String(), "")
arnVal = getLambdaArn(name.String(), region.String(), "")
if arnVal == "" {
return nil, nil, errors.New("arn required to fetch lambda function")
}
Expand Down

0 comments on commit f0fcc35

Please sign in to comment.