terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
885 stars 658 forks source link

Add support for including raw file content in zip #589

Open fheinecke opened 3 days ago

fheinecke commented 3 days ago

Is your request related to a new offering from AWS?

No

Is your request related to a problem? Please describe.

In some bootstrapping situations I need to build a Lambda source file via Terraform and have it included in the Lambda source.

Describe the solution you'd like.

I'd like to be able to specify raw file contents as a source under source_paths. Something like:

source_paths = [
{
  path = "path-in-zip.txt" # This path does not exist on the filesystem
  content = "This is a Terraform-built value that written to `path` inside the zip. It could come from a data source, a template, a literal, or some other Terraform logic."
}
]

This is similar to what the archive_file datasource can do.

Describe alternatives you've considered.

Create a local_file resource and include the path to it. As the documentation for this resource mentions, this is very very noisy in automation as it's recreated on every new machine that Terraform is ran on.

Additional context