1Z0-1067-25 practice question 13 of 15

You are working with Terraform on your laptop and have been tasked with spinning up multiple compute instances in Oracle Cloud Infrastructure (OCI) for a project. In addition, you are also required to collect IP addresses of provisioned instances and write them to a file and save it in your laptop. Which specific Terraform functionality can help accomplish this task? (Choose the best)

Full set: 93 questions
Answer options
A:

A. Terraform remote-exec

B:

B. Terraform remote state

C:

C. Terraform modules

D:

D. Terraform local-exec

Correct answer
Correct Answer:
D. D. Terraform local-exec
Explanation

The requirement is to perform an action on the local machine (the laptop running Terraform) after a resource is created in OCI. The local-exec provisioner is designed for this exact purpose. It invokes a local executable after a resource is created or destroyed. In this scenario, it can be used to run a script that takes the IP addresses of the newly created instances as input and writes them to a local file. This happens on the machine where the terraform apply command is executed.

Why Incorrect

A. The remote-exec provisioner runs scripts on the remote resource that Terraform creates (e.g., on the new compute instance), not on the local machine.
B. Terraform remote state is a feature for storing the state file in a shared, remote location, which is unrelated to executing local scripts.
C. Terraform modules are reusable packages of Terraform configurations for creating and managing resources, not for executing local commands post-provisioning.

References

1. HashiCorp Terraform Documentation, "Provisioners - local-exec". The documentation states, "The local-exec provisioner invokes a local executable after a resource is created. This invokes a process on the machine running Terraform, not on the resource."

2. HashiCorp Terraform Documentation, "Provisioners". The overview explains the difference between local and remote provisioners, clarifying that local-exec is for actions on the control machine.

Scroll to Top