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

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

Closed
1 task done
sm0ke21 opened this issue Jan 13, 2024 · 3 comments · Fixed by #298
Labels

Comments

@sm0ke21
Copy link

sm0ke21 commented Jan 13, 2024

Terraform CLI and Provider Versions

Terraform v1.6.6
on linux_amd64

  • provider registry.terraform.io/hashicorp/archive v2.4.1
  • provider registry.terraform.io/hashicorp/aws v5.32.1
  • provider registry.terraform.io/hashicorp/random v3.6.0

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

  • I agree to follow this project's Code of Conduct
@sm0ke21 sm0ke21 added the bug label Jan 13, 2024
@sm0ke21
Copy link
Author

sm0ke21 commented Jan 13, 2024

commonlib is a valid symlink

bendbennett added a commit that referenced this issue Jan 15, 2024
bendbennett added a commit that referenced this issue Jan 23, 2024
* Fix generation of archives when using exclude_symlink_directories (#296)

* Adding change log entries (#296)

* Return error when generating an archive would result in an empty archive (#296)

* Adding equivalent test coverage for archive_file resource (#296)
@bendbennett
Copy link
Contributor

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants