Terraform usage: Difference between revisions
From wikinotes
(→Usage) |
|||
Line 14: | Line 14: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
terraform fmt # autoformat terraform files | terraform fmt # autoformat terraform files | ||
terraform init # install dependencies | |||
terraform plan # show what is required to deploy | |||
terraform apply # deploy instance | |||
terraform destroy # delete instance | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Usage --> | </blockquote><!-- Usage --> |
Revision as of 21:33, 25 September 2022
Documentation
terraform cli https://www.terraform.io/cli debugging https://www.terraform.io/internals/debugging
Usage
terraform fmt # autoformat terraform files terraform init # install dependencies terraform plan # show what is required to deploy terraform apply # deploy instance terraform destroy # delete instance
Secrets Management
The simplest way is probably a combination of direnv and pass.
# ${PROJECT}/main.tf terraform { required_providers { vultr = { source = "vultr/vultr" version = ">=2" } } } provider "vultr" { api_key = "VULTR_API_KEY" } resource "vultr_instance" "web" { # ... }# ${PROJECT}/.envrc export TF_VAR_api_key="$(pass foo/bar/api_key)"cd ${PROJECT} direnv allow terraform init