Soru

Zorluk: OrtaInfrastructure as Code and Environment Provisioning

Your organization is establishing an automated, reliable environment provisioning workflow using Terraform and Cloud Build on Google Cloud. What is the correct sequence of steps to safely establish the infrastructure configuration pipeline from initial state storage setup to resource deployment?

  1. 1Create a dedicated Google Cloud Storage (GCS) bucket configured with Uniform Bucket-Level Access and Object Versioning enabled.
  2. 2Create a dedicated IAM service account for pipeline execution and grant it least-privilege roles on target resources and GCS bucket access.
  3. 3Write the Terraform configuration files specifying the Google provider and configuring the GCS remote backend block.
  4. 4Execute terraform init in the automated CI/CD pipeline using service account impersonation.
  5. 5Execute terraform plan to preview infrastructure changes, followed by terraform apply upon automated review approval.

Cevap

The correct operational sequence begins with creating the GCS state bucket with versioning, configuring the execution service account and IAM permissions, writing Terraform configurations referencing the GCS backend, running terraform init to configure the backend connection, and finally executing terraform plan and terraform apply.
Establishing IaC automation requires creating prerequisites (GCS state bucket and IAM Service Account), defining configuration code referencing those prerequisites, running terraform init to link the environment, and executing terraform plan and terraform apply to deploy resources safely.

Adım Adım Çözüm

1
Provision remote state bucket
A secure GCS bucket with versioning is created to hold terraform.tfstate.
Backend storage infrastructure must exist prior to declaring backend initialization.
2
Configure service account and IAM access
A service account with least-privilege permissions and bucket storage access is generated.
The automated deployment pipeline requires authorized identity access to resources and state storage.
3
Define Terraform code and backend configuration
Terraform files declare GCP providers and link to the GCS backend bucket.
Infrastructure definition files must specify the target state storage location before initialization.
4
Initialize backend via terraform init
Provider plugins are downloaded and remote state lock mechanisms are established.
Initialization binds the workspace context to the remote state infrastructure.
5
Execute terraform plan and terraform apply
Resource modifications are evaluated for drift and successfully provisioned.
Specifying plan before apply guarantees changes are inspected prior to resource creation.

Anahtar Kavram

Terraform Automated Environment Provisioning Sequence
Bu soruyu puanla