Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Maintain Parent Directory of source_dir #66

Open
jerroydmoore opened this issue Mar 27, 2020 · 2 comments
Open

Feature Request: Maintain Parent Directory of source_dir #66

jerroydmoore opened this issue Mar 27, 2020 · 2 comments

Comments

@jerroydmoore
Copy link

Trying to create a lambda layer consisting of just the ./node_modules fails, because the zip file created strips away the node_module parent directory (example). Ideally, source_dir should maintain the parent directory structure and allow you to strip away the parent directory using a value such as ./path/to/dir/**, but this would not be backwards compatible. Ways this could be solved without breaking backwards compatibility would be to add an ignore attribute that would be a regex, a target_dir attribute that would set the name of the parent directory inside of the zip file, or a boolean attribute save_parent_dir to copy the parent directory structure as well.

Terraform Version

Terraform v0.12.24
+ provider.archive v1.3.0
+ provider.aws v2.54.0

Affected Resource(s)

  • data.archive_file

Terraform Configuration Files

data "archive_file" "node_modules" {
  type        = "zip"
  output_path = "./.cache/${var.name}_node_module.zip"
  source_dir  = "${var.source_dir}/node_modules"
}
@beanaroo
Copy link

Is there a known workaround for this?

I was expecting source_dir to preserve the directory when not providing a trailing /. In other words:

  • /my/path/node_modules - produces a zip with node_modules at the root
  • /my/path/node_modules/ - produces a zip with the contents of node_modules at the root

In my case, I'm trying to add a python package to a zip, preserving the package parent directory.

@delwaterman
Copy link

This is also a problem when you use source blocks:

data "http" "this" {
  # ...
}

data "archive_file" "this" {
  type        = "zip"
  output_path = "${path.root}/zipfiles"

  source {
    content  = data.http.this.body
    filename = "my-certs/cert-ca.pem"
  }
}

will place the cert file at the root of the zip package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants