terraform-provider-aws: Better Lambda error
When creating a Lambda function, I get
Error: Error creating Lambda function: ValidationException:
status code: 400, request id: 2db74e8f-49b6-4fe7-a005-55ac6afa6d23
I had used role name instead of role ARN. Does the API provide any further detail than status code 400 about the problem? If so, we should display that.
See also https://discuss.hashicorp.com/t/error-creating-lambda-function-validationexception/8192/3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 60
- Comments: 23 (3 by maintainers)
TL;DR I think we have some compatibility problem between AWS SDK/API and the underlying AWS service for Lambda.
Faced with an obvious discrepancy in error reporting by AWS CLI and Terraform, I decided to dig a bit deeper.
Here’s the API response, taken from the Terraform debug log:
Apparently there’s 147 bytes of JSON content, which must be an encoded error message, which the provider needs to extract and return to Terraform. But the provider seems to throw away the error message and then we simply get a “computer says no” in the console:
So I tried to obtain the content of that error message. Running my AWS CLI command with
--debugI got:And if I copy the request parameters from Terraform debug log and stick them into an HTTP client, I get a similar response:
But AWS API for
CreateFunctiondoes not listValidationExceptionamong possible error types. The closest it gets to it isInvalidParameterValueException.Likewise,
aws-sdk-godoes not haveValidationExceptionin the list of generated exception classes for Lambda API, most likely because it is absent from the API schema. An example of API that does supportValidationExceptionand has it in the generated API/SDK is ACM.So I suspect that somehow Lambda service sends back an error type that is not part of the schema for Lambda API, and hence it is not recognised by
aws-sdk-go, which makes it fall back to the default implementation, which does not know how to format the message.Any updates on this. We are facing the same issue, and have no idea why. works in cli, so we need the real error message from terraform.
This may be an upstream issue in the
aws-go-sdkV1 library (see https://github.com/aws/aws-sdk-go/issues/4733 for a complete writeup). In this case, the provider itself is not filtering any messaging returned from theCreateFunctioncall, the additional information just isn’t there.While we await a response on the bug report, we’ll also investigate updating to V2 of the AWS Go SDK for the Lambda function resource.
I’ve had this error for many reasons, and have spent countless hours trying to figure it out each time. Please fix this hashicorp, as lambdas are becoming critical infrastructure, and we need actual error to be able to resolve.
This happens when invoking a lambda from within another lambda
This functionality has been released in v4.56.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!