From a2f5b8f6dd19d8973a52c467fc5d6e07a8683116 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 16 Oct 2023 19:56:45 +0000 Subject: [PATCH] ref(terraform): oppa AJ style --- terraform/README.md | 51 +++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/terraform/README.md b/terraform/README.md index 1ebd83522..b5f74f240 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -14,14 +14,14 @@ description: | > shared, managed, and executed within a workflow that is consistent across all > infrastructure. -### Defining infrastructure state +### How to Define Infrastructure State Create configurations that provide an outline for Terraform to provision your -target infrastructure. E.g., +target infrastructure. For example: -```tf -# main.tf +`main.tf`: +```tf terraform { required_providers { docker = { @@ -52,43 +52,56 @@ resource "docker_container" "nginx" { } ``` -### Initializing Terraform +### How to Initialize Terraform Terraform needs to install provider-specific plugins, generate lockfiles, etc. before you can begin provisioning. -`terraform init` +```sh +terraform init +``` You should only need to run this on new configurations, or other configurations checked-out from version control. -### Checking your configuration +### How to Lint / Check / Validate your Config To check you have a valid configuration -`terraform validate` +```sh +terraform validate +``` To format your configuration files -`terraform fmt` +```sh +terraform fmt +``` -### Provisioning resources +### How to Provision Resources -You can generate an execution plan before commiting to provisioning real +You can generate an execution plan before committing to provisioning real resources. This command allows you to see exactly what Terraform will do when running the next command. -`terraform plan` +```sh +terraform plan +``` -**Then, to apply your configurations and provision infrastructure resources.** +Then, **to apply your configurations and provision infrastructure** resources: -`terraform apply` +```sh +terraform apply +``` -To automatically accept all user prompts when running this command +Use `-auto-approve` to automatically accept all user prompts (non-interactive, +batch mode): -`terraform apply -auto-approve` +```sh +terraform apply -auto-approve +``` -### Execution plans +### How to Execute Plans Execution plans generated by `terraform plan` also act as the _last working state of your infrastructure_. You may wish to save the generated `.tfstate` @@ -96,4 +109,6 @@ file so that you may re-provision these resources reliably. You can pass in the execution plan to `terraform apply` (example): -`terraform apply -auto-approve main.tf` +```sh +terraform apply -auto-approve ./main.tf +```