-
Notifications
You must be signed in to change notification settings - Fork 0
/
tf_apply.sh
executable file
·29 lines (23 loc) · 988 Bytes
/
tf_apply.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
set -e
set -o pipefail
export STORAGE_ACCOUNT_TFSTATE_NAME="${STORAGE_ACCOUNT_TFSTATE_NAME}"
export ARM_CLIENT_ID="${ARM_CLIENT_ID}"
export ARM_CLIENT_SECRET="${ARM_CLIENT_SECRET}"
export ARM_SUBSCRIPTION_ID="${ARM_SUBSCRIPTION_ID}"
export ARM_TENANT_ID="${ARM_TENANT_ID}"
export ARM_SKIP_PROVIDER_REGISTRATION='true'
# Get full path to the directory containing this script
FULL_SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
# Change to the terraform directory
cd "${FULL_SCRIPT_PATH}/../terraform"
echo 'terraform init'
terraform init \
-backend-config="storage_account_name=${STORAGE_ACCOUNT_TFSTATE_NAME}" \
-backend-config="subscription_id=${ARM_SUBSCRIPTION_ID}" \
-backend-config="resource_group_name=${RESOURCE_GROUP_NAME}" \
-backend-config="container_name=${STORAGE_ACCOUNT_TFSTATE_CONTAINER_NAME}"
echo 'Selecting terraform workspace'
terraform workspace select "${ENV}"
echo 'terraform apply'
terraform apply -auto-approve "${ENV}"-tfplan