Skip to content

Instantly share code, notes, and snippets.

@isaiahtaylor
Created July 8, 2021 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaiahtaylor/7242200adaa6fef53c1c2e25a900f384 to your computer and use it in GitHub Desktop.
Save isaiahtaylor/7242200adaa6fef53c1c2e25a900f384 to your computer and use it in GitHub Desktop.
Hash a directory for Terraform external data source
#!/usr/bin/env bash
set -e
eval "$(jq -r '@sh "DIRECTORY=\(.directory)"')"
HASH=$(git ls-files --exclude-standard -os ${DIRECTORY} | git hash-object --stdin)
echo "{\"checksum\": \"${HASH}\"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment