grep "set -o" ~/.bashrc || echo "set -o vi" >>~/.bashrc
grep "now" ~/.bashrc || echo export now='$(date +"%Y-%m-%d-%T")' >>~/.bashrc

cd ~/PREPARE/res*

terraform init -upgrade || { echo "terraform init failed - returning"; return 1; } 
terraform validate || { echo "terraform validate failed - returning"; return 1; } 

#Prepare variables first
terraform state rm terraform_data.vars[0] 2>null
terraform apply -auto-approve -target terraform_data.vars || { echo "terraform apply of terraform_data.vars failed - returning"; return 1; }

# Apply identity resources before applying the remainder
rd=oci_identity_domain_replication_to_region.my_region 
terraform apply -auto-approve -target $rd || { echo "terraform apply of $rd failed - returning"; return 1; }

# Apply the remainder
terraform apply -auto-approve || { echo "terraform apply of remainder failed - returning"; return 1; }

clear
test -f ~/provisioning_info && rm ~/provisioning_info; bash provisioning_info.sh > >(tee -a ~/provisioning_info) 2> >(tee -a ~/provisioning_info >&2)
#clear;
#echo ""; echo "----------------- Make a Note ----------------------"; echo "";
#terraform output -raw FA_Domain_User_Login; echo""
#terraform output -raw FA_Domain_User_Login_URL; echo ""
#terraform output -raw FA_Domain_User_Name
#echo ""; echo ""; echo "----------------------------------------------------"
#cat ~/provisioning_info
#echo ""; echo ""; echo "----------------------------------------------------"
