Skip to content

Commit

Permalink
Merge pull request #16544 from hashicorp/b-lambda-code-signing-read
Browse files Browse the repository at this point in the history
r/lambda_function: update lambda package type check to prevent panic
  • Loading branch information
anGie44 authored Jan 19, 2021
2 parents 69e824e + 6a4fe8e commit 027fd40
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions aws/resource_aws_lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,26 +809,25 @@ func resourceAwsLambdaFunctionRead(d *schema.ResourceData, meta interface{}) err
return nil
}

codeSigningConfigInput := &lambda.GetFunctionCodeSigningConfigInput{
FunctionName: aws.String(d.Get("function_name").(string)),
}

// Code Signing is only supported on zip packaged lambda functions.
if *function.PackageType == lambda.PackageTypeZip {
var codeSigningConfigArn string

if aws.StringValue(function.PackageType) == lambda.PackageTypeZip {
codeSigningConfigInput := &lambda.GetFunctionCodeSigningConfigInput{
FunctionName: aws.String(d.Id()),
}
getCodeSigningConfigOutput, err := conn.GetFunctionCodeSigningConfig(codeSigningConfigInput)
if err != nil {
return fmt.Errorf("error getting Lambda Function (%s) code signing config %w", d.Id(), err)
}

if getCodeSigningConfigOutput == nil || getCodeSigningConfigOutput.CodeSigningConfigArn == nil {
d.Set("code_signing_config_arn", "")
} else {
d.Set("code_signing_config_arn", getCodeSigningConfigOutput.CodeSigningConfigArn)
if getCodeSigningConfigOutput != nil {
codeSigningConfigArn = aws.StringValue(getCodeSigningConfigOutput.CodeSigningConfigArn)
}
} else {
d.Set("code_signing_config_arn", "")
}

d.Set("code_signing_config_arn", codeSigningConfigArn)

return nil
}

Expand Down

0 comments on commit 027fd40

Please sign in to comment.