Skip to content

Instantly share code, notes, and snippets.

@alastairmccormack
Created April 23, 2019 17:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastairmccormack/a8c290738145f1c94a86029aca66cb8e to your computer and use it in GitHub Desktop.
Save alastairmccormack/a8c290738145f1c94a86029aca66cb8e to your computer and use it in GitHub Desktop.
One-liner Terraform external command to get current branch (No need to create additional script)
# Branch name accessible via: ${data.external.git-branch.result.branch}
data "external" "git-branch" {
program = ["/bin/bash", "-c", "jq -n --arg branch `git rev-parse --abbrev-ref HEAD` '{\"branch\":$branch}'"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment