Automating network deployments on OCI using Resource Manager

April 19, 2024 | 4 minute read
Aditya Kulkarni
Cloud Solution Technologist, Networking
Text Size 100%:

Introduction:

OCI console makes it easier to provision the resources customers want quickly and efficiently. Customers usually start with very small environments that tend to grow as they get mature on OCI. Once the footprint expands and environments get bigger, it’s a cumbersome task to manage it all manually.

This blog will demonstrate, with an example:

  1. How to use Resource Discovery feature under Resource Manager to bring existing environment under Terraform
  2. Create a template that we can use to repetitively to replicate for DR or other purposes.

Network Diagram:

For this demonstration, I am using a most commonly used hybrid DNS scenario (Scenario 4) which is covered by my colleague in this blog: https://www.ateam-oracle.com/post/oci-private-dns---common-scenarios

Network Diagram

Solution:

I have already implemented the above network scenario manually in my tenancy.

1. Use Resource Discovery to generate a terraform configuration for the existing environment:

On OCI console, click on Developer Services Resource Manager Create Stack:

Check the box for ‘Existing Compartment’ and select the appropriate compartment and region.

Resource Discovery

 After specifying name and target compartment, hit ‘Create.’       Resource Discovery

2. Download the Terraform configuration:

You can now see the construct under ‘Stacks’. Click on the one we created previously and download the terraform configuration:

Download Terraform

3. Modify the terraform configuration as needed:

This step will differ according to the deployment needed. For example, in my configuration, I had to change following main things to suit my target deployment:

  • Deleting the existing OCIDs
  • Replacing existing IP ranges for VCNs and subnets
  • Replacing existing display names
  • Adding Remote Peering Connection on top of the existing region’s configuration
  • Adding second OCI provider for the remote region
  • Running Core and DNS codes independently to manage dependency.

4. Deploy the Terraform configuration in the target location:

On the OCI console, under Developer Services, click on Resource Manager create Stack.

    Select My Configuration and upload a folder or a zip file of the terraform configuration:

    Deployment

    Optionally, you can give this stack a name and select the target compartment.

    Deployment

Click ‘Next’

Based on your terraform configuration, you will be asked to specify variables. In my case, its local and remote region. Compartment and tenancy OCIDs are filled in automatically.

Variables

Once the stack gets created use ‘Terraform Plan’ to verify the resources you plan to deploy and that there are no errors. After that, use Terraform Apply to deploy the resources. You can again download the terraform configuration on this tab if needed. If you want to modify the existing configuration, you can edit the stack as well:

Deployed Stack

For the given network scenario, I am using for this blog, I have published the terraform code on the Git-Hub:

https://github.com/oracle-quickstart/oci-security-networking/tree/main/Networking/Automations/oci-hybrid-dns

Follow the instructions carefully in the README which are tailored for this example and hence may differ from this blog.

Conclusion:

In this blog, we learnt how to use Resource Discovery feature of Resource Manager to bring the existing infrastructure under terraform and create a customized terraform template which you can use repetitively for DR or in cases where you need to deploy the same infrastructure multiple times. This will result in saving valuable time of OCI customers and manage the infrastructure efficiently.

 

 

Aditya Kulkarni

Cloud Solution Technologist, Networking


Previous Post

Automate CPQ Data Table Exports

Shea Nolan | 4 min read

Next Post


Implementing a Complex Transformation in OIC

Siming Mu | 5 min read