terraform-provider-archive icon indicating copy to clipboard operation
terraform-provider-archive copied to clipboard

Feature Request: multiple files and directories handled properly

Open buchs opened this issue 6 years ago • 4 comments

Use Case: I need to build a zip archive to upload to AWS Lambda. Because I am using the NodeJS platform, my zip will typically contain one source file and the node_modules directory. I cannot build this via the file_archive provider. I would like to be able to use this HCL:

data "archive_file" "lambdaCode" {
   type = "zip"
   source_file = "lambda_process_firewall_updates.js"
   source_dir = "node_modules"
   output_path = "${var.lambda_zip}"
}

Of course, you can only have one of source_file and source_dir. I have other files in the source file directory and so I want to exclude them all (not one-by-one).

I looked at the provider code, and it seems like the archive platform in Go needs to be used in a way where it keeps the archive open as you loop over the source* arguments. Not terrible and I thought that might be something I could do, but it is enough work for me to pick up Go again to where it will have to be saved for a rainy day.

buchs avatar Jan 10 '19 15:01 buchs

I have a case for a python lambda where I have more than one file in the src directory

  • lambda_function.py
  • utils.py
  • something.py

When I use archive_file with source_dir="src", it creates a folder and then places the files inside it. I just need it to zip the files inside src without making a folder for them. Is there way I can achieve it?

Please refer https://github.com/terraform-providers/terraform-provider-aws/issues/10653 for more details.

sanspace avatar Nov 18 '19 20:11 sanspace

Any chance to get this implemented?

simonweil avatar Jul 05 '22 08:07 simonweil

Same here

Luis-3M avatar Dec 19 '23 11:12 Luis-3M

This would be really needed. I can also see there are multiple pr-s trying to solve this issue. Could we somehow push this?

RipplB avatar Dec 21 '23 10:12 RipplB