Soru

Zorluk: KolayDeploying Infrastructure using Deployment Manager or Terraform

A Cloud Engineer is initializing a new infrastructure environment on Google Cloud using Terraform. The working directory contains valid `.tf` configuration files. What is the correct chronological sequence of Terraform CLI commands to initialize the working directory, preview proposed infrastructure changes, provision the GCP resources, and finally decommission the resources when no longer needed?

  1. 1Run `terraform init` to download provider plugins and initialize the backend configuration.
  2. 2Run `terraform plan` to create and review an infrastructure execution plan.
  3. 3Run `terraform apply` to provision the resources on Google Cloud.
  4. 4Run `terraform destroy` to tear down all managed infrastructure resources.

Cevap

The correct sequence begins with workspace initialization using `terraform init`, followed by generating an execution preview with `terraform plan`, executing infrastructure creation with `terraform apply`, and ending with resource teardown via `terraform destroy`.
The standard Terraform workflow requires preparing the environment (`init`), validating proposed actions (`plan`), executing provisioning calls (`apply`), and lastly performing cleanup (`destroy`).

Adım Adım Çözüm

1
Initialize working directory
`terraform init` downloads provider plugins and configures state backend.
Terraform requires initialization before it can recognize provider definitions and execute any downstream commands.
2
Generate execution preview
`terraform plan` outputs proposed resource changes.
Planning ensures that unexpected modifications or syntax errors are identified prior to altering live cloud infrastructure.
3
Apply infrastructure updates
`terraform apply` calls GCP APIs to create and update resources.
This step turns the defined configuration code into active Google Cloud infrastructure components.
4
Decommission environment
`terraform destroy` removes all tracked state resources.
Destruction is the final step in the lifecycle, removing resources when they are no longer required.

Anahtar Kavram

Terraform Deployment Lifecycle Command Sequence
Bu soruyu puanla