Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 181 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 181
Topic #: 1
[All Terraform Associate Questions]

When should Terraform configuration files be written when running terraform import on existing infrastructure?

  • A. Infrastructure can be imported without corresponding Terraform code
  • B. Terraform will generate the corresponding configuration files for you
  • C. You should write Terraform configuration files after the next terraform import is executed
  • D. Terraform configuration should be written before terraform import is executed
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Uma10
Highly Voted 1 year, 10 months ago
Selected Answer: D
The current implementation of Terraform import can only import resources into the state. It does not generate configuration. A future version of Terraform will also generate configuration. Because of this, prior to running terraform import it is necessary to write manually a resource configuration block for the resource, to which the imported object will be mapped. Source: https://www.terraform.io/cli/import
upvoted 19 times
...
zyxphreez
Highly Voted 1 year, 10 months ago
Selected Answer: C
i got confused..... check this url https://learn.hashicorp.com/tutorials/terraform/state-import the steps are 1. Identify the existing infrastructure you will import. 2. Import infrastructure into your Terraform state. 3. Write Terraform configuration that matches that infrastructure. 4. Review the Terraform plan to ensure the configuration matches the expected state and infrastructure. 5. Apply the configuration to update your Terraform state. based on the learning path... i will choose C
upvoted 11 times
SanderIsTheBestCloudShaper
1 year, 9 months ago
this is true , its c
upvoted 1 times
...
AB7088
1 year, 6 months ago
the question said import on existing infrastructure, so it should be answer C. based on https://learn.hashicorp.com/tutorials/terraform/state-import
upvoted 1 times
...
RVivek
1 year, 9 months ago
2 second step mport infrastructure into your Terraform state requires confiuration to be written just an empty block with provider name and resource type and and resouce address for exapmple resource aws_instace "my-webserver" { } then you have to run terraform import ws_instace .my-webserver <instance-id> where instance-id of the Ec2 instace to be ipmorted. Then the sate is imported . from the state you have to copy other importanat values like VPC-id, subnet-id, ebs volume id ...
upvoted 3 times
...
lezgino
1 year, 5 months ago
Selected answer: D That is correct, Terraform configuration should be written before terraform import is executed. It's best to have the Terraform code reflect the current state of the infrastructure so that Terraform can manage it.
upvoted 1 times
...
...
petersoliman
Most Recent 7 months, 1 week ago
Selected Answer: C
A. Infrastructure can be imported without corresponding Terraform code indeed but the question is saying should, so we should write the configurations sometime. B. Terraform will generate the corresponding configuration files for you that is also correct but with the plan command not import terraform plan -generate-config-out=generated_resources.tf that can be done after the importing, because you have the state file with the resources C. You should write Terraform configuration files after the next terraform import is executed that is the most correct for me. D. Terraform configuration should be written before terraform import is executed not sure why most people are choosing this one?!
upvoted 1 times
8876ca1
3 weeks, 2 days ago
Because of terraform import ADDR ID
upvoted 1 times
...
...
lukacs16
12 months ago
Selected Answer: D
"To import a resource, first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform" Answer is D. https://developer.hashicorp.com/terraform/cli/import/usage
upvoted 2 times
...
[Removed]
1 year ago
Selected Answer: C
Will pick D: Using configuration to import resources involves the following steps: 1. Identify the existing infrastructure you will import. 2. Define an import block for the resources. 3. Run terraform plan to review the import plan and optionally generate configuration for the resources. 4. Prune generated configuration to only the required arguments. 5. Apply the configuration to bring the resource into your Terraform state file. https://developer.hashicorp.com/terraform/tutorials/state/state-import
upvoted 1 times
...
Jhaggar
1 year, 1 month ago
Selected Answer: D
The correct statement is "Terraform configuration should be written before terraform import is executed". This is because Terraform import requires a corresponding resource block in the configuration file to identify and map the imported resource to the configuration. If the configuration file is not written before the import is executed, there will be no resource block available to map the imported resource to, which can result in an incomplete or incorrect state. After the import is executed, any necessary changes to the configuration file can be made to ensure that the configuration is up to date with the imported resources.
upvoted 1 times
...
FawadK
1 year, 2 months ago
Selected Answer: C
Answer is C. see https://developer.hashicorp.com/terraform/tutorials/state/state-import
upvoted 2 times
...
kiran15789
1 year, 2 months ago
Selected Answer: C
the steps are 1. Identify the existing infrastructure you will import. 2. Import infrastructure into your Terraform state. 3. Write Terraform configuration that matches that infrastructure. 4. Review the Terraform plan to ensure the configuration matches the expected state and infrastructure. 5. Apply the configuration to update your Terraform state.
upvoted 2 times
...
Chinensis
1 year, 3 months ago
Selected Answer: C
The answer is clearly written here: https://developer.hashicorp.com/terraform/tutorials/state/state-import Why debate? :)
upvoted 3 times
...
camps
1 year, 3 months ago
Selected Answer: D
D. Terraform configuration should be written before terraform import is executed When running terraform import on existing infrastructure, you should write the corresponding Terraform configuration files before executing the import command. The terraform import command requires that the resource configuration already exists in your Terraform code, as it maps the existing infrastructure to the defined resource in your configuration. The command then adds the imported resource information to your Terraform state file.
upvoted 1 times
...
camps
1 year, 3 months ago
Selected Answer: D
D. Terraform configuration should be written before terraform import is executed. Terraform import is used to import an existing infrastructure into a Terraform configuration. Before running terraform import, the configuration files must be written to describe the desired state of the imported resources. Once the configuration is written and the import command is executed, Terraform maps the existing resources to the configuration and updates its state accordingly. Therefore, Terraform configuration files should be written before running terraform import on existing infrastructure.
upvoted 1 times
...
noobster
1 year, 3 months ago
Before you run terraform import you must manually write a resource configuration block for the resource. https://developer.hashicorp.com/terraform/cli/import
upvoted 1 times
...
TechHero
1 year, 5 months ago
You don't need to write resource configuration before importing Bringing existing infrastructure under Terraform's control involves five steps: 1. Identify the existing infrastructure you will import. 2. Import infrastructure into your Terraform state. 3. Write Terraform configuration that matches that infrastructure. 4. Review the Terraform plan to ensure the configuration matches the expected state and infrastructure. 5. Apply the configuration to update your Terraform state. https://developer.hashicorp.com/terraform/tutorials/state/state-import?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS The Correct Answer is: A
upvoted 2 times
...
Zeppoonstream
1 year, 5 months ago
Selected Answer: D
D. Terraform configuration should be written before terraform import is executed When running the terraform import command on existing infrastructure, Terraform uses the configuration files to know how to interact with the resources. Without the configuration files, Terraform does not know how to interact with the resources and what to import. Therefore, Terraform configuration files should be written before terraform import is executed. A. Infrastructure can be imported without corresponding Terraform code is not true. B. Terraform will generate the corresponding configuration files for you is not true. C. You should write Terraform configuration files after the next terraform import is executed is not true. It's important to note that Terraform import is not a replacement for creating Terraform configuration files, but it helps to discover and populate the state with existing resources.
upvoted 1 times
...
gekkehenk
1 year, 5 months ago
Selected Answer: D
According to Terraform, the configuration should be written before performing the import. "Before you run terraform import you must manually write a resource configuration block for the resource. The resource block describes where Terraform should map the imported object." https://developer.hashicorp.com/terraform/cli/import
upvoted 1 times
...
Andreaw
1 year, 6 months ago
Selected Answer: A
to import is not necessary update config. To apply yes, is tricky
upvoted 1 times
robertninho
1 year, 6 months ago
D. Terraform configuration should be written before terraform import is executed The terraform import command is used to import existing infrastructure into Terraform, so that it can be managed as part of your configuration. In order to use terraform import, you need to have a corresponding Terraform configuration file that defines the desired state of the infrastructure. Therefore, it is generally a good idea to write the Terraform configuration file before running terraform import. This will allow you to specify the desired state of the infrastructure, including any resources that you want to import and any additional resources or configurations that you want to add.
upvoted 1 times
...
...
InformationOverload
1 year, 6 months ago
Selected Answer: D
Terraform configuration files should be written before running the terraform import command on existing infrastructure. The configuration files define the infrastructure that Terraform will manage, and the terraform import command is used to import existing resources into the configuration so that Terraform can manage them.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
ex Want to SAVE BIG on Certification Exam Prep?
close
ex Unlock All Exams with ExamTopics Pro 75% Off
  • arrow Choose From 1000+ Exams
  • arrow Access to 10 Exams per Month
  • arrow PDF Format Available
  • arrow Inline Discussions
  • arrow No Captcha/Robot Checks
Limited Time Offer
Ends in