💾 Archived View for koyu.space › vydyck › tech › cloud › terraform › index.gmi captured on 2023-11-04 at 12:15:01. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

🚧 View Differences

-=-=-=-=-=-=-

Terraform

Install

Available as a standalon binary for most osses, download from hashicorp.

Closed source product?

Set up a project

Create a subdir, preferably managed as a git repo.

main.tf

is no longer required, but expected by many oldtimer terraformers

newer-ish standard (not actually required but recommended) :

provider.tf: configure all provider plugins here

vars.tf: all variable definitions

outputs.tf: all output definitions

One or more of:

<resourcename>.tf: group by resource type, eg all s3, iam,...

The "Language"

Variables:

variable "<variablename>" {

type = "some type, usually string"

default = "a default value"

}

Resources:

resource "<resource type>" "<terraform resource name>" {

note that the real name of the resource is an attribute itself; the terraform resourcename is only used in the terraform code

see the docs of the <resource type>

usually:

<attributename> = "<attribute value>"

references to attributes of other resource type are via:

<attributename> = <resource type>.<terraform resource name>.<attributename>

you can extrapolate values of variables in the assigment:

<attributename> = " (TBD)

the value can also be function output:

eg source_code_hash = filebase64sha256("Accounts.zip")

}

outputs

special variables that can be called via "terraform output <outputname>"

useful for attribute values that are only known after creation, eg because they are randomized.

output "<my output name>" {

value = <some resource type>.<my resource name>.<attribute name>.

}