A retail organization wants to bring a manually created Google Cloud Storage bucket used for transactional archives under Terraform management without destroying the existing bucket. Which sequence of operational steps must the Cloud Architect execute to safely import the bucket into the Terraform state using declarative import configuration?
- 1Declare the resource block for the Cloud Storage bucket and write a corresponding import block specifying the target resource address and GCP bucket identifier in the Terraform configuration file.
- 2Run terraform plan to inspect the execution plan, verifying that Terraform matches the live GCP storage bucket configuration without requesting unexpected resource recreation.
- 3Run terraform apply to lock the remote Cloud Storage state backend and record the bucket's live attributes into the state file.
- 4Remove the temporary import block from the Terraform configuration while retaining the resource block for future CI/CD pipeline management.
Cevap
The correct operational sequence is: 1) Declare the resource and import blocks in the HCL configuration file, 2) Execute terraform plan to inspect the import plan without introducing resource destruction, 3) Execute terraform apply to bind the live resource into the remote Cloud Storage state file while acquiring backend locks, and 4) Remove the temporary import block from the configuration.
The correct sequence follows Google Cloud and Terraform best practices for brownfield IaC onboarding: configuration declaration (resource and import blocks), plan verification to prevent resource destruction, apply execution to update state safely with remote backend locking, and post-import cleanup of temporary import metadata.
Adım Adım Çözüm
Anahtar Kavram
Declarative Infrastructure as Code resource import workflow and state management