Voiced by Amazon Polly |
Introduction
In today’s fast-paced IT landscape, businesses are increasingly adopting cloud automation to streamline infrastructure deployment and management. Oracle Cloud Infrastructure (OCI), combined with Terraform, empowers organizations to embrace Infrastructure as Code (IaC), enabling faster, consistent, and reliable provisioning of cloud resources.
Freedom Month Sale — Upgrade Your Skills, Save Big!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
Why Oracle Cloud Infrastructure with Terraform?
Oracle Cloud Infrastructure (OCI) is a next-generation cloud designed to run any workload securely and efficiently. Terraform, developed by HashiCorp, is a leading IaC tool that allows you to define infrastructure in declarative configuration files.
Together, they provide:
- Automation: No more manual provisioning; everything is managed through reusable
- Consistency: Reduce human errors and ensure predictable
- Scalability: Manage small environments and enterprise-grade deployments with the same approach.
- Cost-effectiveness: Control, monitor, and optimize infrastructure
Key Features and Benefits of Oracle Cloud Infrastructure
- High Performance and Scalability
OCI is built on a high-performance backbone with low-latency networking. Elastic scaling ensures resources can scale up or down automatically, guaranteeing optimal performance and cost control.
- Comprehensive Security
Multi-layered security with encryption, isolated virtualization, identity management,
and compliance certifications. Advanced monitoring and threat detection mechanisms built into the platform.
- Cost-Effective Cloud Services
Pay-as-you-go pricing ensures you only pay for what you consume. Built-in cost governance tools for analysing and predicting usage.
- Flexibility and Compatibility
Wide support for multiple databases, operating systems, and enterprise applications. Seamless hybrid integration with on-premises environments.
- Extensive Service Portfolio
Rich portfolio of services including compute, storage, networking, databases, analytics, machine learning, and more. Designed to integrate smoothly for complete workload management.
Common Use Cases of OCI
- Enterprise Applications – Running critical workloads like Oracle E-Business Suite, PeopleSoft, and JD Edwards.
- Data Management & Analytics – Powering big data, Oracle Autonomous Database, and analytics pipelines.
- High-Performance Computing (HPC) – Ideal for financial simulations, engineering workloads, and AI/ML training.
- Disaster Recovery & Backup – Cost-effective data protection with strong reliability.
- Development & Testing – Developers can rapidly spin up test environments to accelerate delivery.
Prerequisites
Before provisioning OCI resources with Terraform, ensure the following are in place:
- Oracle Cloud Infrastructure Account
- Sign up at Oracle Cloud Free Tier for free
- OCI CLI Installed
- Install via OCI CLI
- Terraform Installed
- Download from Terraform
- API Keys Generated
- Follow OCI API Key
- OCI CLI Configured
- Configure CLI with tenancy OCID, user OCID, fingerprint, and region.
Connecting OCI with Terraform Using API Key Authentication
- Generate an API Key Pair
On your local machine:
1 2 3 4 5 |
mkdir ~/.oci cd ~/.oci openssl genrsa -out oci_api_key.pem 2048 chmod 600 oci_api_key.pem openssl rsa -pubout -in oci_api_key.pem -out oci_api_key_public.pem |
This creates:
pem → your private key (keep safe!)
pem → your public key
Upload Public Key to Your OCI User Account
Log in to OCI
Open User Settings → API Keys → Add API Key.
Upload pem.
OCI generates a Fingerprint (example: 20:3b:97:13:…:7f).
- Collect Required Information
You now need the following values:
- Tenancy OCID – Found under Tenancy Details in the
- User OCID – Found under User Settings.
- Fingerprint – Shown when you upload your API
- Region – g., us-ashburn-1.
- Private Key Path – Path to pem (e.g., ~/.oci/oci_api_key.pem).
- Verify OCI CLI Works (Optional)
- Before using Terraform, test authentication via the OCI CLI:
- Configure Terraform Provider with API Key
- Create a Resource Using Terraform
1 2 3 4 5 |
resource "oci_core_vcn" "my_vcn" { cidr_block = "10.1.0.0/16" display_name = "my-api-key-vcn" compartment_id = "<your_compartment_ocid>" } |
- Run Terraform Commands terraform init
terraform plan terraform apply
Conclusion
Provisioning Oracle Cloud Infrastructure with Terraform simplifies cloud management by automating resource creation, ensuring consistency, and reducing operational overhead.
By following the steps in this blog, you’ve seen how to:
- Set up Terraform for OCI
- Configure API keys and provider details
- Create and deploy a VCN using IaC principles
This foundation opens the door to more advanced use cases such as multi-region deployments, complex networking setups, and enterprise-scale automation.
Start small, automate more, and scale with confidence using OCI and Terraform Official References Used:
- Oracle Cloud Free Tier
- How to Upload the Public Key
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#three)
- Terraform Downloads
https://releases.hashicorp.com/terraform/1.13.1/terraform_1.13.1_linux_amd64.zip
Freedom Month Sale — Discounts That Set You Free!
- Up to 80% OFF AWS Courses
- Up to 30% OFF Microsoft Certs
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

WRITTEN BY Martuj Nadaf
Comments