AWS Builder Center

CloudFormation and Terraform for realistic, "shareable" AWS Lambda test events

With "shareable" AWS Lambda test events, multiple developers can test Lambda functions realistically, not just locally. Here's how to create shareable AWS Lambda test events in CloudFormation and Terraform, because the official documentation only covers manual creation, not infrastructure-as-code.

I thought I'd share CloudFormation source code (and Terraform references) for creating "shareable" AWS Lambda test events…
  • Introduced in 2022, this way of distributing sample events so that multiple developers can test Lambda functions realistically, not locally, hasn't received much attention. The documentation only covers manual creation, not infrastructure-as-code.
  • The  lambda-testevent-schemas  registry serves every Lambda function in an AWS account and region, so you've got to be able to create it conditionally, and it has to survive the deletion of your project. In CloudFormation, set   DeletionPolicy   and  UpdateReplacePolicy  to  Retain  . In Terraform, consider a   removed   block with  destroy = false  .
  • The required naming convention for schemas in this registry is  _LambdaFunctionName-schema  , where LambdaFunctionName is your function's name. The leading underscore and the trailing  -schema  are required.
  • In case it's not clear, each of your tests is a key in the  examples  object. The rest of the JSON blob stays the same.
  • Test events for your internal projects will be more specific than my example, and won't need editing. Test execution can be automated but extra keys with instructions for humans might be useful nevertheless.
Let me know in the comments how you handle Lambda testing…
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article