This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Terraform module that creates consistent .zip archives across different operating systems (Linux/Windows) using Python. It solves cross-platform checksum inconsistencies by normalizing file attributes and line endings.
The module consists of three main components:
-
main.tf: Terraform configuration that uses the
externaldata source to invoke the Python script and expose outputs (zip_pathandbase64sha256) -
archive.py: Python script that:
- Accepts JSON input via stdin with
source_dirandoutput_path - Recursively walks the source directory
- Normalizes Windows line endings to Unix (
\r\n→\n) - Creates deterministic zip files with fixed timestamps (1980-01-01) and permissions
- Returns JSON output with zip metadata including base64-encoded SHA256 hash
- Accepts JSON input via stdin with
- The Python script ensures deterministic zip creation by:
- Setting fixed timestamps on all files
- Using consistent file permissions (0o777)
- Sorting files before adding to the archive
- Converting line endings to Unix format
- Compatible with both Python 2 and Python 3
- The module is typically used with AWS Lambda deployments to ensure consistent
source_code_hashvalues
To test the archive generation:
echo '{"source_dir": "path/to/source", "output_path": "output.zip"}' | python archive.py