Created
August 21, 2023 09:32
-
-
Save huevos-y-bacon/66b756dfb3825529e5691b8ff0e8f5aa to your computer and use it in GitHub Desktop.
Terraform - Prepare local provider cache for Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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