Skip to content

Commit

Permalink
docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
vggonzal committed Oct 19, 2023
1 parent 4aa8ad8 commit cd3de6e
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:

- name: Deploy to venue
id: terraform-deploy
working-directory: examples/cumulus-tf
working-directory: terraform
env:
AWS_DEFAULT_REGION: us-west-2
run: |
Expand Down
15 changes: 0 additions & 15 deletions terraform/bin/config.sh

This file was deleted.

65 changes: 65 additions & 0 deletions terraform/bin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash

set -Eexo pipefail

# Read in args from command line

POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"

case $key in
--ticket)
ticket="$2"
shift # past argument
shift # past value
;;
--app-version)
app_version="$2"
shift # past argument
shift # past value
;;
--lambda_container_image_uri)
lambda_container_image_uri="$2"
shift # past argument
shift # past value
;;
-v|--tf-venue)
tf_venue="$2"
case $tf_venue in
sit|uat|ops) ;;
*)
echo "tf_venue must be sit, uat, or ops"
exit 1;;
esac
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

# https://www.terraform.io/docs/commands/environment-variables.html#tf_in_automation
TF_IN_AUTOMATION=true

# Terraform initialization
terraform init -reconfigure -input=false -backend-config="bucket=podaac-services-${tf_venue}-terraform" -backend-config="profile=ngap-service-${tf_venue}"

if [[ "${ticket}" ]]; then
set +e
terraform workspace new "${ticket}"
set -e
terraform workspace select "${ticket}"
else
terraform workspace select default
fi

terraform plan -input=false -var-file=tfvars/"${tf_venue}".tfvars -var="credentials=~/.aws/credentials" -var="profile=ngap-service-${tf_venue}" -var="app_version=${app_version}" -var="lambda_container_image_uri"=${lambda_container_image_uri} -out="tfplan"

# Apply the plan that was created
terraform apply -input=false -auto-approve tfplan
54 changes: 54 additions & 0 deletions terraform/bin/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -Eexo pipefail

POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"

case $key in
--ticket)
ticket="$2"
shift # past argument
shift # past value
;;
--app-version)
app_version="$2"
shift # past argument
shift # past value
;;
-v|--tf-venue)
tf_venue="$2"
case $tf_venue in
sit|uat|ops) ;;
*)
echo "tf_venue must be sit, uat, or ops"
exit 1;;
esac
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

# https://www.terraform.io/docs/commands/environment-variables.html#tf_in_automation
TF_IN_AUTOMATION=true

# Verify that you are in test workspace
current_workspace=$(terraform workspace show)

if [ $current_workspace == ${ticket} ]; then
# Terraform initialization
terraform init -reconfigure -input=false -backend-config="bucket=podaac-services-${tf_venue}-terraform" -backend-config="profile=ngap-service-${tf_venue}"
terraform destroy -auto-approve -var-file=tfvars/"${tf_venue}".tfvars -var="credentials=~/.aws/credentials" -var="profile=ngap-service-${tf_venue}" -var="app_version=${app_version}"
terraform workspace select default
terraform workspace delete ${ticket}
else
exit 1
fi

0 comments on commit cd3de6e

Please sign in to comment.