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

New tar archive sets file perms and last modified timestamps incorrectly #370

Open
1 task done
lewisdan91 opened this issue Sep 18, 2024 · 0 comments
Open
1 task done
Labels

Comments

@lewisdan91
Copy link

lewisdan91 commented Sep 18, 2024

Terraform CLI and Provider Versions

Terraform v1.8.3
hashicorp/archive version 2.6.0

Terraform Configuration

data "archive_file" "create_tar" {
  type        = "tar.gz"
  output_path = "mytar.tgz"
  output_file_mode = 0644

  source {
    content  = local_file.bundle_json.content
    filename = local.bundle
  }

  source {
    content  = data.local_file.main_js.content
    filename = local.main_js
  }
}

Expected Behavior

Files inside tar should have correct file permissions and retain last modified timestamps.

Actual Behavior

If output_file_mode is set, random file perms and incorrect last modified timestamps are shown:

$ tar -xvf mytar.tgz 
bundle.json
main.js
$ ls -l
total 32
--w----r-- 1 daniel users    83 Jan  1  1970 bundle.json
--w----r-- 1 daniel users 12746 Jan  1  1970 main.js
-rw-r--r-- 1 daniel users  3929 Sep 18 14:05 mytar.tgz

If no output_file_mode is set no file perms are set and incorrect last modified timestamps are shown:

$ tar -xvf mytar.tgz 
bundle.json
main.js
$ ls -l
total 32
---------- 1 daniel users    83 Jan  1  1970 bundle.json
---------- 1 daniel users 12746 Jan  1  1970 main.js
-rw-r--r-- 1 daniel users  3922 Sep 18 14:03 mytar.tgz

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lewisdan91 lewisdan91 added the bug label Sep 18, 2024
lewisdan91 added a commit to lewisdan91/terraform-provider-archive that referenced this issue Sep 18, 2024
- Preserve original file permissions when archiving
- Apply output_file_mode to archive file only
- Add parseFileMode function for consistent mode parsing
- Set default mode (0644) for content without specified permissions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant