#!/usr/bin/env bash # # Check for and exit on errors set -e # Script to implement some functions to standardize the workflow for TerraformA In CI/CD Pipelines # # ## Global Variables ## PS4='LINENO:' # Set line numbers on error output to ease debugging ## Terraform Apply Function echo "Applying for environment ${TF_WORKSPACE}" cd tf/templates terraform_1.0.4 apply -input=false -auto-approve tfplan 2>&1 | \ sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" ; \ test ${PIPESTATUS[0]} -eq 0 cd ../../ # Run Terraform apply on our workspaces #for I in `cat tf/config/datadog-integrations.tfvars |scripts/hcl2json |jq -r '.aws_account_id | keys[]'` # do # echo "Planning Terraform run for workspace ${I}" # export TF_WORKSPACE="${I}" # terraform_apply # done