OCI Instance Using Terraform
$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
Then set these attributes
- user ocid
- tenancy ocid
- key file (path to your private keyfile)
- region
Access these configurations from this path ~/.oci/config
Add the API key to the user
- Open user details display page
- Open API keys under resources
- Add API key
- Paste the public key
Create Child instance
Compartment to contain my instance and take the ocid
to be used as a compartment_ocid
Get the image_ocid
from this link, I used the Canonical-Ubuntu-22.04-Minimal-2022.08.16-0
image.
create the OCI provider in the specific region
provider "oci" {
region = var.region
user_ocid = "..."
fingerprint = "..."
private_key_path = "/home/mahmoud/.oci/oci_api_key.pem"
tenancy_ocid = "..."
}
- Run terraform initialize to install OCI Plugin
- Run terraform apply to create my resources on the OCI cloud
$ terraform apply --var-file dev.tfvars
That is the running instance