Giter Site home page Giter Site logo

Comments (5)

RichardBradley avatar RichardBradley commented on July 4, 2024 1

Thanks, that workaround fixes this for me!

from terraform-provider-archive.

RichardBradley avatar RichardBradley commented on July 4, 2024

I have a similar or the same issue.
I am creating a zip file for a Lambda with code like this:

data "archive_file" "my_lambda_zip" {
  type        = "zip"
  output_path = "${path.root}/.terraform/tmp/my_lambda.zip"
  source_file = "${path.module}/my-src.js"
}

The "my-src.js" file is a regular file in git:

$ git ls-files -s my-src.js
100644 8ef1d00576701a5cbd7c07c0f5496131b4554b43 0       my-src.js

On unix, the output of the "archive_file" is a zip containing a 644 / "-rw-r--r--" file:

$ zipinfo my_lambda.zip
Archive:  my_lambda.zip
Zip file size: 1064 bytes, number of entries: 1
-rw-r--r--  2.0 unx     2001 bl defN 49-Jan-01 00:00 my-src.js
1 file, 2001 bytes uncompressed, 876 bytes compressed:  56.2%

On windows, the file permissions are different:

zipinfo my_lambda.zip
Archive:  my_lambda.zip
Zip file size: 1064 bytes, number of entries: 1
-rw-rw-rw-  2.0 unx     2001 bl defN 49-Jan-01 00:00 my-src.js
1 file, 2001 bytes uncompressed, 876 bytes compressed:  56.2%

This causes Terraform to unnecessarily mark the Lambda as changed, as I am using "filebase64sha256" on the zip, which differs by this one byte.

How can I persuade archive_file to generate a 644/"-rw-r--r--" file on Windows (or indeed a 666/"-rw-rw-rw-" file on Unix)?

Thanks

from terraform-provider-archive.

RichardBradley avatar RichardBradley commented on July 4, 2024

It looks like the code that handles this reads the file perms using Go's "os.stat" at archiver.go:28 and hands that file mode off directly to Go's zip.FileInfoHeader at zip_archiver.go:56.

According to this blog, Go will always report either 666 or 444 file mode on Windows. Whereas the actual permissions on unix are typically 644.

So without a windows-specific workaround to archive_file, I will need to arrange for my file to be 666 on unix to make my builds consistent cross-platform.

from terraform-provider-archive.

RichardBradley avatar RichardBradley commented on July 4, 2024

It looks like git won't allow me to make the file 666 mode, only 644 or 755 (cite).
So I'm going to struggle to get this to behave the same on unix and windows without some kind of helper script

from terraform-provider-archive.

kmoe avatar kmoe commented on July 4, 2024

The workaround in #90 has been released in terraform-provider-archive v2.2.0. If output_file_mode does not solve your problem, please comment on this issue or open a new one.

from terraform-provider-archive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.