Created
August 28, 2024 15:47
-
-
Save sodonnell/2e9b87f006b7ef4ff6524d925091753c to your computer and use it in GitHub Desktop.
terraform.apply.destroy.remote.state.example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
TF_STATE_BUCKET=tfstate-ops | |
TF_STATE_PREFIX=cluster/ops | |
### USE REMOTE TFSTATE via S3 | |
terraform init \ | |
-backend-config=bucket=${TF_STATE_BUCKET} \ | |
-backend-config=key=${TF_STATE_PREFIX}/cluster.tfstate \ | |
-backend-config=region=us-west-2 \ | |
-force-copy \ | |
-no-color; | |
### CREATE | |
terraform plan -no-color -var-file=tfvars/ops.tfvars -out=cluster-ops.pln | |
time terraform apply -auto-approve -no-color cluster-ops.pln &> cluster-ops-apply.log | |
exit | |
### DESTROY | |
terraform plan -destroy -no-color -var-file=tfvars/ops.tfvars -out=destroy-ops.pln | |
time terraform apply -auto-approve -no-color destroy-ops.pln &> cluster-ops-destroy.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment