Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added clean_up.sh, changes to destroy.sh and shared_aws.sh #188

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
13 changes: 13 additions & 0 deletions bin/clean_up.sh
Original file line number Diff line number Diff line change
@@ -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 {} +
7 changes: 7 additions & 0 deletions bin/destroy.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,3 +36,8 @@ then
else
terraform destroy -auto-approve
fi

cd "${0%/*}" || exit 1

# shellcheck disable=SC1091
source ./clean_up.sh
11 changes: 11 additions & 0 deletions bin/shared_aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=<YOUR_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