Skip to content

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

@lewisdan91

Description

@lewisdan91

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions