Saturday, April 12, 2025

 

OCI Resource Manager

OCI Resource manager is an automation tool for infrastructure. It can be considered as Infrastructure as a code tool. It executes the terraform code and provisions the resource. It’s a managed service for Terraform in OCI.

We would have provisioned resources using OCI market place image. Basically, terraform code was written behind for provisioning market place image in OCI and that terraform code will be executed via Resource manager. So knowingly or unknowingly we use Resource manager for provisioning resources in OCI.

Stacks

OCI resource manager bundles the terraform code and required attributes/variable in a package called Stacks. The stacks will be validated through plan and apply phase which is similar to terraform plan and apply. The variables can have default value or it can collected dynamically during execution.

Resource manager can be invoked in OCI console through  Developer Services -> Resource Manager.

 

Lets see how to execute a terraform code using Resource manager.

In the Resource manager window choose Stacks -> Create stack.

 

Stack can be created in 4 ways.

My configuration: Stack creation with our own terraform code.
Template: A set of defined templates available like market place images and stack can be created using that.
Source code control system: Terraform code stored at Bitbucket Cloud, Bitbucket Server, DevOps, GitHub, or GitLab can be used to create stack. Based on chosen repository platform, details will be collected to create stack.
Existing compartment: This is very useful and unique feature of Resource manager. It can read the existing resources and generate terraform code of that. It will be useful to redeploy the resources in other region or other tenancy.

In this article lets examine first option – My configuration.

My configuration – We need to provide terraform code to create stack. The terraform code can be uploaded as folder or object storage bucket URL or Zip file.

It has option to choose custom terraform provides, but that would require the provider to be stored in the object storage bucket. Hashicorp is used here.

Stack name and description fields are optional and stack creation requires compartment to create. Also, it has option to specify the preferred terraform versions to execute the stack.

In this article we use terraform code of vcn creation and it has been uploaded as zip file.

The next page will have details of variables needed to execute the stack.  In case variables are specified with default value in the code, that will be displayed here. It can be modified and also values can be specified to other variables.

 

After confirming values, click next.

The next page will display all the variable and its value.

It has option to execute this stack along with creation. In case we want to perform terraform plan to preview the changes, not to choose the ratio button Run apply.

The stack has option to perform Plan and Apply.

Edit option will allow to recreate the stack with same name. We can upload new terraform code if required. Plan will perform terraform plan with a task name.

Logs column will show if any warnings or errors are observed.

If the plan succeeded, we could see the banner in green color with the status.

Logs can be downloaded for future reference. Also Terraform configuration and Terraform plan (as binary or json file) can be downloaded.

When plan is succeeded, we can proceed with apply.

 

 

Apply can proceed with automatic approval or specify the plan which had success.

Apply with automatic approval will perform terraform plan and also execute the code. Logs will show the details of execution. Also Terraform configuration and Terraform state file can be downloaded.

 

 

 Advantage of Resource manager:

1)     Its serverless, we don’t need resource to execute terraform code.

2)     It has native terraform integration using Hashicorp.

3)     State files are maintained internally and has provision to download.

4)     GUI based execution.

5)     All stack executions are recorded and it can be referred at any point of time.

No comments:

Post a Comment

 OCI IAM - OCI Command line - Uploading API Keys to User in Default and Custom Domain In our previous post, we explored how to create users ...