Soru

Zorluk: KolayInfrastructure as Code and Environment Provisioning

A cloud architecture team needs to establish a standard Terraform workflow to manage Google Cloud infrastructure with remote state management. What is the correct sequence of steps to configure and execute this Infrastructure as Code workflow from start to finish?

  1. 1Create a Cloud Storage bucket with object versioning enabled to securely store the remote Terraform state file.
  2. 2Define the GCS backend configuration block within the Terraform code to reference the newly created bucket.
  3. 3Execute `terraform init` to download provider plugins and connect the workspace to the GCS remote backend.
  4. 4Execute `terraform plan` to review proposed infrastructure changes against the current state.
  5. 5Execute `terraform apply` to provision the resources in Google Cloud and update the remote state.

Cevap

The correct order of operations begins with creating the GCS remote state bucket, followed by configuring the backend in Terraform code, initializing the directory with `terraform init`, generating an execution plan with `terraform plan`, and finally applying the configuration with `terraform apply`.
The standard Terraform deployment sequence requires establishing backend state storage before initialization, initializing the working directory before planning changes, and reviewing an execution plan before applying infrastructure modifications to Google Cloud.

Adım Adım Çözüm

1
Provision remote state storage infrastructure
A Cloud Storage bucket with versioning is ready to serve as the backend.
Terraform requires an existing storage location before it can bind its state remotely.
2
Configure the Terraform backend code block
The Terraform code points to the created Cloud Storage bucket.
Declarative backend configuration establishes the connection parameters for remote state tracking.
3
Run initialization command
Provider plugins are downloaded and the backend state storage connection is initialized.
`terraform init` must be executed before planning or applying infrastructure.
4
Run speculative plan preview
An execution plan is generated detailing resource additions, modifications, or deletions.
`terraform plan` ensures safety and operational predictability prior to resource mutation.
5
Apply infrastructure changes
GCP resources are created or modified and state is locked and updated in Cloud Storage.
`terraform apply` executes the planned actions against the live Google Cloud environment.

Anahtar Kavram

Terraform Remote State Workflow Lifecycle
Bu soruyu puanla