With Resource Manager, you can use Terraform's remote exec functionality to execute scripts or commands on a remote computer. You can also use this technique for other provisioners that require access to the remote resource.
On Windows, WinRM must be enabled. On Linux or Unix, SSH must be enabled.
A key pair used for signing API requests, with the public key uploaded to Oracle. For more information on generating and uploading keys, see Required Keys and OCIDs.
Authenticating 🔗
We recommend using one of the following approaches, depending on whether you have access to the Vault service. For more information, see Overview of Vault.
If you do not have access to the Vault service, you can dynamically generate a key pair and store them in the state file.
Generate a key pair using a TLS resource.
When you launch the compute instance, use the public key from the TLS resource.
When you establish the SSH connection, provide the private key.
Caution
You should not save your private key in your Terraform configuration file because that is not a secure location.
The following sample demonstrates how to use the TLS private key resource to provision a compute instance, then perform a remote execution on that instance.
This example demonstrates how to use a connection construct for remote exec. Terraform uses a number of defaults when connecting to a resource, but these can be overridden using a connection block in either a resource or provisioner. For more information, see Provisioner Connection Settings.