It brings existing infrastructure resources into Terraform's management by adding them to the state file without changing the actual resource.
Click to reveal answer
intermediate
Why can't Terraform import multiple resources at once?
Terraform import works on one resource at a time because each resource requires a unique address and ID to be mapped correctly in the state file.
Click to reveal answer
beginner
What must you do after importing a resource to Terraform?
You must write the matching Terraform configuration code for the imported resource to avoid discrepancies between the state and configuration.
Click to reveal answer
intermediate
Can Terraform import resources that are not supported by the provider?
No, Terraform can only import resources that the provider supports and has import functionality for.
Click to reveal answer
advanced
What is a common consideration when importing resources with dependencies?
You should import resources in the correct order (dependencies first) to maintain relationships and avoid errors in the state.
Click to reveal answer
What does Terraform import update?
AThe Terraform state file
BThe cloud provider's resource configuration
CThe Terraform configuration files
DThe Terraform backend settings
✗ Incorrect
Terraform import updates the state file to include the existing resource but does not change configuration files or the actual resource.
Which of the following is a limitation of Terraform import?
AIt requires manual configuration code after import
BIt automatically generates configuration code
CIt can import multiple resources simultaneously
DIt changes the resource in the cloud provider
✗ Incorrect
Terraform import does not generate configuration code; you must write it manually to match the imported resource.
If a resource has dependencies, what should you do when importing?
AIgnore dependencies during import
BImport the resource without dependencies first
CImport the dependent resources first
DImport all resources at once
✗ Incorrect
Import resources without dependencies first (i.e., the dependencies) to ensure the state reflects correct relationships and avoids errors.
Can Terraform import a resource that the provider does not support?
AOnly if manually configured
BNo, only supported resources can be imported
CYes, always
DYes, but only with plugins
✗ Incorrect
Terraform import only works for resources supported by the provider with import functionality.
What happens if Terraform configuration does not match the imported resource?
ATerraform will automatically fix the configuration
BTerraform deletes the resource
CTerraform ignores the mismatch
DTerraform will show a difference and may try to change the resource
✗ Incorrect
Terraform detects differences and may attempt to update the resource to match the configuration.
Explain the key limitations and considerations when using Terraform import.
Think about what import changes and what you must do after.
You got /5 concepts.
Describe the steps you should take after importing a resource into Terraform.
Consider how to keep Terraform state and config consistent.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the terraform import command?
easy
A. To delete resources from the cloud provider
B. To create new resources from scratch
C. To bring existing resources under Terraform management without recreating them
D. To update Terraform itself to the latest version
Solution
Step 1: Understand the role of terraform import
The terraform import command is used to take resources that already exist outside Terraform and bring them into Terraform's control without deleting or recreating them.
Step 2: Differentiate from other commands
Creating new resources is done with terraform apply, deleting is done with terraform destroy, and updating Terraform is unrelated to resource import.
Final Answer:
To bring existing resources under Terraform management without recreating them -> Option C
Quick Check:
terraform import = bring existing resources under control [OK]
Hint: Import means adopt existing resources, not create new ones [OK]
Common Mistakes:
Thinking import creates new resources
Confusing import with resource deletion
Assuming import updates Terraform version
2. Which of the following is required before running terraform import for a resource?
easy
A. The resource must be deleted first
B. The resource must be created by Terraform previously
C. Terraform must be initialized with terraform init after import
D. The resource configuration must exist in the Terraform files
Solution
Step 1: Check Terraform import requirements
Before importing, Terraform needs a matching resource block in the configuration files to map the imported resource to.
Step 2: Understand other options
The resource should not be deleted before import; terraform init is run before import, not after; and the resource does not need to be created by Terraform previously.
Final Answer:
The resource configuration must exist in the Terraform files -> Option D
Quick Check:
Config must exist before import [OK]
Hint: Write resource config first, then import [OK]
What happens if you run terraform import aws_s3_bucket.mybucket my-existing-bucket?
medium
A. Terraform imports the existing S3 bucket and manages it without changes
B. Terraform deletes the existing bucket and creates a new one
C. Terraform throws an error because the bucket name is missing
D. Terraform creates a duplicate bucket with a different name
Solution
Step 1: Match resource config and import command
The resource block matches the bucket name used in the import command, so Terraform will link the existing bucket to this resource.
Step 2: Understand import behavior
Import does not delete or recreate resources; it only brings them under Terraform management.
Final Answer:
Terraform imports the existing S3 bucket and manages it without changes -> Option A
Quick Check:
Import links existing resource without changes [OK]
Hint: Import links existing resource, no deletion [OK]
Common Mistakes:
Assuming import deletes or recreates resource
Confusing import with apply
Using wrong resource ID format
4. You run terraform import aws_instance.web i-1234567890abcdef0 but get an error saying the resource ID format is invalid. What is the most likely cause?
medium
A. Terraform was not initialized with terraform init
B. The resource ID does not match the expected format for the AWS provider
C. The resource configuration block is missing in Terraform files
D. The AWS instance does not exist in the cloud
Solution
Step 1: Check resource ID format
Terraform import requires the resource ID to match the provider's expected format exactly. An invalid format causes errors.
Step 2: Differentiate from other causes
Missing config causes different errors; uninitialized Terraform causes different errors; non-existent resource causes not found errors, not format errors.
Final Answer:
The resource ID does not match the expected format for the AWS provider -> Option B
Quick Check:
Invalid ID format causes import error [OK]
Hint: Check provider docs for correct ID format before import [OK]
Common Mistakes:
Ignoring ID format requirements
Assuming missing config causes format error
Skipping terraform init before import
5. You want to import multiple existing resources of the same type but with different IDs into Terraform. Which approach best handles this scenario?
hard
A. Write separate resource blocks with unique names and import each resource individually
B. Write one resource block and import all IDs at once using a comma-separated list
C. Use a single resource block with a list of IDs and import once
D. Import resources without any configuration blocks and Terraform will auto-discover them
Solution
Step 1: Understand Terraform resource uniqueness
Each resource block must have a unique name to represent a single resource instance in Terraform.
Step 2: Import multiple resources properly
To import multiple resources, create multiple resource blocks with unique names and import each resource ID separately.
Step 3: Eliminate incorrect options
Terraform does not support importing multiple IDs at once in one resource block or auto-discovery without config.
Final Answer:
Write separate resource blocks with unique names and import each resource individually -> Option A
Quick Check:
One resource block per resource, import individually [OK]
Hint: One resource block per resource, import separately [OK]
Common Mistakes:
Trying to import multiple IDs in one resource block
Assuming Terraform auto-discovers resources
Using comma-separated IDs in import command
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.