Skip to content

Instantly share code, notes, and snippets.

@huevos-y-bacon
Created August 21, 2023 09:32
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 huevos-y-bacon/66b756dfb3825529e5691b8ff0e8f5aa to your computer and use it in GitHub Desktop.
Save huevos-y-bacon/66b756dfb3825529e5691b8ff0e8f5aa to your computer and use it in GitHub Desktop.
Prepare local provider cache for Terraform
#!/usr/bin/env bash
[[ ! "$(uname -s)" == "Darwin" ]] && NOCOLOR=1 # Disable color output if not macOS
mkdir -p "${HOME}"/.terraform.d/plugin-cache # Create local plugin cache folder if not exists
ecco(){
if [[ -n "${NOCOLOR}" ]]; then echo -e "${*}"
else
echo -e "\033[0;1;3;32m${*}\033[0m" # echo green bold and italics
fi
}
RC=${HOME}/.terraformrc
if [[ -f "${RC}" ]]; then ecco "Backup ${RC} to ${RC}.bak ..."; mv "${RC}" "${RC}".bak; fi
ecco "Create ${RC}:\n"
echo "plugin_cache_dir = \"${HOME}/.terraform.d/plugin-cache\"
disable_checkpoint = true" > "${RC}" && \
cat "${RC}"
ecco "\nDone"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment