Skip to content
Snippets Groups Projects
Commit 4a0c75ed authored by Ole Langbehn's avatar Ole Langbehn
Browse files

Merge branch 'main' into production

parents 8b366f08 b1d7c36b
No related branches found
No related tags found
No related merge requests found
.envrc.local .envrc.local
coverage coverage
terraform*.log
#!/usr/bin/env sh #!/usr/bin/env bash
# exit when any command fails # exit when any command fails
set -ex set -ex
# enable full debug output in terraform, which is only written to logfiles # enable debug output in terraform
export TF_LOG=TRACE export TF_LOG=DEBUG
cd terraform/environments # retry logic for destroy: sometimes, a full workspace destroy does not work. This can be due to e.g.:
# * implicit dependencies between terraform resources not declared with depends_on,
# * unclean shutdown of resources, e.g. service does not close db connections, db still sees clients connected,
# * GCP stuff not allowing our resources to be deleted.
# Most of the time, retrying a destroy fixes these causes.
retry() {
for i in {1..3}; do
set +e
"$@"
retval=$?
set -e
if [ "$retval" -ne "0" ]; then
if [ "$i" -lt "3" ]; then
echo "command '$*' failed in try $i, retrying after 60 seconds"
sleep 60 # let things settle a bit
else
echo "command '$*' failed in try $i, giving up"
exit $retval
fi
else
break # success
fi
done
}
WORKSPACE=$1 cd "$(dirname "$0")"/..
TAG=$2
TF_LOG_PATH=terraform-init.log terraform init TF_LOG_PATH=terraform-init.log terraform init
TF_LOG_PATH=terraform-version.log terraform version TF_LOG_PATH=terraform-version.log terraform version
TF_LOG_PATH=terraform-workspace.log terraform workspace new "$WORKSPACE" || terraform workspace select "$WORKSPACE" TF_LOG_PATH=terraform-workspace.log terraform workspace select -or-create=true "$1"
TF_LOG_PATH=terraform-plan.log terraform plan -var="image_tag=$TAG" -out plan -no-color | tee tfplan.plain TF_LOG_PATH=terraform-destroy.log retry terraform destroy -auto-approve -var="image_tag=dummy"
TF_LOG_PATH=terraform-apply.log terraform apply -auto-approve -parallelism=50 plan TF_LOG_PATH=terraform-ws-default.log terraform workspace select default
\ No newline at end of file TF_LOG_PATH=terraform-ws-delete.log terraform workspace delete "$1"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment