Before you can import the resource’s current state, what must you do in order to prepare to manage these resources using Terraform?

Posted by: Pdfprep Category: VA-002-P Tags: , ,

You want to use terraform import to start managing infrastructure that was not originally provisioned through infrastructure as code.

Before you can import the resource’s current state, what must you do in order to prepare to manage these resources using Terraform?
A . run terraform refresh to ensure that the state file has the latest information for existing resources.
B . update the configuration file to include the new resources
C . modify the Terraform state file to add the new resources
D . shut down or stop using the resources being imported so no changes are inadvertently missed

Answer: B

Explanation:

The current implementation of Terraform import can only import resources into the state. It does not generate a configuration. Because of this, and prior to running terraform import, it is necessary to manually write a resource configuration block for the resource to which the imported object will be mapped.

First, add the resources to the configuration file:

resource "aws_instance" "example" {

# …instance configuration…

}

Then run the following command:

$ terraform import aws_instance.example i-abcd1234

Leave a Reply

Your email address will not be published.