hashicorp / terraform-provider-archive

Utility provider that provides a data source that can create zip archives for individual files or collections of files.
https://registry.terraform.io/providers/hashicorp/archive/latest/docs
Mozilla Public License 2.0
89 stars 62 forks source link

Error generating archive with archive_file when symlink is present and exclude_symlink_directories is set to true #296

Closed sm0ke21 closed 7 months ago

sm0ke21 commented 8 months ago

Terraform CLI and Provider Versions

Terraform v1.6.6 on linux_amd64

Terraform Configuration

data "archive_file" "admin_zip" {
  type                        = "zip"
  source_dir                  = "${path.module}/../lambda/admin_api/src"
  output_file_mode            = "0666"
  exclude_symlink_directories = true
  output_path                 = "${path.module}/../lambda/admin_api/out/admin.zip"
}

Expected Behavior

I expect a zip file in output_path containing everything in source_dir

Actual Behavior

I get the following error:

│ Error: Archive creation error
│ 
│   with data.archive_file.admin_zip,
│   on lambda.tf line 20, in data "archive_file" "admin_zip":
│   20: data "archive_file" "admin_zip" {
│ 
│ error creating archive: error archiving directory: error reading file for archival: read ../lambda/admin_api/src/commonlib: is a directory

Steps to Reproduce

  1. terraform plan

How much impact is this issue causing?

High

Logs

https://gist.github.com/sm0ke21/c1371dede8e6e288da456854582d7a00

Additional Information

There is a symlink inside admin_api/src called commonlib linking to common python libraries. If the symlink is removed then terraform plan works.

I expected this to not fail since exclude_symlink_directories is set to true.

Code of Conduct

sm0ke21 commented 8 months ago

commonlib is a valid symlink

bendbennett commented 7 months ago

@sm0ke21 this bug should be fixed in v2.4.2:

github-actions[bot] commented 3 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.