Last active
January 24, 2024 12:12
-
-
Save Sysa/ac06b2bd9ddc44424d93dede8007d127 to your computer and use it in GitHub Desktop.
terraform cli commands and more
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
terraform cheatlist | |
terraform fmt - formatter | |
terraform init - initialize tf backend (local one) | |
terraform plan - | |
terraform apply - | |
terraform apply -refresh-only | |
terraform state list | |
terraform state show | |
terraform state show “specific resource” | |
terraform show | |
terraform apply -destroy (equal to terraform destroy) | |
terraform plan -destroy | |
terraform outputs - get specified outputs | |
terraform output ip_address | |
terraform console - handy tool | |
terraform workspace select dev | |
terraform state rm | |
remove existing: | |
-remove from code | |
destroy: | |
terraform state list | |
terraform destroy -target … | |
terraform state rm … # just to resource from a state. (if was changed manually) | |
terraform state show module.aml-workspace.azurerm_storage_account.sa | |
manually edit state file if required (dangerous, make sure you have state file backups) | |
terraform state pull > tfstatefile | |
# do required changes | |
terraform state push tfstatefile | |
-> if you see something `Failed to write state: cannot overwrite existing state with serial 440 with a different state that has the same serial`, then just increase serial for any number (like +1 or +3) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment