1. Getting Started with Oracle Cloud Infrastructure

Jeff Davies
Aug 1 · 8 min read

Getting started with Oracle Cloud Infrastructure (OCI) can be daunting. It has a ton of functionality, allowing you to create anything you want on the cloud. However, all of that power and functionality can be intimidating when you are just starting on the OCI learning curve.

In this series of articles, I will walk you through some common uses for OCI. In each article, we will have a specific goal in mind, and then achieve that goal by following the detailed steps. Before long, you will be able to solve all sorts of programming/networking/web challenges using OCI.

But I don’t have access to OCI!

Getting access to your own instance of OCI is simple and free. You can register for a free trial at https://cloud.oracle.com. You will be prompted for a valid credit card, but the card will not be charged at the end of the trial unless you explicitly opt in. The free trial is limited to about 30 days or $300 worth of charges, whichever comes first. In my experience, for a single developer who is learning OCI, this is more than enough.

No Powerpoint Here

I won’t start with an overview of what OCI is. In my experience, it is easy to get lost in the massive number of details and capabilities of OCI. Instead, I prefer to set goals that most developers would have and already understand; then show you how to achieve those goals in OCI. Along the way, you will learn the OCI architecture from the ground up. On occasion, I may give some preliminary info so you can understand the relationships between various OCI components and concepts, but I’ll do that only as needed.

Dude, Just Get To It!

For our first article we will create a compute instance (think web server) that will host a simple, “hello world” website running on Node. To get started, go to https://cloud.oracle.com and log into OCI. This will bring up the main OCI dashboard view in your browser.

The main OCI dashboard in your browser.
The main OCI dashboard in your browser.

Click on the Create VM Instance box. You will be prompted to select the compartment for the compute instance. You will only have one at this point: the root compartment. I’ll go over compartments in the future, for now, just select the one and only compartment available to you and press the Confirm button.

Select the one and only compartment available to you.
Select the one and only compartment available to you.

Now you will fill in the additional details needed to create the compute instance. First you need to name your compute instance. I named mine “webserver1” to capture what that instance does. By default, an availability domain will be selected for you and the default image of the server will be Oracle Linux 7.6 (or later, depending on when you’re reading this article). The default instance type will be a Virtual Machine.

Scroll down and then accept the default shape. The “shape” is the computing power you want to use. By default, the smallest is selected and that’s exactly what we want. Remember, you can select a beefier shape, but it will be more expensive to run. Since we are in a trial account, we want to minimize costs and not waste our trial credits on computing power that wont ever be used.

Also, don’t make any changes to the boot volume for the purposes of this article.

Select the shape of the compute instance.
Select the shape of the compute instance.

Scrolling further down, you need to select your SSH key so that you can later SSH into the compute instance. If you don’t have an SSH key that you can use, just search for “SSH Key Generation [PLATFORM]” and follow the instructions specific to your platform. Keep track of the keys you create! You will need it to connect to your instance via SSH.

In the final steps, you will have to provide a name for a new Virtual Cloud Network (VCN). Think of a VCN as a container for your compute instances and other resources. Your VCN will ultimately contain a variety of things, but let’s keep it simple for now. Enter any name you like. I used the name trial_vcn for this series of articles.

Name your new virtual cloud network
Name your new virtual cloud network

Click the Show Advanced Options if you’re curious about what else you can specify. I won’t bother explaining all of the advanced options in this article. When you’re ready, press the Create button to create your compute instance.

This will display the dashboard for your compute instance. You can see by the orange square in the top left corner of the page that the instance is still in the Provisioning state. You can also see some other useful information about the instance.

It will take approximately 5 minutes or less for the instance to finish provisioning. When the status changes to the green Running icon, the instance is ready for use.

Now we need to deploy some software onto our instance to make it useful. To do that we will need to SSH into our instance using the public IP address of the compute instance (I have redacted it in the screenshot above). Using your favorite SSH tool (I’m using the command line on my Mac) run the following command:

ssh -i ~/oci_key opc@[Public IP]

Be sure to substitute in the Public IP Address of your compute instance. Also, as you can see from the command, I have the private SSH key located in my home directory and we are logging in as the opc user. This is the main user account on your compute instance and essentially has root privileges.

Let’s Install Node.js

We will create a simple web server using Node.js. To install Node onto your compute instance you can go to https://nodejs.org/dist and look around to find the specific version of Node you want. Alternatively, you can just download the version in the latest/ directory

At the time of this writing the latest version of Node is v12.7.0. So the command I used to download it onto my compute instance was:

curl https://nodejs.org/dist/latest/node-v12.7.0-linux-x64.tar.xz > nodejs.tar.xz

This image of Node is only about 13MB and the download is almost instantaneous.

Now that we have Node on our compute instance, we install it with the following command.

tar -xvf nodejs.tar.xz

We add Node to our PATH variable by opening our .bash_profile file and modifying the line that defines the PATH variable. I use vi as my editor since it’s built into linux.

vi .bash_profile

My modified PATH variable in my .bash_profile is


Back in your SSH console, you can activate your changes to your .bash_profile with the following command:

source ~/.bash_profile

Use the following command to make sure your PATH is correct by testing the node command.

node -v

Create the Web Server

Now that we have Node installed, let’s create our web server. First let’s create a directory for our Node package that will be our web server. From the SSH console enter these commands:

mkdir helloserver
cd helloserver
npm init

Accept the defaults for everything for which npm prompts you. Since the default name for the main file is index.js, we need to create that file. Again I used vi and wrote the following code:

const http = require(‘http’);
hostname = ‘’;
const port = 3000;
const server = http.createServer((req, res) => {
var currentDate = new Date();
var utcDate = currentDate.toUTCString();
res.statusCode = 200;
res.setHeader(‘Content-Type’, ‘text/plain’);
if(req.method === ‘GET’ && req.url === ‘/greeting’) {
// This is the Hello World invocation
res.end(‘Hello World\n’);
console.log(‘Hello World invoked ‘ + utcDate);
} else {
// This is the health check from the load balancer
//console.log(`Health check `+ utcDate);
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);

Now run the code with the following command:

node index.js

If you typed in everything correctly, the index.js program should be running and listening to port 3000. Let’s test it to be sure. Open another console and create a second SSH connection into your compute instance.


And you should get the response Healthy. However, all is not well yet. If you try the curl command using your Public IP address, it will timeout. Why does it work from and not from the public IP address? Because there is a firewall that doesn’t allow traffic to port 3000 by default. By default, the firewall only allows traffic through for SSH. So we need to configure the firewall to allow for traffic across port 3000.

Configuring the Firewall

Opening port 3000 permanently and then reloading the firewall with the new settings is done with the following commands:

sudo firewall-cmd --permanent --add-port=3000/tcp
sudo firewall-cmd --reload

Note the double dashes. However, this isn’t quite enough. If you try to hit port 3000 using the public IP address, it will still time out. There is one more thing we need to do to route traffic to our web server on OCI.

Create a Stateless Ingress Rule

In addition to the firewall. OCI also uses security lists to handle how network traffic can be routed. In order to get traffic routed to our helloserver on port 3000, we need to create a new ingress rule.

You can navigate to the security lists for your VCN by clicking on the “hamburger” icon in the top left corner of the browser screen and then selecting Networking -> Virtual Cloud Networks from the menu.

Using the menu to navigate to the VCN page
Using the menu to navigate to the VCN page

Click on the name of your VCN (you will likely have only 1). Under the Resources section on the left side of the browser, click on the Security Lists link.

Navigate to the Security Lists

Click on the default security list (again, you should only have 1 if you are following this article using a trial account). When the page loads, click on the blue Add Ingress Rule button. Fill in the ingress rule as shown in the next image.

Creating the ingress rule

This rule simply tells the VCN that all TCP requests from any IP address that are directed to port 3000 are allowed. For a more in depth description of Security Rules, read this article.


Now you can hit the public IP address using port 3000 from any computer. You can test it with curl or just point your web browser to the page and you should see the Healthy response message.

We’ve just scratched the surface of OCI. In future articles we will look into scaling this web server across multiple compute instances, load balancing, creating databases to support our web server, and much more. I hope this gives you a taste for OCI and what it can do. You can read much more about OCI at the official site.

Oracle Developers

Aggregation of articles from Oracle & partners engineers, Groundbreaker ambassadors & the developer community on all things Oracle Cloud and its technologies. The views expressed are those of authors solely and do not necessarily reflect Oracle's. Contact @jimgris or @brhubart

Jeff Davies

Written by

Long time software engineer, software architect, technical evangelist and motorcycle enthusiast.

Oracle Developers

Aggregation of articles from Oracle & partners engineers, Groundbreaker ambassadors & the developer community on all things Oracle Cloud and its technologies. The views expressed are those of authors solely and do not necessarily reflect Oracle's. Contact @jimgris or @brhubart

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade