0
0
Terraformcloud~20 mins

Import state verification in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Import Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What happens after importing a resource state in Terraform?

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?

AThe resource is added to the state file but must be defined in the configuration before applying changes.
BThe resource is deleted from AWS and replaced by Terraform-managed resource.
CThe resource is added to the configuration but not to the state file until you run <code>terraform apply</code>.
DThe resource is added to both the state file and the configuration automatically.
Attempts:
2 left
💡 Hint

Think about what terraform import does versus what Terraform configuration files do.

🧠 Conceptual
intermediate
2:00remaining
Why verify Terraform state after import?

After importing a resource into Terraform state, why is it important to verify the state matches the actual resource?

ABecause the import command deletes the resource if state is not verified.
BBecause Terraform automatically fixes any mismatches during import.
CBecause verifying state is optional and has no impact on Terraform behavior.
DBecause mismatches can cause Terraform to attempt to recreate or destroy the resource on next apply.
Attempts:
2 left
💡 Hint

Consider what happens if Terraform's state does not reflect reality.

Configuration
advanced
2:00remaining
Identify the Terraform import command for a GCP Compute Instance

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?

Aterraform import google_compute_instance.vm my-project/us-central1-a/my-instance
Bterraform import google_compute_instance.vm projects/my-project/zones/us-central1-a/instances/my-instance
Cterraform import google_compute_instance.vm my-instance
Dterraform import google_compute_instance.vm zones/us-central1-a/projects/my-project/instances/my-instance
Attempts:
2 left
💡 Hint

Check the required resource ID format for GCP Compute Instances in Terraform import.

security
advanced
2:00remaining
Security risk when importing Terraform state from external resources

What is a potential security risk when importing resources into Terraform state from external cloud accounts or projects?

AImporting resources disables cloud provider security groups temporarily.
BTerraform automatically encrypts all imported state files, so no risk exists.
CSensitive data like passwords or keys may be stored in the state file if not handled properly.
DImporting resources deletes all existing state data, causing data loss.
Attempts:
2 left
💡 Hint

Think about what information Terraform state files contain.

Architecture
expert
2:00remaining
Effect of mismatched Terraform configuration after import

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?

ATerraform will show a plan to enable versioning on the bucket to match the configuration.
BTerraform will ignore the versioning difference and show no changes.
CTerraform will delete the bucket and recreate it with versioning enabled.
DTerraform will fail with an error about versioning mismatch.
Attempts:
2 left
💡 Hint

Consider how Terraform handles differences between state and configuration.