Oracle Cloud Infrastructure 2022 Architect Professional — Question 32
You are a DevOps engineer working for a high tech company, and are using Terraform to maintain your Oracle Cloud Infrastructure (OCI) resources. You have created a Terraform script that would create the infrastructure for deploying a web service. But want to tune in some settings within the OCI Instances using a shell script.
How should you write your Terraform script to run the shell script on OCI instance?
Answer options
- A. Use provisioner "remote-exec" in your code to run the shell script.
- B. Use provisioner "local-exec" in your code to run the shell script.
- C. Use resource "oci_core_instance" to create the instance and run the shell script.
- D. Use provisioner "oci-remote-exec" in your code to run the shell script.
Correct answer: A
Explanation
The correct answer is A, as the 'remote-exec' provisioner is specifically designed to run scripts or commands on a remote machine, which is the OCI instance in this case. Option B is incorrect because 'local-exec' runs commands on the machine where Terraform is executed, not on the OCI instance. Option C is misleading; while creating the instance is necessary, it does not specify how to run the shell script. Option D is incorrect because 'oci-remote-exec' is not a valid provisioner in Terraform.