How can I zip a folder via `archive_file` Terraform

Viewed 1493

I am using terraform to zip a folder as below code.

data "archive_file" "src" {
  type        = "zip"
  source_dir  = "dist"
  output_path = ".build/src.zip"
}

It creates the zip file src.zip in .build directory. But the src.zip doesn't include the root folder which is dist. How can I zip the folder include the folder itself?

1 Answers

So currently you're zipping a folder structure that looks like this:

dist
    ...

Is there anything stopping you from zipping a folder structure that looks like this?

my_archive_file_target
    dist
        ...
Related