Tuesday, April 21, 2026

End-to-End CI/CD Pipeline using Azure DevOps and Terraform for Oracle Cloud Infrastructure (OCI)

 Learn how to build a complete CI/CD pipeline using Azure DevOps and Terraform to automate Oracle Cloud Infrastructure (OCI). This step-by-step guide covers repository setup, service connections, Terraform configuration, pipeline creation, self-hosted agents, and deployment strategies. Ideal for DevOps engineers and cloud architects working with OCI, Azure DevOps, and Infrastructure as Code (IaC). Improve automation, scalability, and deployment efficiency with real-world implementation insights.

Introduction

In today’s cloud-native world, automation is the backbone of scalable infrastructure. In this blog, I’ll walk you through setting up a complete CI/CD pipeline using Azure DevOps and Terraform to deploy resources on Oracle Cloud Infrastructure (OCI).

This approach enables:

  • Infrastructure as Code (IaC)
  • Automated deployments
  • Version-controlled infrastructure
  • Scalable and repeatable environments




Create Azure DevOps Repository







Create a PAT token in Azure

Go to your profile and 





Clone the blank repository to your local machine  using an IDE. I had used VsCode


Download the terraform extension in Azure.







Create service connection to OCI





Choose OCI for terraform









Save the details


Prepare the terraform codes

Note: The terraform state file will be stored in the OCI object storage.


Create the variables in ADO





Click on pipelines. Inside we have the library







Also upload the private key to the secure files which will be referred during the execution






The local machine should have the OCI-CLI installed and configured so that terraform connects to the target OCI tenancy. 


Github Repo:-  https://github.com/samratsinha/ADO-OCI-Terraform


Push the code to ADO Repo





in ADO






Create the ADO Pipeline
















Save it



Trigger the CI/CD Pipeline




Every commit in the code will trigger the ADO pipeline.


In Azure








in OCI






From the screenshot above, we can see that the pipeline completed successfully and created all the resources in OCI needed to run a VM. This concept can be scaled up as per the requirement.

In continuation to this blog, the part 2 of this blog will discuss about how we can add an another stage to the pipeline which is terraform destroy which will only run after the approval is provided in the staging pipeline.

Till then, continue learning cloud. Hope this will help someone.





No comments:

Post a Comment