-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from gsi-labs/patch/solution-builder
Added static files at tf build
- Loading branch information
Showing
7 changed files
with
123 additions
and
5 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 @@ | ||
# Add the values for the Credentials to access the IBM Cloud | ||
# Instructions to access this information can be found in the README.MD | ||
# This is a template file and the ./launch.sh script looks for a file based on this template named credentials.properties | ||
ibmcloud.api.key="" |
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,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
ENV="credentials" | ||
|
||
function prop { | ||
grep "${1}" ${ENV}.properties | grep -vE "^#" | cut -d'=' -f2 | sed 's/"//g' | ||
} | ||
|
||
if [[ -f "${ENV}.properties" ]]; then | ||
# Load the credentials | ||
IBMCLOUD_API_KEY=$(prop 'ibmcloud.api.key') | ||
CLASSIC_API_KEY=$(prop 'classic.api.key') | ||
CLASSIC_USERNAME=$(prop 'classic.username') | ||
LOGIN_USER=$(prop 'login.user') | ||
LOGIN_PASSWORD=$(prop 'login.password') | ||
LOGIN_TOKEN=$(prop 'login.token') | ||
SERVER_URL=$(prop 'server.url') | ||
else | ||
echo "Error: The ${ENV}.properties file is not found." | ||
exit 1 | ||
fi | ||
|
||
if [[ -d "workspace" ]]; then | ||
echo "Found workspace" | ||
else | ||
mkdir workspace | ||
cp terraform/* workspace | ||
cp utils/* workspace | ||
fi | ||
|
||
docker run -it \ | ||
-e "TF_VAR_ibmcloud_api_key=${IBMCLOUD_API_KEY}" \ | ||
-e "IBMCLOUD_API_KEY=${IBMCLOUD_API_KEY}" \ | ||
-v ${PWD}:/terraform \ | ||
-w /terraform/workspace \ | ||
quay.io/ibmgaragecloud/cli-tools:v0.15 |
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,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
find . -type d -maxdepth 1 | grep -vE "[.]/[.].*" | grep -vE "^[.]$" | grep -v workspace | sort | \ | ||
while read dir; | ||
do | ||
name=$(echo "$dir" | sed -E "s~[.]/(.*)~\1~g") | ||
|
||
echo "*** Applying ${name} ***" | ||
|
||
cd "${name}" && \ | ||
terraform init && \ | ||
terraform apply -auto-approve && \ | ||
cd - 1> /dev/null || \ | ||
exit 1 | ||
done |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
terraform apply -auto-approve |
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,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
find . -type d -maxdepth 1 | grep -vE "[.]/[.].*" | grep -vE "^[.]$" | grep -v workspace | sort -r | \ | ||
while read dir; | ||
do | ||
name=$(echo "$dir" | sed -E "s~[.]/(.*)~\1~g") | ||
|
||
if [[ ! -f "./${name}/terraform.tfstate" ]]; then | ||
echo "*** No state found for ${name}. Skipping ***" | ||
continue | ||
fi | ||
|
||
echo "*** Destroying ${name} ***" | ||
|
||
cd "${name}" && \ | ||
terraform init && \ | ||
./destroy.sh && \ | ||
cd - 1> /dev/null || \ | ||
exit 1 | ||
done |
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,39 @@ | ||
#! /bin/bash | ||
|
||
RESOURCE_FILTER="$1" | ||
|
||
echo "" | ||
echo "Listing current state" | ||
terraform state list | ||
|
||
if [[ -n "${RESOURCE_FILTER}" ]]; then | ||
echo "" | ||
echo "Collecting resources to destroy using filter: ${RESOURCE_FILTER}" | ||
RESOURCE_LIST="" | ||
while read -r resource; do | ||
echo " Adding $resource to destroy targets" | ||
RESOURCE_LIST="$RESOURCE_LIST -target=$resource" | ||
done < <(terraform state list | grep -E "${RESOURCE_FILTER}") | ||
else | ||
echo "" | ||
echo "Collecting resources to destroy" | ||
RESOURCE_LIST="" | ||
while read -r resource; do | ||
echo " Adding $resource to destroy targets" | ||
RESOURCE_LIST="$RESOURCE_LIST -target=$resource" | ||
done < <(terraform state list) | ||
fi | ||
|
||
if [[ -n "$RESOURCE_LIST" ]]; then | ||
echo "" | ||
echo "Planning destroy" | ||
terraform plan -destroy ${RESOURCE_LIST} -out=destroy.plan | ||
|
||
echo "" | ||
echo "Destroying resources" | ||
terraform apply -auto-approve destroy.plan | ||
else | ||
echo "" | ||
echo "Nothing to destroy!!" | ||
fi | ||
|
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