Terraform usage: Difference between revisions

From wikinotes
No edit summary
Line 16: Line 16:
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Usage -->
</blockquote><!-- Usage -->
= Secrets Management =
<blockquote>
The simplest way is probably a combination of [[direnv]] and [[pass]].
<syntaxhighlight lang="tf">
# ${PROJECT}/main.tf
terraform {
  required_providers {
    vultr = {
      source = "vultr/vultr"
      version = ">=2"
    }
  }
}
provider "vultr" {
  api_key = "VULTR_API_KEY"
}
resource "vultr_instance" "web" {
  # ...
}
</syntaxhighlight>
<syntaxhighlight lang="bash">
# ${PROJECT}/.envrc
export TF_VAR_api_key=abcdefg
</syntaxhighlight>
<syntaxhighlight lang="bash">
cd ${PROJECT}
direnv allow
terraform init
</syntaxhighlight>
</blockquote><!-- Secrets Management -->

Revision as of 20:04, 25 September 2022

Documentation

terraform cli https://www.terraform.io/cli
debugging https://www.terraform.io/internals/debugging

Usage

terraform fmt  # autoformat terraform files

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=abcdefg
cd ${PROJECT}
direnv allow
terraform init