Skip to content

sort files in cloudformation package when creating zip for consistency #10122

Open
tef-ger-florian-juettner wants to merge 1 commit intoaws:developfrom
tef-ger-florian-juettner:cloudformation-package-zipfile-sorting
Open

sort files in cloudformation package when creating zip for consistency #10122
tef-ger-florian-juettner wants to merge 1 commit intoaws:developfrom
tef-ger-florian-juettner:cloudformation-package-zipfile-sorting

Conversation

@tef-ger-florian-juettner
Copy link

@tef-ger-florian-juettner tef-ger-florian-juettner commented Mar 12, 2026

Sort files when zipping in cloudformation package

This change updates the make_zip function in artifact_exporter.py to sort
directories and files before adding them to the ZIP archive.
make_zip relies on os.walk() for file collection, and its iteration order
depends on the underlying filesystem. Since the package's S3 key is derived
from the hash of the final ZIP file, sorting the inputs increases determinism
when the source content is identical and helps avoid unnecessary deployments.

Note: This change affects only file ordering. Other ZIP metadata like mtime and
file permissions is also influencing the resulting hash code, but can be
controlled externally by the user before invoking the package command. This
keeps the change minimal and non-intrusive while still giving users additional
control over determinism when needed.

Partially addresses #3131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant