github.com/brandonstevens/terraform@v0.9.6-0.20170512224929-5367f2607e16/examples/azure-vnet-two-subnets/deploy.ci.sh (about) 1 #!/bin/bash 2 3 set -o errexit -o nounset 4 5 # generate a unique string for CI deployment 6 # KEY=$(cat /dev/urandom | tr -cd 'a-z' | head -c 12) 7 # PASSWORD=$KEY$(cat /dev/urandom | tr -cd 'A-Z' | head -c 2)$(cat /dev/urandom | tr -cd '0-9' | head -c 2) 8 9 docker run --rm -it \ 10 -e ARM_CLIENT_ID \ 11 -e ARM_CLIENT_SECRET \ 12 -e ARM_SUBSCRIPTION_ID \ 13 -e ARM_TENANT_ID \ 14 -v $(pwd):/data \ 15 --workdir=/data \ 16 --entrypoint "/bin/sh" \ 17 hashicorp/terraform:light \ 18 -c "/bin/terraform get; \ 19 /bin/terraform validate; \ 20 /bin/terraform plan -out=out.tfplan -var resource_group=$KEY; \ 21 /bin/terraform apply out.tfplan; \ 22 /bin/terraform show;" 23 24 # check that resources exist via azure cli 25 docker run --rm -it \ 26 azuresdk/azure-cli-python \ 27 sh -c "az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET --tenant $ARM_TENANT_ID > /dev/null; \ 28 az network vnet subnet show -n subnet1 -g $KEY --vnet-name '$KEY'vnet; \ 29 az network vnet subnet show -n subnet2 -g $KEY --vnet-name '$KEY'vnet;" 30 31 # cleanup deployed azure resources via terraform 32 docker run --rm -it \ 33 -e ARM_CLIENT_ID \ 34 -e ARM_CLIENT_SECRET \ 35 -e ARM_SUBSCRIPTION_ID \ 36 -e ARM_TENANT_ID \ 37 -v $(pwd):/data \ 38 --workdir=/data \ 39 --entrypoint "/bin/sh" \ 40 hashicorp/terraform:light \ 41 -c "/bin/terraform destroy -force -var resource_group=$KEY;"