This Terraform project provisions a free-tier Oracle Cloud Infrastructure (OCI) virtual machine (VM) with an attached block volume. It is designed to help users quickly deploy and manage a free-tier VM instance with persistent storage.
- Provisions a free-tier VM instance in OCI.
- Attaches a block volume for persistent storage.
- Configurable through
terraform.tfvars. - Uses
cloud_init.yamlfor instance initialization.
- Install Terraform.
- Set up an OCI account and generate API keys.
- Configure your OCI CLI with the required credentials.
-
Clone the Repository
git clone <repository-url> cd oci_free_vm_with_volume
-
Configure Variables Update the
terraform.tfvarsfile with your OCI credentials and desired configuration:tenancy_ocid = "<your-tenancy-ocid>" user_ocid = "<your-user-ocid>" region = "<your-region>" compartment_ocid = "<your-compartment-ocid>" ssh_public_key = "<path-to-your-ssh-public-key>"
-
Initialize Terraform Run the following command to download the required providers:
terraform init
-
Plan the Deployment Preview the changes that Terraform will make:
terraform plan
-
Apply the Configuration Deploy the resources to OCI:
terraform apply
Confirm the prompt with
yes. -
Access the VM Use the public IP address of the VM to SSH into it:
ssh -i <path-to-private-key> opc@<vm-public-ip>
To destroy the resources created by this project, run:
terraform destroyConfirm the prompt with yes.
main.tf: Defines the OCI resources to be provisioned.variables.tf: Declares input variables for the project.terraform.tfvars: Contains user-specific variable values.cloud_init.yaml: Specifies initialization scripts for the VM..terraform.lock.hcl: Tracks provider versions.
- Ensure that your OCI account has sufficient free-tier resources available.
- Modify
cloud_init.yamlto customize the VM initialization process.