TERRAFORM-ASSOCIATE-003 practice question 18 of 30

[Navigate Terraform State and Backends] Which parameters does terraform import require? Choose two correct answers.

Full set: 226 questions
Answer options
A: Provider
B: Resource ID Correct answer
C: Resource address Correct answer
D: Path
Correct Answer:
B. Resource ID; C. Resource address
Explanation

The terraform import command is used to bring existing, manually-created infrastructure under Terraform's management. The command's syntax is terraform import [options] ADDRESS ID. It requires two primary arguments: the ADDRESS and the ID. The ADDRESS is the resource address within the Terraform configuration where the imported object will be mapped (e.g., awsinstance.web). The ID is the unique identifier of the existing resource in the cloud provider's system (e.g., an AWS EC2 instance ID like i-01a2b3c4d5e6f7g8h). Both are mandatory for the import operation to succeed.

Why Incorrect

A. Provider: The provider is inferred from the resource address and the associated configuration files, not supplied as a direct argument to the import command.
D. Path: The command operates on the configuration files in the current working directory by default. A path is not a required argument for the command's core function.

References

1. HashiCorp. (n.d.). Command: import. Terraform CLI Documentation. Retrieved from https://developer.hashicorp.com/terraform/cli/commands/import.

Section: Usage. The documentation explicitly states the command's syntax as: terraform import [options] ADDRESS ID. It defines ADDRESS and ID as the two required arguments.

2. HashiCorp. (n.d.). Importing Infrastructure to Terraform. Terraform Language Documentation. Retrieved from https://developer.hashicorp.com/terraform/language/import/importing-infrastructure.

Section: How to Import Resources. This section provides a clear example: terraform import awsinstance.web i-12345678

which demonstrates the use of the resource address (awsinstance.web) and the resource ID (i-12345678).

Scroll to Top