> For the complete documentation index, see [llms.txt](https://code.janardhanpulivarthi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code.janardhanpulivarthi.com/google-cloud/terraform.md).

# terraform

## Why?

Uniform syntax - Arguments and blocks, Identifiers and Comments.

.<https://www.terraform.io/docs/language/syntax/configuration.html>

Full lifecycle management

Synchronous feedback

Graph theory - <https://www.terraform.io/docs/internals/graph.html>

`terraform plan`

{% code title="console output" %}

```bash
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # google_sql_database.default[0] will be created
  + resource "google_sql_database" "default" {
      + charset   = (known after apply)
      + collation = (known after apply)
      + id        = (known after apply)
      + instance  = (known after apply)
      + name      = "default"
      + project   = (known after apply)
      + self_link = (known after apply)
    }

  # google_sql_database_instance.master will be created
  + resource "google_sql_database_instance" "master" {
      + connection_name               = (known after apply)
      + database_version              = "MYSQL_5_6"
      + first_ip_address              = (known after apply)
      + id                            = (known after apply)
      + ip_address                    = (known after apply)
      + master_instance_name          = (known after apply)
      + name                          = (known after apply)
      + private_ip_address            = (known after apply)
      + project                       = (known after apply)
      + public_ip_address             = (known after apply)
      + region                        = "us-central1"
      + self_link                     = (known after apply)
      + server_ca_cert                = (known after apply)
      + service_account_email_address = (known after apply)

      + replica_configuration {}

      + settings {
      + host     = "%"
      + id       = (known after apply)
      + instance = (known after apply)
      + name     = "default"
      + password = (sensitive value)
      + project  = (known after apply)
    }

  # random_id.name will be created
  + resource "random_id" "name" {
      + b64         = (known after apply)
      + b64_std     = (known after apply)
      + b64_url     = (known after apply)
      + byte_length = 2
      + dec         = (known after apply)
      + hex         = (known after apply)
      + id          = (known after apply)
    }

  # random_id.user-password will be created
  + resource "random_id" "user-password" {
      + b64         = (known after apply)
      + b64_std     = (known after apply)
      + b64_url     = (known after apply)
      + byte_length = 8
      + dec         = (known after apply)
      + hex         = (known after apply)
      + id          = (known after apply)
    }

Plan: 5 to add, 0 to change, 0 to destroy.
```

{% endcode %}

`terraform apply -parallelism=2`

source: <https://github.com/j143/autoscaler/blob/master/terraform/per-project/main.tf>

## Usage docs

.<https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_subnetwork>

![](https://1074895821-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKpcZyxGXJcyzkNoKkm%2F-MYrP-Lj6lw5mytEwMgW%2F-MYrPi9zaihsgIprf5IQ%2Fimage.png?alt=media\&token=def23a5c-9f6c-4582-9a47-83c542be2a5b)

## Errors

### Error 1

.<https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_zones>

.<https://github.com/hashicorp/terraform/issues/17131>

.<https://github.com/hashicorp/terraform-provider-google/issues/973>

.<https://github.com/hashicorp/terraform-provider-google/issues/4856>

```bash
Error: project: required field is not set
```

.<https://github.com/hashicorp/terraform-provider-google/issues?q=is%3Aissue++Error%3A+project%3A+required+field+is+not+set>
