You run terraform import aws_instance.example i-1234567890abcdef0 to import an existing AWS EC2 instance into your Terraform state. What is the immediate effect on your Terraform state and configuration?
Think about what terraform import does versus what Terraform configuration files do.
Importing a resource adds it to the Terraform state file, but the resource must already be declared in the configuration files to be managed properly. Terraform does not modify configuration files automatically.
After importing a resource into Terraform state, why is it important to verify the state matches the actual resource?
Consider what happens if Terraform's state does not reflect reality.
If the state does not match the actual resource, Terraform may try to change or replace the resource during the next apply, causing unintended disruptions.
You have a Google Cloud Compute Instance named my-instance in project my-project and zone us-central1-a. Which import command correctly imports this instance into Terraform resource google_compute_instance.vm?
Check the required resource ID format for GCP Compute Instances in Terraform import.
The correct format for importing a GCP Compute Instance includes the full resource path: projects/{project}/zones/{zone}/instances/{instance}.
What is a potential security risk when importing resources into Terraform state from external cloud accounts or projects?
Think about what information Terraform state files contain.
Terraform state files can contain sensitive information. Importing resources may add secrets or credentials to the state, so secure storage and encryption are important.
You imported an AWS S3 bucket into Terraform state with terraform import aws_s3_bucket.mybucket my-bucket-name. However, your Terraform configuration defines the bucket with versioning enabled, but the actual bucket has versioning disabled. What will happen when you run terraform plan?
Consider how Terraform handles differences between state and configuration.
Terraform compares the imported state with the configuration. If versioning is disabled in the actual bucket but enabled in config, Terraform plans to update the bucket to enable versioning.