Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Add a safeguard when trying to initialize a lambda function resource #4268

Merged
merged 1 commit into from
Jun 19, 2024
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
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
Loading