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

CFT lambda conversion nil pointer check to avoid panic #1260

Merged
merged 1 commit into from
May 19, 2022
Merged
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
17 changes: 13 additions & 4 deletions pkg/mapper/iac-providers/cft/config/lambda-function.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,28 @@ func getServerlessConfig(sf *serverless.Function) []AWSResourceConfig {
}

func setServerlessCodePackage(cf LambdaFunctionConfig, f *serverless.Function) LambdaFunctionConfig {
if f == nil {
return cf
}

if f.ImageUri != "" {
cf.ImageURI = f.ImageUri
return cf
}

if *f.CodeUri.String != "" && !strings.HasPrefix(*f.CodeUri.String, "s3") {
if f.CodeUri != nil && f.CodeUri.String != nil &&
*f.CodeUri.String != "" && !strings.HasPrefix(*f.CodeUri.String, "s3") {
cf.FileName = *f.CodeUri.String
return cf
}

cf.S3Bucket = f.CodeUri.S3Location.Bucket
cf.S3Key = f.CodeUri.S3Location.Key
cf.S3ObjectVersion = strconv.Itoa(f.CodeUri.S3Location.Version)
if f.CodeUri != nil && f.CodeUri.S3Location != nil {
cf.S3Bucket = f.CodeUri.S3Location.Bucket
cf.S3Key = f.CodeUri.S3Location.Key
cf.S3ObjectVersion = strconv.Itoa(f.CodeUri.S3Location.Version)

}

return cf
}

Expand Down