Skip to content

Commit

Permalink
ref(terraform): oppa AJ style
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Oct 16, 2023
1 parent 621f2ec commit a2f5b8f
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -52,48 +52,63 @@ 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`
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
```

0 comments on commit a2f5b8f

Please sign in to comment.