Skip to content

Instantly share code, notes, and snippets.

@ngstigator
Last active August 8, 2023 17:00
Show Gist options
  • Save ngstigator/e6f323f8f0c162e8ea1d53015051cc1f to your computer and use it in GitHub Desktop.
Save ngstigator/e6f323f8f0c162e8ea1d53015051cc1f to your computer and use it in GitHub Desktop.

Terraform

Bash prompt display workspace

terraform-workspace-prompt

Create Terraform template files

sh -c "$(curl -fsSL https://raw.githubusercontent.com/dyordsabuzo/miscellany/main/tools/terraform-create-template-files.sh)"

Move state to another workspace

terraform workspace select <SOURCE_WORKSPACE>

terraform state pull > source.tfstate

terraform workspace select <TARGET_WORKSPACE>

terraform state push source.tfstate

Delete state from source workspace

terraform workspace select <SOURCE_WORKSPACE>

terraform state list | xargs -n 1 terraform state rm

Remove lock

terraform force-unlock <LOCK_ID>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment