I was working on automation using REST API (Representational State Transfer – Application Programming Interface) and found it very interesting and easy to implement with a simple command to deploy services on OCI (Oracle Cloud Infrastructure). In this blog, I will show you how to deploy DBCS (Oracle Database Cloud Service) using REST API.
I know you are wondering why I need to deploy using REST API if I have the console. You can schedule a job to stop/start DBCS and save costs. Especially when you doing any testing, auto stop/start will help, it will save time and money.
There are many ways to use APIs, I am using oci-curl function in this blog available by the OCI team. OCI_CURL will sign and encrypt your APIs so they are not sent in clear over the internet. OCI-CURL can be used on Linux and windows, I am using windows here.
You can use the below link to copy oci-curl script.
You only have to change these 4 parameters in this script as per your environment.
Tenancy OCID, USER OCID, KeyFingerprint, and private key .pem file location. You can easily get it from the OCI console.
here is my JSON file here…
Now I have everything, so I just created a small shell script
So to deploy the DB System, I just need to run the shell script like ./createdbsystem.sh and magically starts to begin 🙂
Here is the output:
And when I go to the console, I can see its provisioning…
You can go to the work request to see how much was completed…
It will take like 20-30 mins to complete and then you can connect to the node using your private key.
Delete or terminating the DB System is, even more, simpler because you don’t need any configuration file, you need the OCID of the DB System.
Here is the script I created for termination…
Now we can schedule these jobs in crontab or windows scheduler to automate start/stop.