diff --git a/aws/resource_aws_lambda_function.go b/aws/resource_aws_lambda_function.go index 1486b02f4f9..8a97ea45f71 100644 --- a/aws/resource_aws_lambda_function.go +++ b/aws/resource_aws_lambda_function.go @@ -1315,7 +1315,7 @@ func expandLambdaFileSystemConfigs(fscMaps []interface{}) []*lambda.FileSystemCo func flattenLambdaImageConfig(response *lambda.ImageConfigResponse) []map[string]interface{} { settings := make(map[string]interface{}) - if response == nil || response.Error != nil { + if response == nil || response.Error != nil || response.ImageConfig == nil { return nil } diff --git a/aws/resource_aws_lambda_function_test.go b/aws/resource_aws_lambda_function_test.go index 262dce47fc6..19fa4057c28 100644 --- a/aws/resource_aws_lambda_function_test.go +++ b/aws/resource_aws_lambda_function_test.go @@ -3140,3 +3140,9 @@ resource "aws_lambda_function" "test" { } `, rName, runtime)) } + +func TestFlattenLambdaImageConfigShouldNotFailWithEmptyImageConfig(t *testing.T) { + t.Parallel() + response := lambda.ImageConfigResponse{} + flattenLambdaImageConfig(&response) +}