diff --git a/bin/README.md b/bin/README.md index 0d543bd..34c758f 100644 --- a/bin/README.md +++ b/bin/README.md @@ -10,3 +10,4 @@ Helper scripts. |`check_index.sh` | Check that the index links work, and that every example is mentioned in there | |`check_scripts.sh` | Check that scripts are in each relevant folder and that they are likely to work | |`destroy.sh` | Destroy terraform (add provider as a argument) | +| `clean_up.sh` | Removes all files created by terraform works in conjuction with destroy.sh | diff --git a/bin/clean_up.sh b/bin/clean_up.sh new file mode 100755 index 0000000..b49b5e6 --- /dev/null +++ b/bin/clean_up.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Script to remove all files created by terraform + +cd - || exit 1 + +# Ignoring the file "./backends/remote/.terraformignore" +IGN_FILE=".terraformignore" + +echo "================================================================================" +echo "Removing all the files created by terraform" +echo "================================================================================" +find . -type f \( -name ".terraform.*" -o -name "terraform.*" \) -a ! -name ${IGN_FILE} -delete && find . -type d -name ".terraform" -exec rm -rf {} + diff --git a/bin/destroy.sh b/bin/destroy.sh index a2e84a0..597e845 100755 --- a/bin/destroy.sh +++ b/bin/destroy.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Also deletes all the files created by terraform with this script with conjunction of clean_up.sh + SUPPORTED_PROVIDERS="aws|azurerm|digitalocean|google|kubernetes|linode" if [[ -n "$1" && ! "$1" =~ ${SUPPORTED_PROVIDERS} ]] then @@ -34,3 +36,8 @@ then else terraform destroy -auto-approve fi + +cd "${0%/*}" || exit 1 + +# shellcheck disable=SC1091 +source ./clean_up.sh \ No newline at end of file diff --git a/bin/shared_aws.sh b/bin/shared_aws.sh index 274f2a0..2746548 100644 --- a/bin/shared_aws.sh +++ b/bin/shared_aws.sh @@ -17,7 +17,18 @@ then read -r -s AWS_SECRET_ACCESS_KEY fi +# If someone requires a token for the deployment then please uncomment the following code [`IF block` requesting session token] +# and export AWS_SESSION_TOKEN + +# if [ -z "$AWS_SESSION_TOKEN" ] +# then +# echo "If you want to suppress this input, run 'export AWS_SESSION_TOKEN=' on the command line" +# echo 'Input AWS_SESSION_TOKEN' +# read -r -s AWS_SESSION_TOKEN +# fi + set -o nounset export AWS_ACCESS_KEY_ID export AWS_SECRET_ACCESS_KEY +# export AWS_SESSION_TOKEN