37 lines
1.2 KiB
Bash
Executable File
37 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -o errexit -o nounset
|
|
|
|
docker run --rm -it \
|
|
-e ARM_CLIENT_ID \
|
|
-e ARM_CLIENT_SECRET \
|
|
-e ARM_SUBSCRIPTION_ID \
|
|
-e ARM_TENANT_ID \
|
|
-v $(pwd):/data \
|
|
--workdir=/data \
|
|
--entrypoint "/bin/sh" \
|
|
hashicorp/terraform:light \
|
|
-c "/bin/terraform get; \
|
|
/bin/terraform validate; \
|
|
/bin/terraform plan -out=out.tfplan -var resource_group=$KEY -var sql_admin=$KEY -var sql_password=a!@abcd9753w0w@h@12; \
|
|
/bin/terraform apply out.tfplan; \
|
|
/bin/terraform show;"
|
|
|
|
# check that resources exist via azure cli
|
|
docker run --rm -it \
|
|
azuresdk/azure-cli-python:0.2.10 \
|
|
sh -c "az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID > /dev/null; \
|
|
az sql db show -g $KEY -n MySQLDatabase -s $KEY-sqlsvr; \
|
|
az sql server show -g $KEY -n $KEY-sqlsvr;"
|
|
|
|
# cleanup deployed azure resources via terraform
|
|
docker run --rm -it \
|
|
-e ARM_CLIENT_ID \
|
|
-e ARM_CLIENT_SECRET \
|
|
-e ARM_SUBSCRIPTION_ID \
|
|
-e ARM_TENANT_ID \
|
|
-v $(pwd):/data \
|
|
--workdir=/data \
|
|
--entrypoint "/bin/sh" \
|
|
hashicorp/terraform:light \
|
|
-c "/bin/terraform destroy -force -var resource_group=$KEY -var sql_admin=$KEY -var sql_password=a!@abcd9753w0w@h@12;" |