{"id":15546815,"url":"https://github.com/bboe/deterministic_zip","last_synced_at":"2025-07-31T03:40:03.755Z","repository":{"id":49346274,"uuid":"172574620","full_name":"bboe/deterministic_zip","owner":"bboe","description":"A tool to generate consistent zip files (useful for terraform updates of aws lambda functions).","archived":false,"fork":false,"pushed_at":"2021-07-17T06:44:01.000Z","size":15,"stargazers_count":63,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T02:01:50.107Z","etag":null,"topics":["aws-lambda","terraform","zip"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bboe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-25T19:55:22.000Z","updated_at":"2025-03-26T01:57:59.000Z","dependencies_parsed_at":"2022-09-02T17:33:59.761Z","dependency_job_id":null,"html_url":"https://github.com/bboe/deterministic_zip","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bboe%2Fdeterministic_zip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bboe%2Fdeterministic_zip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bboe%2Fdeterministic_zip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bboe%2Fdeterministic_zip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bboe","download_url":"https://codeload.github.com/bboe/deterministic_zip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688569,"owners_count":21145766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","terraform","zip"],"created_at":"2024-10-02T13:04:54.340Z","updated_at":"2025-04-14T12:52:48.698Z","avatar_url":"https://github.com/bboe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deterministic_zip\n\nA tool to generate consistent zip files.\n\nThis tool was specifically built to prevent zip file changes from triggering\nAWS Lambda function updates when running `terraform apply`. Before this change,\nevery re-build of the zipfile would result in a different zip, even if its\ncontents had not changed.\n\n## Requirements\n\nThis tool currently only runs on python3.7+ in order to use deflate compression\nlevel 9.\n\n## Installation\n\n```sh\npip install deterministic_zip\n```\n\n## Creating a deterministic_zip\n\nRun the following, and verify that your zip produces the same sha256 hash:\n\n```sh\necho \"The first file.\" \u003e first\necho \"The second file.\" \u003e second\ndeterministic_zip archive.zip first second\nsha256sum archive.zip\n```\n\nIf you have `\\n` line endings the result should be:\n\n    3afbd7c9b42bd5539ffd5c40499d3d1825157ed83791dce8d7ff2694189d28d6\n\nIf you have `\\r\\n` line endings (Windows) the result should be:\n\n    40e16270d62f15e7a192e88b1b301fa6540c86e7e897036b56be513341d376ed\n\n\n## How does it work?\n\nGreat question! There are three tricks to building a deterministic zip:\n\n1) Files must be added to the zip in the same order. Directory iteration order\n   may vary across machines, resulting in different zips. `deterministic_zip`\n   sorts all files before adding them to the zip archive.\n\n2) Files in the zip must have consistent timestamps. If I share a directory to\n   another machine, the timestamps of individual files may differ, despite\n   having identical content. To achieve timestamp consistency,\n   `deterministic_zip` sets the timestamp of all added files to `2019-01-01\n   00:00:00`.\n\n3) Files in the zip must have consistent permissions. File permissions look\n   like `-rw-r--r--` for a file that is readable by all users, and only\n   writable by the user who owns the file. Similarly executable files might\n   have permissions that look like: `-rwxr-xr-x` or\n   `-rwx------`. `deterministic_zip` sets the permission of all files added to\n   the archive to either `-r--r--r--`, or `-r-xr-xr-x`. The latter is only used\n   when the user running `deterministic_zip` has execute access on the file.\n\n\n__Note__: `deterministic_zip` does not modify nor update timestamps of any\nfiles it adds to archives. The techniques used above apply only to the copies\nof files within archives `deterministic_zip` creates.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbboe%2Fdeterministic_zip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbboe%2Fdeterministic_zip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbboe%2Fdeterministic_zip/lists"}