Skip to content

Commit

Permalink
added terraform destroy capabilities to terraform script
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Montanelli committed May 4, 2023
1 parent e1c5cc4 commit 51e6d85
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ tfplan(){
tfapply(){
terraform apply "${ADF_PROJECT_NAME}-${TF_VAR_TARGET_ACCOUNT_ID}"
}
tfplandestroy(){
terraform plan -destroy -out "$ADF_PROJECT_NAME"-"$TF_VAR_TARGET_ACCOUNT_ID"-destroy
}
tfdestroy(){
terraform apply "$ADF_PROJECT_NAME"-"$TF_VAR_TARGET_ACCOUNT_ID"-destroy
}
tfrun(){
export TF_VAR_TARGET_ACCOUNT_ID=$ACCOUNT_ID
echo "Running terraform $TF_STAGE on account $ACCOUNT_ID and region $REGION"
Expand All @@ -62,6 +68,13 @@ tfrun(){
tfplan
tfapply
set +e
elif [[ "$TF_STAGE" = "destroy" ]]
then
set -e
tfinit
tfplandestroy
tfdestroy
set +e
else
echo "Invalid Terraform stage: TF_STAGE = $TF_STAGE"
exit 1
Expand Down

0 comments on commit 51e6d85

Please sign in to comment.