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.
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
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
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 ...
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.
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?!
"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
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
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.
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.
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.
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.
Before you run terraform import you must manually write a resource configuration block for the resource. https://developer.hashicorp.com/terraform/cli/import
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
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.
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
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.
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.
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.
Uma10
Highly Voted 1 year, 10 months agozyxphreez
Highly Voted 1 year, 10 months agoSanderIsTheBestCloudShaper
1 year, 9 months agoAB7088
1 year, 6 months agoRVivek
1 year, 9 months agolezgino
1 year, 5 months agopetersoliman
Most Recent 7 months, 1 week ago8876ca1
3 weeks, 2 days agolukacs16
12 months ago[Removed]
1 year agoJhaggar
1 year, 1 month agoFawadK
1 year, 2 months agokiran15789
1 year, 2 months agoChinensis
1 year, 3 months agocamps
1 year, 3 months agocamps
1 year, 3 months agonoobster
1 year, 3 months agoTechHero
1 year, 5 months agoZeppoonstream
1 year, 5 months agogekkehenk
1 year, 5 months agoAndreaw
1 year, 6 months agorobertninho
1 year, 6 months agoInformationOverload
1 year, 6 months ago