-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A couple util scripts * Doc
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
# This is script is simply a shortcut to the pre-commit hook command that I always forget when I clone this repo. | ||
# The pre-commit hook in ./hooks will automatically run terraform fmt on all terraform files in the repo. | ||
git config set core.hooksPath ./hooks |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
### WARNING: THIS IS A POTENTIALLY DANGEROUS SCRIPT. | ||
### MAKE SURE YOU ARE IN THE CORRECT ENVIRONMENT BEFORE RUNNING | ||
|
||
### This script is intended to do a terragrunt init --reconfigure on all folders in the env/$ENVIRONMENT directory | ||
|
||
runCommand() | ||
{ | ||
CMD=$1 | ||
eval "$CMD" | ||
if [ $? != 0 ]; then | ||
echo -e "{${RED} ERROR: Command: \"$CMD\" Failed. Halting." | ||
exit 1 | ||
fi | ||
} | ||
|
||
toApply="common,ecr,ses_receiving_emails,dns,ses_validation_dns_entries,cloudfront,eks,elasticache,rds,lambda-api,lambda-admin-pr,performance-test,heartbeat,database-tools,lambda-google-cidr,ses_to_sqs_email_callbacks,sns_to_sqs_sms_callbacks" | ||
|
||
ENVIRONMENT=$1 | ||
VARFILE=$2 | ||
|
||
IFS=', ' read -r -a folders <<< "$toApply" | ||
|
||
echo "This script will iterate through all terraform folders and auto upgrade and apply." | ||
echo -e "${YELLOW}The target environment is: ${BYELLOW} $ENVIRONMENT" | ||
echo -e "${YELLOW}Your current kubernetes context is ${BYELLOW} $AWS_PROFILE" | ||
echo "****VERIFY YOUR CONTEXT IS THE TARGET ENVIRONMENT!****" | ||
echo -e "${COLOR_OFF}" | ||
echo "Are you sure you want to proceed? Only "yes" will be accepted" | ||
read RESPONSE | ||
|
||
if [ "$RESPONSE" == "yes" ]; then | ||
for folder in "${folders[@]}" | ||
do | ||
pushd ../env/$ENVIRONMENT/$folder | ||
runCommand "terragrunt init --reconfigure" | ||
popd | ||
done | ||
exit 0 | ||
else | ||
echo "USER REQUESTED CANCELLATION" | ||
exit 0 | ||
fi |