Terraform OCI Instance with Block Volumes

This is a basic example for creating a compute instance with paravirtualized block volumes. The main.tf file contains the resources and variable declarations. The terraform.tfvars file contains the values for the various parameters. This is the only file you should have to change.

This article assumes that you are familiar with Terraform already. I use syntax for version 0.12.

terraform.tfvars (make sure to use your own values as needed).

 

main.tf

Once the instance is provisioned, you should see the boot volume(s) attached you can log into the instance and mount them.

The block volumes are referenced as per terrafroms.tfvars file (e.g. /dev/oracleoci/oraclevdb) See OCI Docs for details.

Pratition the volume with fdisk (follow the prompts to configure the partition)

Create a file system:

Create a directory to mount the device in:

Mount the device

Add an entry to /etc/fstab:

I hope this helps. Don’t forget to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.