Skip to content

Commit

Permalink
updated .envrc
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed Jul 14, 2024
1 parent 2029a61 commit b8c0d2e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
# https://www.linkedin.com/in/HariSekhon
#

# ============================================================================ #
# T e r r a f o r m D i r E n v
# ============================================================================ #

set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
#srcdir="$(dirname "${BASH_SOURCE[0]}")"

# XXX: beware that tfenv and tgswitch replace the terraform / terragrunt in the path and this is a race condition between different shells
# it is not as good as the KUBECONFIG trick done in the .envrc-kubernetes

# would auto-determine the version from the state file, but this commands seems to always return the version of your local binary pulling the state file, not the version from the actual terraform_version field in state file if you see when opening it up in the cloud bucket
# terraform state pull | jq -r .terraform_version
export TERRAFORM_VERSION=1.1.9
Expand All @@ -25,6 +32,14 @@ export TERRAFORM_VERSION=1.1.9
export TFENV_TERRAFORM_VERSION="$TERRAFORM_VERSION"
export TFENV_AUTO_INSTALL=true

# Terragrunt
export TG_VERSION=0.39.2

# if tgswitch is installed, trigger it to use the above TF_VERSION environment variable and switch to the correct version of Terragrunt
if type -P tgswitch &>/dev/null; then
tgswitch
fi

# XXX: set these or other variables for Terraform code to find
export CLOUDFLARE_EMAIL=hari@...
export CLOUDFLARE_API_KEY=... # generate here: https://dash.cloudflare.com/profile/api-tokens
Expand All @@ -35,9 +50,6 @@ export TF_VAR_cloudflare_email="$CLOUDFLARE_EMAIL"
export TF_VAR_cloudflare_api_key="$CLOUDFLARE_API_KEY" # must be a key, not a token using the link above

# GITHUB_* environment variables may interfere with GitHub provider, so unset them
#for env_var in $(env | sed 's/GITHUB_TOKEN|GH_TOKEN/d' | awk -F= '$1 ~ /GITHUB/ {print $1}'); do
# unset "$env_var"
#done

#export GITHUB_OWNER=
#export GITHUB_ORGANIZATION=
for env_var in $(env | awk -F= '$1 ~ /GITHUB/ {print $1}'); do
unset "$env_var"
done

0 comments on commit b8c0d2e

Please sign in to comment.