Practical Guide To OCI Lab Guide
Practical Guide To OCI Lab Guide
A Practical Guide to
Oracle Cloud for Infrastructure
Version 1.1
© 2020 TechTipsOnDemand.com
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Table of Contents
DISCLAIMER ....................................................................... 3
Cost Saving Best Practices ...................................................... 3
Lab Guide Overview .............................................................. 3
Signing up for OCI .................................................... 5
Core OCI Compute ................................................... 9
Core OCI Networking ............................................. 26
Core OCI Block Storage .......................................... 53
Core OCI Object Storage ......................................... 77
Core OCI Load Balancer ....................................... 102
Core Identity and Access Management .................. 117
References .......................................................................... 152
Appendix A : How to Access Private OCI Compute Instances using a Jump Server 152
© 2020 TechTipsOnDemand.com 2
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
DISCLAIMER
The student performing the steps in this lab guide is solely responsible for any charges incurred. The Author of this course and
TechTipsOnDemand are not liable for any charges you may incur while performing any of the labs or exercises associated with this course
and lab guide.
While the Author makes every attempt to leverage OCI services that are part of the Oracle Free Tier Trial Period, the availability of such
services as part of a free trial period are subject to change by Oracle and may convert to a paid service.
Any service that is part of the Free Trial period becomes a paid service after the trial period expires, and as such is the financial responsibility
of the student and the organization which owns the OCI Tenancy where the costs are incurred.
1. Stop compute instances when you are not using them. Running compute instances cost money. Stopped instances do not cost money.
2. Delete block and boot volumes when you are done with them. Persistent storage such as block storage costs money.
3. Delete object storage objects when you are done with them. Persistent objects cost money.
The References section of this document contains links to the software needed for this lab, as well as links to online documentation for
reference.
System Requirements
There are very few system requirements for this course. Since everything we are doing is in the cloud, we simply need a computer with one of
the common operating systems and an internet connection.
© 2020 TechTipsOnDemand.com 3
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Organization
• Skills Learned describes what you will get out of the lab
• Overview describes the overall details of the lab
• Configuration Parameters defines parameters and values you will need to perform the lab
• Instructions provide the details steps needed to perform the lab
Links to required software can be found in the References section of this lab guide.
Need Help?
If you need help with the labs or have questions please write us at [email protected]
© 2020 TechTipsOnDemand.com 4
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Skills Learned
At the end of this exercise, you will be able to:
Overview
In this first lab you will sign up for the free-tier version of OCI. This lab will get you familiar with navigating the OCI console, viewing
account details, changing your password, and view billing information including creating a budget.
Instructions
The tenancy name will be used when logging into the OCI console.
1.5 For individual users of OCI, select the Pay-as-you-Go model (PAYGO).
1.6 After you complete the registration process, you will receive a welcome email from Oracle containing information on how
to log into your account.
© 2020 TechTipsOnDemand.com 5
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.7 Use the link in the welcome email to access the OCI Console. Log in using your email address and the credentials you
specified when signing up for OCI.
2 Preparing your Tenancy for this Lab Guide
2.1 Whether you are working in a brand new tenancy that is entirely yours alone or you are sharing one with your
organization or group, we are going to carve out an area within the tenancy where we are going to perform all the lab
exercises.
As you will learn in lectures on OCI IAM and Compartments, OCI has a feature concept called Compartments. A
compartment is a way to organize and group OCI resources in a tenancy. A compartment structure can be flat or it can
be hierarchical. Compartments are also used with OCI’s authorization policies so that types of resources can be
managed by one group in a compartment while permitting users of another group to use those resources.
It is fairly common to see large organizations set up a compartment structure that aligns with their corporate structure or
IT and development departments.
For this lab guide, you will do all your work under one top level compartment that we will call OCI_Labs.
2.2 To create a compartment, log into the OCI Console and navigate to Identity > Compartments from the stacked navigation
menu in the upper left-hand corner of the Console.
You will see at least two compartments already, possibly more. By default, every tenancy comes with at least a root
compartment. All other compartments will hang off the root compartment.
© 2020 TechTipsOnDemand.com 6
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
2.5 Click Create Compartment after filling in the information. Your compartment will be created. You may have to refresh
your browser window if the compartment does not immediately appear in the list.
In this section you will define a monthly budget and then specify when to get alerted based on forecasted or actual
usage.
3.2 Log into the OCI Console and click on the three stacked bars in the upper left to pop out the main navigation menu.
3.3 Navigate to Account Management > Budgets
3.4 Click Create Budget and provide the following details:
© 2020 TechTipsOnDemand.com 7
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Budget Scope: Compartment
Name: Provide any name for your budget
Description: Leave blank
Target Compartment: OCI_Labs
Monthly Budget Amount: Enter a value that you are comfortable with. Remember, this is the figure OCI will use to alert
you.
Under Budget Rules, specify whether you want to be notified based on actual spend or forecasted spend. For this
course, I would suggest actual spend.
Under Threshold Type, select whether you want to be notified if you come within a certain percentage of your budget or
an actual dollar amount. For example, if your budget was $100 and you specify a threshold of 80%, you will get notified
when you use $80 worth of OCI services. Likewise, if you specify an absolute amount, you will get notified when you
consume that absolute amount.
Under Email Addresses, be sure to include your email address and an email message to remind you why you are
getting an email from Oracle.
3.5 You can use OCI’s Cost Analysis tool to determine what services are costing you money. This is useful if your free trial
expires and your account converts to a normal paid account.
Access the Cost Analysis tool by going to Account Management > Cost Analysis.
3.6 You will be presented with a fairly typical reporting page. You can specify a date range and what type of report you want
to run. If you have created a new account, then this page will not be very excited since we have not used any services
yet.
Conclusion
In this lab you should have signed up for an OCI Account and with that received a free trial period. We also set up a budget so that we can be
alerted if we are using services that cost money and exceed our budget. Lastly, you got to see the Cost Analysis Tool which can be used to
generate real-time cost usage reports.
© 2020 TechTipsOnDemand.com 8
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Skills Learned
At the end of this exercise, you will be able to:
Overview
We are going to dive right into creating our first compute instance in OCI just to get our feet wet very quickly. In this lab we are going to keep
things simple by starting with how to create a compute instance and how to log into it, and of course how to stop and terminate the instance.
We start here because 1) Creating compute instances is why we are here so let’s just cut to the chase and 2) we need to know how to deploy
compute instances in order to demonstrate how all the other OCI IaaS features work.
Estimated Costs
You may incur costs associated with running compute instances that are not part of the Always Free Eligible tier. Oracle charges for how long
a compute instance is running and the OCPU/hour rate is based upon the compute shape being used, so it is recommended that you use the
smallest shape possible and stop all instances when you are done working with them to reduce your costs.
Oracle provides an online cost estimator which you can use to estimate your costs based on expected usage.
https://www.oracle.com/cloud/cost-estimator.html
© 2020 TechTipsOnDemand.com 9
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
A word of caution! A running compute instance costs money and requires that you have a paid account or are in the free trial period to
provision. While there is an Always Free Tier available, it limits you to two compute instances. To save on costs, always STOP your compute
instances when you are done using them. A stopped instance does not incur any costs associated with compute, however any persistent
storage will indeed incur some costs.
Instructions
Instructions for generating ssh keys on Linux and Windows machines will be provided below.
In a Linux terminal window run the following command to generate an RSA-based key with a size of 4096 bits.
The command will generate the private key oci_lab.id_rsa and the public key oci_lab.id_rsa.pub.
You can find more information on generating and managing SSH keys here:
https://www.ssh.com/ssh/keygen/
If you are on Windows, one of the more common SSH clients is PuTTY, a free SSH client and toolset that supports SSH
key creation and management.
Step 3. Generate a private key by first selecting RSA as the key type and the number of bits as 4096.
Then click the Generate button and move your mouse cursor around the PuTTYgen window. This is used to generate
some randomness that’s used in creating the private key.
Step 4. Once the generating is complete, select all the text in the ‘Public key for pasting … ‘ window shown below. Save
the text in a text file (using notepad or something similar) using the filename oci_lab.id_rsa.pub.
Step 5. Save the private key by clicking the Save private key button. Do not set a passphrase. Save the file using the
name oci_lab.ppk.
© 2020 TechTipsOnDemand.com 11
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Be sure to save the ppk (private putty key) in a safe location.
Power users can also use powershell and openSSH tools instead of using PuTTY.
Open a Powershell window (Press Win + R and type powershell) and follow the instructions for Generating SSH Keys on
Linux.
2 Creating a Virtual Cloud Network
2.1 In order to create a compute instance, we need a place to deploy it. When you deploy a server in a data center, you
physically mount it in a rack and then connect it to the network. In the cloud case, you will create a virtual network called
a VCN and subnets within that VCN.
There is an entire lab that focused on OCI Networking and VCNs in detail, however for this lab you will use a default
configuration from OCI that will give us a basic VCN to work with.
2.2 Log into the OCI console and navigate to Networking > Virtual Cloud Networks
2.3 Under List Scope, select the OCI_Labs compartment. Recall from Lab 1 that we created the OCI_Labs compartment. All
OCI resources we create will be created in this compartment.
2.4 Select Start VCN Wizard.
2.5 Select VCN with Internet Connectivity, then click Start VCN Wizard.
2.6 Under Basic Information, specify vcn1 for the VCN name.
Verify the compartment is set to OCI_Labs.
Leave all the other values alone as they are sufficient for this lab.
2.7 Click Next to move to the Summary screen. This screen shows us how the VCN will be created and with what OCI
resources.
The VCN wizard gives us a rather functional network which includes both a public and private subnet, and various
network gateways for accessing the internet and OCI services.
2.8 Click Create.
2.9 Once OCI creates the VCN and all its resources, you may click on the View Virtual Cloud Network button at the bottom
of the screen.
© 2020 TechTipsOnDemand.com 12
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3 Creating a Compute Instance
3.1 In this section you will launch a Linux compute instance in one of the public subnets you created earlier and connect to it
using ssh.
3.2 Log into the OCI console and navigate to Compute > Instances.
3.3 Under List Scope, select the OCI_Labs compartment if not already selected.
3.4 Click the Create Instance button.
3.5 The Create Compute instance screen provides a wide variety of parameters for configuring a compute instance.
Platform images are maintained by Oracle and are your typical general purpose OS images.
Oracle Images are also maintained by Oracle but are purpose built for specific workloads or configurations.
Partner Images are developed and maintained by trusted Oracle third parties.
© 2020 TechTipsOnDemand.com 13
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3.7 Select Show Shape, Network, and Storage options to reveal additional parameters.
3.8 If your region has more than one availability domain, you have the option of specifying which AD to launch the compute
instance in. It is a best practice to spread your compute instances across availability domains within a region to provide
© 2020 TechTipsOnDemand.com 14
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
some level of fault tolerance and high availability in the event one AD goes offline.
In the Networking lab, we created regional subnets which span all ADs within a region, whereas a regular subnet only
exists in one AD. Regional subnets eliminate the need to set up additional subnets in each region, create route rules and
configure security lists to permit compute instances to talk to one another.
3.9 Select Change Shape to select the type and size of compute instance we want to create. The selection of shapes will
be restricted depending on whether you have a paid account or a free tier account.
For this lab we are going to use one of the Always Free Eligible shapes.
*** Keep in mind that you are limited to the number of Always Free Eligible compute instances you can create in a
tenancy. If there are no free compute instances available, then you would need to register a form of payment with your
OCI account in order to provision additionfal compute instances. ***
Then click the Select Shape button to return to the compute instance screen.
© 2020 TechTipsOnDemand.com 15
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3.10 Next we want to configure the networking for this compute instance by specifying which network and subnet to launch
the compute instance in, and whether we want to assign a public IP address.
For this lab, we want to launch the compute instance in the bastion subnet we created earlier and assign a public IP
address so we can ssh into it.
© 2020 TechTipsOnDemand.com 16
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Virtual Cloud Network Compartment: OCI_Labs
Select a Virtual Cloud Network: vcn1
Subnet Compartment: root
Subnet: Public Subnet-vcn1(regional)
3.11 Under Add SSH Keys, you can upload a private SSH key or you can have Oracle generate one for you, or not specify
one at all.
For this lab we are going to use the SSH keys we generated earlier by specifying the public key. Oracle will take the
public key and bootstrap the compute instance with it. You hold on to the private key.
Select Choose Public Key Files to load the oci_lab.id_rsa.pub (public key) that was created in the first part of the lab.
It will take a little bit of time to provision the instance. After you launch the instance, you will be taken to the instance
details page which has important information about the compute instance.
The work request status will change from Provisioning to Running (if all goes well).
3.13 Once the instance is running, you will see various details that are specific to the instance, such as networking details.
Note the public IP and private IP addresses that have been assigned to the instance. The public IP address is generated
by Oracle from their pool of public IPs. You will connect to this compute instance using its public IP.
The private IP address is assigned out of the subnet that the instance resides in.
© 2020 TechTipsOnDemand.com 17
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Open a terminal window in linux and run the following command to connect to the compute instance:
Be sure to specify the location of the private key you created earlier and the public IP address of the compute instance
© 2020 TechTipsOnDemand.com 18
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
you created. You can find the public IP address in the OCI console on the details page for the compute instance.
-i specifies what private key (identity file) to use. In this case you must specify the location of the private key you created
earlier.
opc@public_IP_of_compute_instance specifies what user and what host to connect to. For example,
This command will connect to the public IP address of a compute instance (129.146.132.172) as username opc (default OCI
username for Orale Linux images) using the identity file oci_lab.id_rsa.
Under SSH > Auth, specify the private key you created earlier by clicking the Browse button.
© 2020 TechTipsOnDemand.com 19
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Go back to Session, enter a name for this session (ocilab) and click Save.
Click Open to open a connection to the compute instance. If you have any issues connecting to the new instance, be sure to
double-check:
1. You have specified the correct private key that goes with the public key on the compute
instance
2. You are connecting as user opc.
3. You are connecting to the correct public IP address for the compute instance. You can find the
public IP address in the OCI console under Compute > Instances.
4.4 Once you are connected to your compute instance, feel free to poke around the server.
Using the wizard to create a VCN automatically generated some basic network security rules that only allow us to SSH
into the network from the internet. We will learn more about securing VCNs in the OCI Networking lab.
© 2020 TechTipsOnDemand.com 20
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
5 Monitoring Health
5.1 Each OCI compute instance emits health and performance metrics to the OCI Monitoring service under the namespace
oci_computeagent.
The oci_computeagent namespace contains a variety of information specific to a compute instance, including CPU and
memory utilization, disk I/O, and network I/O.
5.2 You can quickly view the health of a particular compute instance by navigating to the compute instance (Compute >
Instances > bastion1 for example) and selecting Metrics as show in the screenshot below.
OCI provides an interactive report that allows you to look at metrics over a period of time. I
5.3 You can also access compute metrics from OCI Monitoring directly.
Navigate to Monitoring > Service Metrics from the main navigation menu.
Under Metric Namespace, select oci_computeagent
Select the OCI_Labs compartment.
This screen will display metrics for all compute instances in the OCI Labs compartment.
© 2020 TechTipsOnDemand.com 21
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
The specific shape of a compute instance determines the number of vNICS that can be created. In this lab we will create
a new compute instance that supports additional vNICS. The compute instance will be created in a public subnet but the
secondary vNIC will be deployed in a private subnet. In essence this compute instance will have a ‘leg’ in each subnet.
6.2 Create a new compute instance using the method above, by placing it the public subnet for vcn1.
Use a compute shape that supports more than 1 vNIC. For example, under Specialty and Previous Generation shapes,
select the VM.Standard.E2.1 shape, which supports max of 2 vNICs.
Configure the instance to use the same SSH key you created earlier.
6.3 Once the instance has booted and is running, select Attached VNICS from the compute instance’s resources menu.
6.4 Click the Create VNIC button and specify the following details:
Name: secondvnic
© 2020 TechTipsOnDemand.com 22
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Network: Normal setup
Subnet: Use the private subnet in the vcn1 VCN. Be sure to select the OCI_Labs compartment.
$ sudo su
$ wget https://docs.oracle.com/en-
us/iaas/Content/Resources/Assets/secondary_vnic_all_configure.sh
$ chmod u+x secondary_vnic_all_configure.sh
$ ./secondary_vnic_all_configure.sh -c
6.7 Run the following ifconfig command to confirm that a second interface has been created. Take note of the IP address
assign to the second VNIC – in this example it is ens5. This IP address comes out of the CIDR block for the private
subnet in VCN1.
The primary VNIC, ens3, is assigned an IP address from the CIDR block for the public subnet.
$ ifconfig -a
ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9000
inet 10.0.0.12 netmask 255.255.255.0 broadcast 10.0.0.255
ether 00:00:17:02:03:be txqueuelen 1000 (Ethernet)
RX packets 88007 bytes 143391102 (136.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 78519 bytes 71557388 (68.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
© 2020 TechTipsOnDemand.com 23
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Stopped: Instance is powered off. No compute cost is incurred for a stopped instance.
Running: Instance is up and running. Compute costs are being incurred on an hourly basis.
Terminated: Instance has been deleted. No compute cost is incurred for a terminated instance.
Instances that are running incur cost since compute is charged on an hourly basis. Instances that are not running, either
stopped or terminated, do not incur compute costs.
7.2 When you create a compute instance using the OCI console, OCI will automatically launch the instance into a running
state.
You can use the console to stop, reboot, terminate or start an instance.
7.3 Let’s stop our running compute instance by navigating to Compute > Instances.
You will see a list of compute instances. Select the 3 dots (ellipsis) next to the instance we created earlier as shown in
the screenshot below.
Select Stop to shutdown the instance. You will be presented with a warning about shutting down the instance. Go ahead
and confirm the shutdown.
© 2020 TechTipsOnDemand.com 24
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
7.4 The compute instance’s state will change from Running to Stopping. Eventually the state will transition to Stopped.
7.5 To restart the instance, click on the ellipsis again and select Start. The state will change from Stopped to Starting, then
Running.
7.6 You can terminate an instance while it is either stopped or running. A terminated instance is effectively deleted.
Select Terminate from the ellipsis menu. You will be asked whether to preserve the boot volume. Go ahead and check
the box to delete the boot volume.
Boot volumes normally cost money since they are persistent storage, so be sure to delete your boot volumes when
terminating compute instances. We will cover boot volumes in a later lab.
Conclusion
This lab showed you how to quickly provision a compute instance in a virtual cloud network and access it using SSH.
© 2020 TechTipsOnDemand.com 25
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Skills Learned
At the end of this exercise, you will be able to:
Overview
In this lab you will begin creating a virtual cloud network from scratch using a variety of OCI networking features. A VCN or virtual cloud
network is the foundation for building any network in OCI. Think of a VCN as your own virtual data center that is defined by a range of IP
addresses known as a CIDR block.
Subnets can be created to segment a VCN into smaller networks. Subnets are typically used to provide network isolation for different
workloads, such as application servers and databases. In a traditional environment, application servers would be deployed into a subnet
separate from the database. Firewall rules would then be implemented to permit network traffic to flow from the application server subnet to
the database subnet. In OCI we implement this sort of network security using network security lists. A security list is attached to a subnet and
defines what traffic is allowed in and out. You can specify what port, protocol, and even where the traffic is coming from or headed to.
While security lists are used to control network access, routing of network traffic in and out of a VCN is handled using a variety of routing
gateways and the route table. A routing gateway is a networking gateway similar to your router at home, directing traffic from your home
network to the internet and vice versa. In OCI there are gateways that route traffic to and from the Internet such as the Internet and NAT
gateways.
A Service Gateway is a special gateway that allows you to call OCI services privately. In plain speak this means when you call an OCI service
such as autonomous database or functions, OCI keeps the traffic inside the Oracle Service Network which remains private. The traffic never
flows over the internet.
© 2020 TechTipsOnDemand.com 26
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
A route table in a VCN contains route rules that determine how network traffic in a VCN is directed. No explicit route rules are needed to
route traffic within a VCN, such as between subnets. However, if you have a compute instance in a private subnet that needs to talk to the
internet, then a route rule must exist to send traffic from that compute instance to an OCI NAT Gateway.
A more modern method of providing network isolation rather than using subnets is a network security group. An NSG is a logical grouping
that associates compute instances with a set of security rules. NSGs are completely decoupled from the actual networking layout. In fact, you
could have a completely flat network with no subnetting, and still mimic secure network isolation through the creation and application of
various network security groups.
© 2020 TechTipsOnDemand.com 27
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Instructions
1.2. Log into the OCI console using your web browser using the login URL that was in the welcome email from Oracle or go
to cloud.oracle.com and click on sign in.
1.3. Once logged into the OCI console, navigate to Networking > Virtual Cloud Networks by clicking on the stacked bars in
the upper left hand part of the OCI console.
Name: vcn_oci_labs
Create in Compartment: OCI_Labs
CIDR Block: 10.0.0.0/16
© 2020 TechTipsOnDemand.com 29
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
You will be taken to a page that shows the details of the VCN that you just created, including any resources that are
part of a VCN (Subnets, Route Tables, Internet Gateways, etc). When you create a VCN using the OCI console, OCI
automatically creates a few networking resources including:
The default route table and security list are used as default values when you create a subnet in the OCI console. For
© 2020 TechTipsOnDemand.com 30
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
this lab we will be created our own security lists and route tables.
2. Creating Public and Private Subnets
2.1. With our VCN created, let’s create some subnets. A subnet is a way to carve up a large network into smaller networks.
Subnets are typically used to isolate application functions from one another in a multi-tier architecture. For example, in
a three-tier application, you would have one subnet for a public facing load balancer, another for the application
servers, and yet another subnet for the database.
A public subnet allows OCI resources such as compute to have a public IP address assigned to them, allowing them to
be reachable from the internet.
A private subnet does not allow resources to have a public IP, therefore these resources are not directly accessible
from the internet.
In this lab you will create both public and a private subnets to host a bastion server and application servers respectively.
2.2. In this section you will create a public subnet for hosting a bastion server. The bastion server will have a public IP
address, which will allow us to access it from the internet. We will then use the bastion server to access compute
instances in our VCN that have private IP addresses.
In the VCN details page of the VCN we created earlier, click on Subnets on the left-hand side of the console.
Create a public subnet by clicking the Create button and specify the following details for the public subnet.
Name: bastion-subnet
Subnet type: Regional
CIDR block: 10.0.0.0/28
Route table: Default Route Table for vcn_oci_labs
Subnet Access: Public – MAKE SURE THIS IS SELECTED!
DNS Resolution: Checked
DNS Label: Blank
DHCP Options: Default DHCP Options for vcn_oci_labs
Security Lists: Default Security List for vcn_oci_labs
The Public Subnet Access option is what enables public IP addresses to be assigned. Private subnets do not permit
public IP addresses to be defined.
© 2020 TechTipsOnDemand.com 31
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
© 2020 TechTipsOnDemand.com 32
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
2.3. Repeat the previous steps to create a private regional subnet named app-subnet with a CIDR block of 10.0.0.16/28. To
make the subnet private, be sure to select Private Subnet under Subnet Access.
3. Security Lists
3.1. Even though we get a default security list when a VCN is created, we are going to create our own security list so you
can learn how to do this for yourself.
© 2020 TechTipsOnDemand.com 33
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Each subnet will have its own security list controlling network traffic in and out. This is because the public subnet needs
to be treated differently than the private subnet. The bastion subnet will only allow SSH traffic in so that we can connect
to the bastion server using SSH. This will be the only protocol allowed.
The app subnet will have a security list that will only allow SSH traffic from the bastion subnet and no where else. For
now, it will be the only protocol that we allow in.
Both subnets will have a security rule that will allow any network traffic to leave the subnet for the internet.
Let’s create a security list to allow ssh into the public subnet, and allow ssh out of the public subnet to other subnets in
our VCN. The intent here is to create a subnet for a bastion server that we will deploy later on. A bastion server is a
compute instance that typically sits in a DMZ and is used to access all other servers that are deployed in private
subnets.
It is a best practice to minimize the number of resources exposed to the internet as much as possible. You can achieve
this by deploying all your compute instances and resources in private subnets, and then allowing access to these
servers through limited known access points such as a bastion server or a public load balancer.
Navigate to the VCN details page (Networking > Virtual Cloud Networks > vcn_oci_labs) and click on Security Lists.
3.2. Click Create Security List and specify the following details:
Add an ingress rule to allow ssh traffic over port 22 into the subnet.
Stateless: Unchecked
Source Type: CIDR
Source CIDR: 0.0.0.0/0
IP Protocol: SSH (TCP/22)
This rule will allow ssh traffic coming from anywhere into the subnet since the source CIDR is set to 0.0.0.0/0, which is
shorthand for any address.
*** For additional security, you should whitelist your own network address as the source CIDR so that OCI only permits
ssh coming from a trusted location.
For example, if you want to ssh into the bastion from your home, you could use the public IP address that is assigned
© 2020 TechTipsOnDemand.com 34
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
by your Internet Service Provider.
3.3. Add an egress rule to the same bastion security list to allow SSH traffic out of the public subnet to any location
within the VCN. This will allow us to SSH into any private compute instance.
© 2020 TechTipsOnDemand.com 35
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Click the Additional Egress Rule button and specify the following rules:
Stateless: Unchecked
Destination Type: CIDR
Destination CIDR: 10.0.0.0/16 (This is the CIDR block for the entire VCN)
IP Protocol: SSH (TCP/22)
3.4. Security lists must be explicitly assigned to subnets. To assign the bastion security list to the bastion subnet, select
Subnets under Resources on the vcn_oci_labs details page (Networking > Virtual Cloud Networks > vcn_oci_labs >
Subnets).
You will see the default security list assigned to the subnet on the Subnet details page.
3.5. Assign a security list by clicking the Add Security List button, then select the Default Bastion Security List.
3.6. Once the bastion security list is assigned, we can remove the default security list from the bastion subnet.
Select the ellipsis (3 vertical dots) next to the Default Security List for vcn1 and then select Remove.
© 2020 TechTipsOnDemand.com 36
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3.7. Repeat the previous steps to:
1) Create a new security list named Default Private Security List that allows ssh/22 into the app subnet from the
bastion subnet. Be sure to use the bastion subnet’s CIDR (10.0.0.0/28) as the source CIDR in the new list.
2) Assign the security list to the app subnet.
3) Remove the default security list from the app subnet.
3.8. Up to this point, you have created a virtual cloud network and two subnets. You have also implemented virtual firewalls
for each of the subnets using security lists. These security lists define what network traffic is allowed to flow in and out.
The next step is to define network routes to allow traffic to flow into and out of our VCN using OCI network gateways.
© 2020 TechTipsOnDemand.com 37
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
4. Routing Internet Traffic using Route Tables and an Internet Gateway
4.1. In OCI route tables and gateways are used to send traffic out of a VCN.
The OCI Internet Gateway is the first one you will create. An Internet Gateway is a virtual router that directs traffic to
flow from the internet into a VCN, and conversely allows traffic to flow out of a VCN to the internet. This is different than
a security list which is a firewall essentially that determines what protocols and ports are allowed.
Only public subnets can use an IGW to send traffic to the internet since public subnets allow for public IP addresses.
Resources with only private IP addresses cannot directly send traffic to the Internet. They need to use a NAT Gateway
which we will cover shortly.
To create an Internet Gateway, navigate to the vcn_oci_labs details page (Networking > Virtual Cloud Networks >
vcn_oci_labs), and select Internet Gateways under Resources.
4.2. Click Create Internet Gateway button. Specify igw as the name of the gateway and place it in the OCI_Labs
compartment.
4.3. With the internet gateway created, we need to create a route rule to tell the VCN how to route internet bound traffic.
© 2020 TechTipsOnDemand.com 38
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
The route rule will direct traffic to the internet (0.0.0.0/0) through the internet gateway.
© 2020 TechTipsOnDemand.com 39
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Start by creating a public compute instance called bastion1 in the bastion subnet using the same procedures in the
previous lab. Be sure to check the box for assigning a public IP address. Use the same SSH key you generated earlier.
5.2. Verify you can access the bastion server using the public SSH key you provided.
If you can connect, then you successfully configured your VCN to allow ssh traffic to the bastion server.
© 2020 TechTipsOnDemand.com 40
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1) The bastion server is assigned a public IP address (must be placed in a public subnet).
2) The bastion subnet has the correct security list and rules assigned to it to allow SSH/22 in (ingress).
3) The bastion subnet has a default route table with a route rule to use the internet gateway.
4) You are attempting to connect using the public IP address of the bastion server.
5) You are using the correct SSH key
Take note of its private IP address. We will need this to connect to it from the bastion server.
6.2. Next let’s verify the security rules for allowing ssh into the private subnet are working properly.
SSH into the bastion server then ssh into the app server using its private IP address.
If you get challenged for a login, then the networking is working, however you will not be able to login because you are
not yet able to present your private SSH key to the app server. More on this in a moment.
If your attempt to connect times out or you get another error trying to connect, then there may be issue with the security
lists. If this is the case, verify the following:
1) The Default Bastion Security List has an egress rule that allows ssh/22 to the VCN CIDR (10.0.0.0/16).
2) The Default Private Security List has an ingress rule that allows ssh/22 from the bastion subnet 10.0.0.0/28.
3) The Default Private Security List is assigned to the app subnet.
6.3. Next you will use the bastion server to connect to the private compute instance. Since the private compute instance
does not have a public IP address, we cannot connect to it directly, however we can connect to it from the bastion
server because the bastion server has a private IP address in the same VCN as the app server.
You will ‘jump’ through the bastion server to private app server. To do this, you need to configure your SSH client to
proxy or forward our SSH connection to the app server.
© 2020 TechTipsOnDemand.com 41
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Follow the instructions in the Appendix A : How to securely connect to private OCI instances over the Internet.
This appendix covers both Windows and Linux/OSX SSH clients.
6.4. Once you have completed the instructions for setting up SSH agent-forwarding, verify you can connect to the private
compute instance by first connecting to the public server using its public IP address.
Once connected to the public server, ssh to the private server using its private IP address. If you properly set up your
SSH client to use agent forwarding, you should not be prompted for any authentication credentials when connecting to
the private instance.
6.5. Try accessing the public internet from the private compute instance.
$ curl -L https://www.google.com
1) We have not told OCI how to handle internet-bound traffic. We need a route rule defined to solve this problem.
2) We have not created a network security rule to allow http traffic to leave the subnet for the internet. We need a
security rule to permit HTTP/HTTPS.
In the next section you will create routing gateways to allow access to the internet.
7. Routing Traffic to the Internet using OCI NAT Gateway
7.1. Compute instances need a public IP in order to send requests to the Internet. The Internet Gateway allows instances in
public subnets with public IP addresses direct access to the Internet.
Compute instances in a private subnet do not have a public IP address, so they cannot directly access the internet. For
this situation, OCI provides a NAT Gateway virtual router. The NAT Gateway (NATGW) is a virtual router that gets
provisioned in a public subnet and assigned a public IP. Private subnet traffic headed to the internet is routed through
the NATGW. NATGW allows responses from the internet back into the VCN. NATGW is only used for egress out of the
VCN, not for ingress.
In this section you will provision and configured a NAT Gateway to allow compute instances in a private subnet to
access the internet.
7.2. Navigate again to the VCN details page and select NAT Gateways under Resources.
7.3. Create a NAT Gateway by clicking the button and specifying the following details:
© 2020 TechTipsOnDemand.com 42
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Name: natgw
Compartment: OCI_Labs
OCI will automatically assign a public IP address to the gateway. You can see the assigned public IP address for the
NAT gateway listed under NAT Gateways.
7.4. Next we need to define a route rule that will send internet bound traffic through the NAT Gateway. Since this route is
only for private compute instances, we need to separate this route from the other route we created using the Internet
Gateway. To do this, we will create a new route table.
Under Route Tables for the VCN, click the Create Route Table button to create a new table named Default Private
Route Table.
© 2020 TechTipsOnDemand.com 43
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
7.5. Next add a new route rule that will send traffic from the private subnet to the internet by clicking on the new route table
then clicking on the Add Route Rules button.
Here is the route rule that will send internet-bound traffic to the NAT Gateway.
7.6. Assign the Default Private Route Table to the app-subnet by editing the subnet and changing the route table to Default
Private Route Table.
7.7. With our route defined, we now need to create a security rule to allow traffic to flow out of the app-subnet.
Create an egress rule in the Default Private Security List to allow TCP from the private subnet to the internet.
Stateless: Unchecked
Destination Type: CIDR
Destination CIDR: 0.0.0.0/0
IP Protocol: TCP
© 2020 TechTipsOnDemand.com 44
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
7.8. Verify the private compute instance app1 can now access the internet by connecting to it using SSH through the
bastion server as we did earlier in the lab, then run the following curl command.
$ curl https://www.google.com
curl should return HTML from Google. If you receive a connection time out or any other connection error, verify that you
have
1) Routed traffic from the app-subnet to the NAT Gateway using a route rule.
© 2020 TechTipsOnDemand.com 45
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
2) Allowed TCP traffic to leave the app-subnet for the Internet using a security rule.
The OCI Service Gateway allows compute instances in your VCN to access OCI services using public endpoints but
keeps the network flow from going over the internet. Using a Service Gateway is an alternative to configuring a NAT
Gateway. With a NAT Gateway, network traffic is routed out to the internet, ev
In this section you will create the Service Gateway in your VCN, then write a route rule to send traffic destinated for OCI
services through the Service Gateway.
8.2. Navigate to Service Gateways under Resources on the VCN details page.
© 2020 TechTipsOnDemand.com 46
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.3. Click Create Service Gateway and specify the following details:
Name: sgw
Compartment: OCI_Labs
Services: All <Region> Services in Oracle Services Network
The value for Services in the dropdown will vary depending on what region you are working in.
© 2020 TechTipsOnDemand.com 47
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.4. Next create a route rule to send network requests for OCI services (like object storage) to the service gateway.
In this exercise, only the private subnets will be accessing OCI services privately, so create the rule in the Default
Private Route Table.
Add the following route rule to the Default Private Route Table:
© 2020 TechTipsOnDemand.com 48
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.5. The Default Private Route Table should now look like the screenshot below. This route table contains two rules: one for
sending traffic for Oracle Services through the service gateway, and all other traffic intended for the internet through the
NAT gateway.
© 2020 TechTipsOnDemand.com 49
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.6. Now that we have our routes set up, we need to modify our security lists to allow compute instances in the private
subnet to talk to OCI services.
You can leave destination port blank for now. This egress rule will permit any TCP traffic to the Oracle Service Network.
© 2020 TechTipsOnDemand.com 50
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Once the rule is created, requests for OCI services from our private subnet will be routed through the OSN and not out
to the public internet. This keeps the traffic more secure since it does not expose it publicly.
9. Shutdown all Compute Instances
9.1. Be sure to stop any running compute instances when you are finished with the lab. A stopped instance does not incur
any charges.
Do not terminate the instances as that will delete them. We will be reusing bastion1 and app1 in later labs.
Conclusion
© 2020 TechTipsOnDemand.com 51
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
2) Implement virtual firewalls using Network Security Lists
3) Route traffic in and out of the VCN using Internet and NAT Gateways
4) Route Oracle Services traffic privately to the Service Gateway
© 2020 TechTipsOnDemand.com 52
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Skills Learned
At the end of this exercise, you will be able to:
Overview
The OCI Block Volume Service provides raw high performance durable block volume storage for compute instances. If you need to install
and run software on your compute instances, you would do so on a block volume attached to the compute instance. In fact, the boot volume
on any OCI compute instance is just a special type of block volume.
In this lab you will learn how to provision, attach, and manage block volumes through backups and cloning.
Block volume storage, like all other storage services in OCI, costs money and the limits to the number of volumes and size of those volumes in
the Oracle Free Trial Period and Free Tier is quite limited. Block volume storage is billed based on total provisioned capacity per month. If
you provision a 1 TB volume but are only using 50 GB of it, you will be charged for the full 1 TB per month. This is different than object
storage where you pay for only what you consume.
To keep any potential costs down, it is highly recommended that students delete all volumes and volume backups at the end of each exercise.
Instructions
© 2020 TechTipsOnDemand.com 53
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
reboots of a compute instance. The process for provisioning a volume and using it with a compute instance is as follows:
In this lab you will attach a 50 GB block volume to the private compute instance, app1, that you created in the Core
Compute lab.
1.2. First we need to find out what Availability Domain our app1 instance is in so we know where to create the block volume.
The block volume must live in the same AD as our compute instance. A block volume resource, much like a compute
resource cannot span different data centers or ADs. It is an AD-local resource.
1.3. In the OCI Console, navigate to Compute > Instance. Make sure to select the OCI Labs compartment.
1.4. Now create the block volume by navigating to Block Storage > Block Volumes from the navigation menu.
1.5. Click the Create Block Volume button and specify the following parameters:
Name: app1_datavol
© 2020 TechTipsOnDemand.com 54
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Create in Compartment: OCI_Labs
Availability Domain: Select same as app1
OCI allows us to define performance characteristics for block volumes. Performance is typically linear, meaning the
larger the volume, the more IOPS or throughput is provided.
To keep costs to a minimum, select Custom under Volume Size and Performance.
Volume Size (In GB): 50 GB
Default Volume Performance: Lower Cost
© 2020 TechTipsOnDemand.com 55
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.6. Once the volume is provisioned and available, you can attach it to a compute instance.
Click on the block volume you just created, then click on Attached Instances then Attach to Instance.
1.7. The Attach to Instance dialog will present several different options for configuring the attachment. There are two
attachment types available – Paravirtualized and iSCSI. Paravirtualized is far simpler to configure, however, iscsi
provides much better performance.
© 2020 TechTipsOnDemand.com 56
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
The device name is where the volume will exist as a device in Linux.
1.8. Once the volume is done attaching, your screen should look like the following:
1.9. The next step is to partition, format, and mount the volume on the host.
SSH into app1 by connecting to the bastion first then hopping over to app1.
1.10. Verify the volume is attached to the host by running fdisk. Look for /dev/sdb in the output.
[opc@app1 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 315M 0 315M 0% /dev
tmpfs 345M 0 345M 0% /dev/shm
tmpfs 345M 9.3M 336M 3% /run
tmpfs 345M 0 345M 0% /sys/fs/cgroup
/dev/sda3 39G 2.9G 36G 8% /
/dev/sda1 200M 8.6M 192M 5% /boot/efi
tmpfs 69M 0 69M 0% /run/user/0
tmpfs 69M 0 69M 0% /run/user/994
tmpfs 69M 0 69M 0% /run/user/1000
/dev/sdb1 49G 52M 47G 1% /datavol
Edit /etc/fstab and add the following line at the bottom of the file.
$ sudo vi /etc/fstab
© 2020 TechTipsOnDemand.com 59
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
$ sudo mount -a
$ sudo df -h
2.4. Back in the OCI Console, restart the app1 compute instance.
Go to Compute > Instances > app1. Select Reboot from the menu.
2.5. After app1 reboots, ssh into app1 and confirm /datavol is automatically mounted.
3. Attaching a Block Volume using ISCSI
3.1. Paravirtualized attachments are a simple and easy way to attach a block volume to a host as we performed in the
previous lab. However, there are performance advantages to attaching volumes using ISCSI.
In this section you will detach the volume we just mounted and reattach using ISCSI.
3.2. On the app1, unmount the volume. You can run df again to see that is no longer mounted.
3.3. In the OCI Console, detach the block volume from app1 by going to the app1 compute instance details page > Attached
Block Volumes and selecting Detach from the menu for the app_datavol volume.
3.4. Reattach the volume but this time specify ISCSI as the attachment type.
© 2020 TechTipsOnDemand.com 61
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3.5. Once the volume shows as attached in the OCI Console, you will need to run a series of ISCSI commands on the app1
compute instance.
The ISCI commands are specific to the volume and the compute instance. To get the commands, click on the ellipsis
next to the attached volume and select iSCSI Commands and Information from the menu.
The screenshot below shows us the commands specific to this particular block volume.
© 2020 TechTipsOnDemand.com 62
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3.6. It is recommended that you copy these commands into a text file or somewhere you can reference them later. You can
also come back to the console to retrieve the commands.
3.7. SSH into app1 and run the ISCSI commands for connecting to the volume.
3.8. Run fdisk -l to see the disk attached to the host. Notice that the partition you created earlier, /dev/sdb1, has been
preserved.
© 2020 TechTipsOnDemand.com 64
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
4. Creating a Backup of a Block Volume
4.1. OCI allows you to create a backup of a block volume, either scheduled or manual.
4.2. To create a full manual backup of a volume, navigate to Block Storage > Block Volumes > app_datavol
4.3. Under Block Volume Backups, select Create Block Volume Backup.
Name: app_datavol_backup_01
Backup Type: Full
Click Create.
4.4. The backup request will appear under Block Volume Backups.
4.5. You can also create an incremental backup as well by going through the same steps as a full backup. Simply select
Incremental as the Backup Type.
Here we created an incremental backup volume, however since we did not change anything on disk, the size of the
backup is similar to the full back in this case.
© 2020 TechTipsOnDemand.com 65
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
5.2. To restore from a set of backups, start with the last incremental backup. Select Create Block Volume from the last
incremental backup.
5.3. The dialog for creating a block volume will appear. Select the same parameters as the original volume, however for the
name specify restored_app_datavol.
5.4. The restored block volume will appear alongside the original as shown in the OCI Console.
© 2020 TechTipsOnDemand.com 66
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Once the restored volume is available, you can then go through the process of attaching and mounting the volume as
done earlier in the lab.
To create a backup policy, navigate to Block Volumes > Block Storage > Backup Policies.
6.2. Notice Oracle provides some out-of-the-box backup policies for you to use: Gold, Silver, and Bronze. Each policy has a
different set of backup schedules.
Feel free to click on any policy to view the different schedules and retention periods for each backup.
6.3. For this lab, you will create your own backup policy with two schedules to supply a daily incremental backup and one full
backup per week.
© 2020 TechTipsOnDemand.com 67
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Click the Create Backup Policy button and specify a name for the backup policy. Click Create.
6.4. On the backup policy page, you can define backup schedules that tell OCI when to take a backup and how long to keep
it.
Click Add Schedule to define a schedule for a daily incremental backup. This schedule will retain the daily backups for 7
days.
© 2020 TechTipsOnDemand.com 68
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
6.5. Define another schedule for a weekly full backup with a retention period of 4 weeks.
© 2020 TechTipsOnDemand.com 69
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Go back to the app_datavol details page (Block Storage > Block Volumes > app_datavol) and click the Edit button.
Scroll down to the bottom of the Edit page and select the backup policy you just defined.
© 2020 TechTipsOnDemand.com 70
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
The backup policy is now in effect for the block volume. This can be seen on the app_datavol’s details page.
© 2020 TechTipsOnDemand.com 71
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
7.2. To create a clone in the OCI Console, go back to the list of block volumes in the OCI Labs compartment (Navigate to
Block Storage > Block Volumes).
7.3. Select Create Clone from the ellipsis menu for app_datavol.
In the clone dialog, specify cloned_app_datavol as the name then click Create Clone.
© 2020 TechTipsOnDemand.com 72
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
If you need to get the commands again, navigate to the app1 compute instance in the OCI Console. Under Attached
Block Volumes, select iSCSI Commands and Information next to app_datavol.
8.4. After you have run the detach iSCSI commands on the host, go back to the OCI Console and select detach from the
app_datavol menu.
8.6. Once the volume is detached, it will no longer appear on the list of attached volumes for app1.
© 2020 TechTipsOnDemand.com 74
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Navigate to Block Volumes > Block Storage and select Terminate next to the app_datavol volume. Confirm that you want
to terminate the volume.
© 2020 TechTipsOnDemand.com 75
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
9.2. Once the volume is terminated, it will appear as terminated in the list of volumes. A terminated volume no longer exists
and does not incur any charges.
9.3. Repeat the previous steps to terminate all remaining block volumes.
10. Cleaning up Block Volume Backups
10.1. Remove the block volume backups that we created earlier by navigating to Block Volume Backups under Block Storage.
Select Terminate next to each backup. Termianted backups are deleted are do not incur any charges.
© 2020 TechTipsOnDemand.com 76
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Skills Learned
At the end of this exercise, you will be able to:
© 2020 TechTipsOnDemand.com 77
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Overview
OCI Object Storage is an infinitely scalable cloud native persistent store for unstructured data, such as documents, videos, images, log files,
database backups, et cetera. Object storage has many use cases from hosting static content for a website to forming a data lake for data
analytics workloads.
In OCI, objects are stored in buckets which can be made either public or private. Public objects and buckets are accessible by anyone on the
internet, however access to private objects and buckets requires an OCI credential and an appropriate IAM policy that grants a user or group
or thing access. Access can be granted to private objects using a special OCI feature known as pre-authenticated requests, also known as a
PAR. A PAR is essentially a URL that contains a one-time generated access token that grants anyone with the URL permission to access an
object.
In this lab you will learn how to work with objects and buckets using your browser and the OCI command line interface or CLI.
Instructions
A public object is one that is read-only accessible by anyone on the internet. They do not need to be an authenticated or
authorized user. Each public bucket and each public object have a unique HTTP URL associated with them that can be accessed
from the internet. A public bucket and a public object only allow read access though, not write.
You still need to be logged into OCI in order to write to a bucket, regardless of its visibility.
Log into the OCI Console and navigate to Object Storage from the stacked navigation menu.
Your screen should look similar to the screenshot below. Click Create to create the bucket.
© 2020 TechTipsOnDemand.com 78
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.4. By default, all object storage buckets are created as private. In order to change them to public, you must change their visibility in
the OCI Console.
To make the button public, click on the Edit Visibility button under the name of the bucket and select Public. This will make any
objects in the bucket accessible on the internet.
You also have the option to allow users to list objects in a bucket. This may or may not be desirable depending on the use case,
so let’s be safe and leave this option unchecked.
© 2020 TechTipsOnDemand.com 79
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.6. You should now see the visibility status has changed from Private to Public on the bucket details page. OCI displays a little
warning icon letting you know that the bucket is public.
1.7. With the bucket created, you can now upload an object to the bucket right from the OCI Console.
On the bucket details page, click the Upload button. Select any file you wish to upload to the bucket.
© 2020 TechTipsOnDemand.com 80
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.8. After the file is uploaded, it will appear in the list of objects for the bucket.
© 2020 TechTipsOnDemand.com 81
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.9. The file you uploaded now exists on the public internet and is represented by a URL.
To get the URL of the object, click the three dots (ellipsis) next to the object. A menu will appear.
Select View Object Details from the menu. You will see some basic information about the object, including a URL.
Public object storage is a great way to host static website assets such as images and videos. This is just one use case of course.
© 2020 TechTipsOnDemand.com 82
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
1.10. Let’s delete the object now by clicking on the ellipsis and selecting Delete. Confirm the object was delete and the URL is no longer
valid.
2. Working with Private Buckets and Objects
2.1. Now you will work with a private bucbket and objects.
Click the Upload button and upload any type of file you wish.
Since the bucket is private, all objects within the bucket are private by default which means only authenticated OCI users with the
proper authorization (you) have access to objects in the bucket.
2.3. After the file is uploaded, you will see it appear in the list of objects.
2.4. Because the object was uploaded to a private bucket, it is no accessible on the internet. Users will need to be logged into OCI and
granted access to bucket or object explicitly.
To verify the object is indeed private, get the URL for the object by viewing the object details just like we did with the public object.
Try accessing the URL. You should receive an error message that the bucket doesn’t exist or you don’t have permission.
2.5. You can download objects from within the OCI Console using a browser by selecting Download from the ellipsis menu next to the
object.
© 2020 TechTipsOnDemand.com 83
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3. Using the OCI CLI with Object Storage
3.1. Up to now we have used the OCI Console exclusively to interact with OCI services. While the console is great tool, it is not as
powerful nor as flexible as using the OCI tools, APIs, and CLI to manage our cloud infrastructure.
In this section you will use the OCI command line interface to work with OCI object storage.
There are two options for install the CLI. You can go the easy route and use OCI’s Cloud Shell, which is a terminal window in the
cloud that has all the tools already installed configured to use your OCI credentials. This option is most suitable for a learning or
demo environment.
The other option is to install the OCI CLI on your machine, which is a more involved process, requiring you to download and install
the tools, along with configuring the tools to use an OCI authentication token; but is the preferred method for supporting
development and production environments in OCI.
In this lab guide, we will use Cloud Shell to run the CLI.
3.2. To use the OCI CLI already installed in the Cloud Shell, simply launch the Cloud Shell by selecting the Terminal icon located in
the upper right portion of the OCI Console.
© 2020 TechTipsOnDemand.com 84
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3.3. You can verify the OCI CLI is installed by running the oci command with no arguments.
$ oci
To get the OCID for your tenancy, click on the Profile icon in the OCI Console then click on the name of your tenancy.
The OCID for the tenancy will appear on the Tenancy Details page in the Tenancy Information box. Click on either Show or Copy
next to the OCID value. Save the OCID somewhere on your computer as we will be using this throughout the rest of this lab guide.
© 2020 TechTipsOnDemand.com 85
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
4.2. Run the following command to create a private bucket named bucket2:
$ oci os bucket create --name bucket2 --compartment-id <Put your tenancy OCID here>
4.3. You can verify the bucket was created by using the OCI CLI to list all buckets in a compartment. The OCI CLI will return json
formatted results.
If you are using Cloud Shell or any other Linux environment, create a simple text file.
5.2. Upload the text file to object storage using the following command:
© 2020 TechTipsOnDemand.com 86
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
5.3. You can verify the object was stored in the bucket by listing the contents of the bucket.
The –file parameter tells OCI where to store the downloaded object on your filesystem.
5.5. To delete an object:
The OCI CLI will prompt you to confirm deletion of the object.
6. Working with Pre-Authenticated Requests
6.1. A PAR is a generated URL that allows anyone with the URL to access a private object. The generated URL serves as a secret
access token in a way, so the generation and storage of a PAR should be a protected operation.
PARs are commonly used when you want to share protected information with a client or customer that does not have an account
in your OCI tenancy. It is a best practice in this case to generate a PAR that has a short lifespan and securely hand that URL to
the end user.
In this section you will generate a PAR URL for an object. The PAR will grant access to the file to anyone with the URL. You are
going to configure the PAR to provide READ-ONLY access and for it to expire after a few minutes.
6.2. Use the OCI Console to upload a file to the bucket you created earlier.
6.3. Create a PAR by selecting the ellipsis next to the file you just uploaded then Create Pre-Authenticated Request.
6.4. The options for creating a PAR are fairly simple. You can create a PAR for a bucket or a file.
In this tutorial, configure the PAR to permit read-only access on the object.
Also configure the PAR to expire after 10 minutes. This forces the PAR to be no longer valid after a certain period of time – a best
practice for giving external users temporary access to files!
© 2020 TechTipsOnDemand.com 87
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
6.5. After you click Create Pre-Authenticated Request, the PAR URL will be displayed on the screen only once. Be sure to copy this
URL down somewhere safe since you will not be able to retrieve it from OCI again.
If you lose your PAR URL, you can always generate a new one in the OCI console.
6.6. Close the PAR dialog after you have saved your PAR URL.
Now navigate to the PAR URL using your browser and the object you upload should appear, depending on the type of object.
© 2020 TechTipsOnDemand.com 88
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
6.7. Back in the OCI Console, you can see an inventory of PARs by going to Object Storage > bucket2 > Pre-Authenticated Requests.
Here in this table you will see a list of PARs and whether they are expired or active. If it has been 10 minutes since you created
the PAR, it should show as expired by now.
6.8. If the PAR is not expired by now, go ahead and expire it by selecting the ellipsis next to the PAR.
6.9. After the PAR is expired, try accessing the PAR URL again from your browser. You should receive an error message that either
the bucket does not exist or you are not authorized to access it.
In this section you will use curl to download and upload objects using a PAR url.
7.2. Curl is already installed in the Cloud Shell environment, however if you want to install curl in your own environment there are
hundreds of articles on the internet that detail the procedure so it will not be covered here in this lab. For most linux systems, it’s a
simple one line command.
7.3. In the OCI Console, create a PAR for bucket2 – this will allow someone with the URL to upload objects to a bucket. A bucket PAR
only allows writes to a bucket, it does not allow read. So someone with the URL will not be able to list objects in a bucket.
To create a PAR for a bucket, navigate to Object Storage in the navigation menu and click on the bucket name – in this case
bucket2.
7.4. Under Resources click on Pre-Authenticated Requests then click the button Create Pre-Authenticated Request.
© 2020 TechTipsOnDemand.com 89
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
7.5. In the dialog that appears, make sure Bucket is selected for Pre-Authenticated Request Target. Leave all other values default.
Take note that you must append the name of the object after the PAR URL. Unlike using the OCI CLI where you explicitly specify
the bucket and have to be an authenticated OCI user, a PAR URL combines both bucket and authorization to access the bucket in
the URL.
Use the curl command above to upload any file to object storage using the PAR you generated.
7.7. The PAR that you generated only permits a user to write objects to the bucket. If you want to share access to the object using a
PAR, you must create a PAR just for that object.
Back in the OCI Console, navigate to bucket2 to see a list of objects in the bucket. You should see the object that you just
uploaded using curl.
To create a PAR for the object, select Create Pre-Authenticated Request from the ellipsis menu next to the object.
7.8. In the PAR dialog, you can choose what type of access to allow on the object, either read, write, or both. Select read and write
then create the request. Be sure to save the PAR URL.
7.9. Back on the command line, use curl to fetch the object using the PAR for the object. The curl command below is equivalent to
putting the URL in your browser address bar.
7.10. The PAR for the object also allows writes. Make a change to object.txt on your local file system and upload it back to object
storage using the same PAR.
In this section you will write an IAM policy that lets a group of users manage an object storage bucket and another group to only
read and write objects in the bucket.
8.2. For this scenario you are going to create two local OCI Groups: ObjectStorageAdmins and ObjectStorageUsers. The storage
admins will be responsible for creating and managing buckets in an OCI compartment. Recall an OCI compartment is a logical
construct that is used for organizing and manage OCI resources.
The storage users will be able to read and write to the object storage buckets only in the OCI compartment.
In the OCI Console, select the stacked navigation bars and navigate to Identity > Groups.
8.3. Create a group called ObjectStorageAdmins by selecting the Create Group button.
On the Create Group dialog, specify the name of the group and a description (it’s required).
© 2020 TechTipsOnDemand.com 91
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.5. In this scenario you are going to only allow the object storage admins and users to work with buckets and objects in a dedicated
OCI compartment.
Navigate to Identity > Compartments. Select the OCI_Labs compartment under List Scope.
8.6. Create a new compartment called ObjectStorageLab under the OCI_Labs compartment by clicking on the Create Compartment
button.
8.7. Next you are going to write an IAM policy that allows the ObjectStorageAdmins to create and manage buckets and objects in the
ObjectStorageLab compartment.
Name: ObjectStorageLabPolicy
Description: Same as Name
Compartment: root
© 2020 TechTipsOnDemand.com 92
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Use the Policy Builder to quickly select from pre-defined commonly used policies.
As you select options, you will see the actual Policy Statement being generated at the bottom of the dialog. Notice the two
statements, one that allows the admin group to manage buckets in the compartment, and the another that allows the admin group
to manage objects in the compartment. The verb manage is special in that it allows the highest level of access for the resource
being secured.
There are other verbs like inspect and use which will see shortly.
Your screen should look similar to the screenshot below. Click the Create button once you are done.
© 2020 TechTipsOnDemand.com 93
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.9. Next you will author a set of policies to allow users to manage objects in a compartment. The storage users group will not have
permission to manage buckets, just objects.
This time you are going to author the policy directly without using the policy builder.
© 2020 TechTipsOnDemand.com 94
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Under Identity > Policies, click on the ObjectStorageLabPolicy you just created.
8.11. On the Edit Policy Statements screen, click Add Another Statement and enter the following statement:
8.12. Add another statement to let the users view buckets in a compartment.
8.13. When are you done adding the statements, click the Save Changes button.
© 2020 TechTipsOnDemand.com 95
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.14. Now in order for us to test to see if our policies work as they should, we need to create some users.
Under Identity > User, click Create User and fill in the following details:
© 2020 TechTipsOnDemand.com 96
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
Name: objectstorage_admin
Description object_storage_admin
8.15. On the User Details page for the admin user, set a password for this user by selecting the Create/Reset Password button.
You will be shown a one-time password for the user. Be sure to copy this down somewhere. This OTP will be reset upon first
login.
8.16. With the user created, you can now add the user to the storage admin group.
On the User Details page, click the Add User to Group button and select the ObjectStorageAdminGroup from the list.
The User Details page will list what groups this user is part of.
© 2020 TechTipsOnDemand.com 97
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.17. Repeat the above steps to create another user called objecstorage_user. Set a password as before and add the user to the
objectstorage_user group.
© 2020 TechTipsOnDemand.com 98
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.18. With both our users and our policies set up you can now test that everything works. Here are the steps.
1. Log in to the OCI Console as the storage admin user and set a new password.
2. Create an object storage bucket in the new compartment
© 2020 TechTipsOnDemand.com 99
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
3. Log in as the storage user and set a new password.
4. Read and write objects to the new bucket.
8.19. Log out of the OCI Console and log back in as the objectstorage_admin user using the OCI Direct Sign form (not Single Sign On).
You will be asked to set a new password.
Select the ObjectStorageLab compartment under List Scope to change compartments. The authorization error should disappear.
8.22. Create a new object storage bucket, keeping all the default values.
After the bucket is created, your screen should look like this:
8.23. Next you will log in as the object storage user and try to write to the bucket.
Log back into the OCI Console as objectstoage_user. Again you will have to set a new password since this is the first time logging
in as this user.
You should see the bucket that was just created by the admin user.
8.25. First verify that the storage user is not able to delete the bucket. Recall we only gave the regular user the ability to read buckets in
the compartment, not delete.
Try deleting the bucket by selecting the ellipsis next to the bucket name. The option will be visible but you should receive an
authorization error.
8.26. Next verify that this user can upload objects to the bucket by clicking on the bucket name and then the Upload button. Upload any
file you wish.
8.27. Verify the user can also delete objects in the bucket as well.
9. Lab Cleanup
9.1. Perform the following steps to clean up your lab environment:
1) Delete all objects that were created as part of this lab
2) Stop any running compute instances.
Conclusion
In this lab you were introduced to core object storage concepts buckets, objects, PARs and IAM policies. You used a variety of tools for
working with object storage, including the OCI Console, OCI CLI, and curl to create buckets and objects both public and private. We saw
how to grant access to objects using PARs for anonymous users, and how to use IAM policies and groups to grant users of our tenancy access
to buckets and objects.
Skills Learned
At the end of this exercise, you will be able to:
Overview
A load balancer is typically used to provide high availability for an application or service that is deployed across two or more servers by
distributing requests using an algorithm. A load balancer is configured to manage requests for a service across a pool of servers known as a
backend set in OCI. The load balancer is intelligent to know which servers are healthy and which are unhealthy using a health check system
that involves polling each backend compute instance.
If the load balancer detects one of the servers in a backend set is unhealthy, then it will mark it as such and not forward any requests to it, so
the client or user never gets sent to a bad server. When the load balancer detects the server is healthy again, its status is updated and can start
receiving requests again.
In this lab you will configure a load balancer to provide high availability and SSL for a simple website running on two compute instances.
Below is a picture showing what our VCN will look like when we are done. We will add an additional compute instance in app-subnet to
provide a two-node web server setup. A load balancer will be deployed in a new public subnet and will be configured to handle http and https
requests for our website.
Instructions
We will use the app1 compute instance we created previously in addition to a new instance we will create right now.
Use the same Oracle Linux image as you did with app1.
Select the smallest compute shape available to keep costs down. Since you will have reached the service limits for the
Always Free tier, pick the smallest compute shape available.
For convenience use the same SSH key as you did with app1.
SSH into app1 through the bastion and run the following commands to install and enable Apache
It is important to note that every Oracle Linux image comes with a host-based firewall enabled. So in additional to using
security lists, you must also enable ports on the host itself.
1.3. Verify Apache is up and running by executing curl on the host.
$ curl -L http://localhost
1.4. For this lab we want to create our own custom web page and not use the default page that comes with Apache. We are
going to create a very simple index.html.
$ sudo su
$ echo “Hello welcome to $HOSTNAME ” > /var/www/html/index.html
1.5. Run the curl command again and verify the new html page is returned instead of the default page. The hostname should
© 2020 TechTipsOnDemand.com 104
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
also appear on the page.
1.6. Repeat the previous steps to setup Apache on app2 with the same index.html page and configure the firewall to allow
http/80.
The diagram at the beginning of this lab shows the public load balancer being provisioned in a new public subnet that is
called front-subnet.
Log into the OCI Console and create the new public subnet with the following parameters:
Name: front-subnet
Type: regional
Compartment: OCI_Labs
CIDR: 10.0.0.32/28
Route table: Default Route Table for vcn_oci_labs
Subnet access: Public
Security List: Leave blank – we will create a new one next.
2.2. We need some new security rules to allow HTTP into the load balancer on port 80 and another rule to allow HTTP traffic
to leave the load balancer and hit the web servers app1 and app2.
The first rule will allow HTTP on port 80 in to the load balancer’s subnet. The second rule will allow the load balancer to
send http traffic to the web servers running on port 80.
Create a new security list called Public_LB_SecList and add the following rules:
Ingress
Allow TCP from 0.0.0.0/0 to destination port 80
Egress
Allow TCP to 10.0.0.16/28 on port 80
2.3. Add this new security list to the public load balancer’s subnet.
2.4. Now we must create a corresponding security rule for the app-subnet to allow HTTP traffic in from the load balancer.
Create another security list call Private_App_SecList and add the following rule:
Ingress
Allow TCP from 10.0.0.32/28 to destination port 80.
2.5. Add the security list to the app-subnet.
3. Creating a Public Load Balancer
3.1. With our network prepared, we can now create a public load balancer. This public load balancer will be configured to
listen for HTTP traffic on port 80 and load balance requests across a backend set that has both app1 and app2 web
servers in it.
3.2. Click the Create Load Balancer button and specify the following parameters.
Under Choose Networking, place the load balancer in the front-subnet in the vcn_oci_labs VCN.
Click the Add Backends button and add app1 and app2 to the backend set. A backend is essentially our web server
cluster. The load balancer will load balance requests across every compute instance in the backend set.
Leave the default values under Health Check policy. The Health Check Policy is used by the load balancer to know if a
compute instance in the backend set is healthy or not. If it is not healthy, the load balancer will not forward requests to
that instance.
In this lab:
Oracle will assign a public IP address to the public load balancer, which you can see on the Load Balancer’s details
page. It is this public IP address that will be used to visit our website.
3.5. Once the load balancer is provisioned, it will take time for the Overall Health status to update showing healthy.
Verify the health of your backend set by clicking on the load balancer website_lb > Backend Sets > the backend set >
backends.
3.6. Confirm the health of each backend – app1 and app2 – is healthy.
In order to proceed, the backend set must be healthy as noted in the previous section.
4.2. When you installed and setup Apache to host our really simply website, you create an index.html page for each server.
To demonstrate what server is returning the request, you put the name of the server in the index.htm, such that when
you hit the public IP address of the load balancer, you will see a different index.html depending on what server the load
balancer is sending the request to.
To demonstrate, use your browser to go to the public IP address of the load balancer. You should see the index.html
that you created earlier with the name of the server.
Refresh your browser to reload the request. The load balancer will round robin your request across each server,
returning the index.html page for that server.
5.3. Use your browser to revisit the public IP address of the load balancer. Verify that app2 is returning the request by
observing the output from the web page. Keep refreshing your browser window to confirm that only app2 is returning the
© 2020 TechTipsOnDemand.com 110
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
response.
5.4. In the OCI Console, check the health status of the backend set by going to Networking > Load Balancers > website_lb
> Backend Sets.
OCI will check the health status of a server on a regular interval that you can configure. By default, the interval is 10000
ms.
5.6. Verify the health of the backend set returns to OK. It may take some time for the change to be reflected in the UI, but you
should be able to test using your browser to hit the load blanacer IP address after a few seconds of restarting apache.
6. Enabling SSL
6.1. In this section you will enable SSL for your website by loading a certificate bundle into a new load balancer listener that
you will create.
The certificate bundle is a combination of a signed SSL certificate plus a private key. The load balancer uses this bundle
to accept SSL requests from users and to terminate the SSL connection at the load balancer. The request or network
traffic then moves from the load balancer to the web server unencrypted.
6.2. First let’s generate a certificate bundle to be used with the load balancer. For this exercise you will be created a self-
signed certificate using openssl.
This step requires the use of openssl, which is available for installation on most operating systems.
The server.key is the private key for the server, in this case, for the load balancer. It is used to terminate the SSL
connection before sending it to the web server.
The server.crt is the SSL certificate used to establish an SSL connection with end user.
6.3. Next we need to create a certificate bundle to be used with our load balancer.
In the OCI Console, navigate to Networking > Load Balancers > website_lb > Certificates.
Under SSL certificate, you can either upload the server.crt file or you can paste in its contents.
Add the private key by checking the box for Specify Private Key and uploading or pasting in the contents of server.key.
6.5. Once the certificate has been added, we now need to create a new listener to listen for https/443 requests using the
certificate we just uploaded.
Name: website_secure_listener
Check the box for Use SSL. This should update the Port to 443.
6.7. It will take OCI a moment to provision the listener with the certificate you specified.
You can check the status and any error messages under the Resources heading > Work Requests.
Typically the listener will fail if the SSL certificate or private key are invalid or malformed. If this is the case, then confirm
the certificate bundle was created properly. If not, recreate the bundle and add it to the listener.
6.8. Once the HTTPS listener is up and running, you may access the website using HTTPS instead of HTTP.
Since we are using a self-signed certificate, the browser will warn you that you are accessing an unsafe website. In the
real world you would use a proper certificate from a trusted Certified Authority rather than a self-signed certificate.
However the process for using CA-signed cert and a self-signed cert with OCI is the same.
7. Enabling Logs
7.1. The OCI Load Balancer has the ability to write both access and error logs to the OCI Logging Service.
To enable logs, go to Logs under the Resources heading for the load balancer.
7.2. You can enable either the access log or error log or both.
Click on the Enable toggle for the Access Log and specify the following details:
Compartment: OCI_Labs
Log Group: Default_Group
Log Name: website_access_logs
Log Retention: 1 month
OCI Logging organizes logs into groups called Log Groups. You are free to create your own log groups, however in this
section we are using the default log group for simplicity.
7.3. You can access the log file from the Logs screen by clicking on the name of the log:
7.5. In another browser window, visit the website again a few times, refreshing the browser window. Doing so will create
entries in the access log.
7.6. View the access log by clicking on its name in the OCI Console. You should now see access log entries.
7.7. Expanding one of the log entries will reveal more details about the request, including which web server handled the
request.
8. Cleaning Up
8.1. Perform the following steps to once you are done with the lab
Skills Learned
At the end of this exercise, you will be able to:
Overview
Up to this point in the lab, you have done everything as a tenancy administrator. As a tenancy administrator, you are a member of the
administrators group, which automatically grants access to do anything in the tenancy without needing explicit permission to do so. In the
real world however, resources need governance – there needs to be a separation of duties to ensure the security, integrity, and availability of
the resources in a tenancy. In plain English, this means putting users in groups and granting access to OCI resources using OCI IAM policies.
An IAM policy is a statement or set of statements that let someone or something do something with an OCI resource. The policy syntax is
based on natural language so it is easy to read and learn.
In this lab you will learn how to organize resources based on a typical organizational structure into compartments and manage them using
IAM policies.
We will also touch on using Identity Cloud Service or IDCS as the preferred method for managing users and groups rather than using local
IAM accounts. Every tenancy comes with an instance of IDCS, which allows you to federate with your company’s identity provider. This
allows you to easily and securely tie into your company’s identity management system without needing to maintain a duplicate set of users in
OCI. You can use IDCS on its own, even if you do not have a corporate identity management system.
Let us pretend that our organization’s IT department has the following teams, members, and responsibilities.
Storage Creating and managing block volumes, including managing backups, snapshots, jane_doe
Admins and migrations.
Developers Developing and deploying applications to compute nodes in the cloud. Team is han_lee
also responsible for creating and managing compute instances, including
attaching storage volumes to compute instances.
We want to set up our tenancy so that it aligns with our organizational structure. Each team will have its own OCI group and each team
member will be given an OCI account.
Compartments will be created to organize and manage OCI resources in alignment with our organizational structure. IAM policies will be
written to grant the groups access to resources.
Instructions
** You need to have the proper permissions in OCI to execute this lab. This lab presumes that you personally created the
OCI tenancy and therefore have the necessary permissions to create and manage resources already. **
1.2. Log into the OCI console using your web browser using the login URL that was in the welcome email from Oracle or go
to cloud.oracle.com and click on sign in.
You should be presented with a login screen that looks similar to the screenshot below. If you have never signed in, you
may be presented with a single dialog asking you for a cloud account name first. Enter in the name of the tenancy that
you specified when signing up. This will also be in your welcome email.
You will then see two options on the login screen. The first option (on the left) allows you to login using SSO. The second
© 2020 TechTipsOnDemand.com 118
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
option (on the right) allows you to login using a local account. Select the second option and use the credentials you
specified when signing up for OCI.
1.3. Once you have logged in, you will be in the OCI console.
Click the stacked bars in the upper left and then click on Identity (near the bottom).
1.5. Create a compartment by clicking the button and specifying the following parameters.
Name: Networks
Description: Put whatever you want here but it is a required field.
Parent Compartment: Select the OCI_Labs compartment
Click the button at the bottom of the dialog to create the compartment.
1.6. The Networks compartment should now appear in the list of compartments in the OCI console under the OCI_Labs
compartment.
1.7. Create the DevTeam compartment following the same steps as the Networks compartment.
NetworkAdmins
StorageAdmins
DevTeam
You will eventually write IAM policies that grant these groups access to certain OCI resources.
2.2. Access OCI Groups by selecting Groups under Identity. You can also click on the stacked bars in the upper-left, then
navigate to Identity then Groups.
Notice there is one group already created: Administrators. This group was created when we created the tenancy and
contains at least one user – the person who created the tenancy.
2.3. Click Create Group and specify the following parameters for the Network Admins group.
Name: NetworkAdmins
Description: Put whatever you want here but it is a required field.
2.4. Repeat the process for the StorageAdmins group and the DevTeam group.
2.5. You may have seen various warnings and notices about creating federated groups. What we are doing here in this lab is
creating local users and groups, which live and are managed only within OCI. OCI supports federation with an external
identity provider (IdP) that allows users to log in using SSO. Federated users and groups are managed by the IdP, not
by OCI.
2.6. Now let’s create some users. Click on Users on the left side of the screen under Identity.
2.7. Use the Create User button to create the following users. You can leave the email addresses blank.
2.9. Next let’s assign these users to the right groups. You can either add a user to a group, or a group to a user.
For this tutorial we will be adding users to a group through the Group interface. This is preferred if you are adding users
in bulk.
2.11. Repeat the above steps to add jane_doe to the StorageAdmins group and han_lee to the DevTeam group.
2.12. At this point, users have been created and assigned to groups, but the users do not yet have any credentials to login or
access OCI.
You can assign a one-time password to a user in the Console. When the user logs into the console for the first time, they
will be asked to change the password.
2.13. Generate a password for joe_smith by clicking the Create/Reset Password button. Then click Create/Reset Password
button again to confirm the action.
2.14. A new password will be generated for the user. You must save the password somewhere until you log in as this user.
If you lose the password, you can always repeat the above steps to rest the password.
2.15. Repeat the above steps to create passwords for jane_doe and han_lee. Be sure to save each of the passwords.
2.16. Let’s verify that we can log in as one of the users using the new password.
First you need to log out of the OCI Console. Locate the profile icon in the upper right of the screen and select Sign out.
2.17. Log back in using the joe_smith local user and the password that was generated.
2.18. You will be asked to change the password when you log in for the first time.
© 2020 TechTipsOnDemand.com 132
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
2.19. The users we created do not yet have any permissions assigned to them. We did add users to a group, but we have not
yet written any IAM policies granting users access to really do anything.
2.20. Notice how the user can only see the root compartment and the managed compartment for PaaS. This user cannot see
any of the compartments that were created earlier because we have not granted this user any permissions. Users need
INSPECT permission at a minimum to see a list of compartments.
The dialog will appear, and you are able to fill it out. However when you click the create button, you will receive an
authorization error. This is expected since this user has not been given any permissions.
3.2. Log back into the OCI console as a tenancy administrator. (In most cases, this is the account you used to sign up for
OCI).
3.4. Policies are created in a compartment, just like most other OCI resources you will create.
You will see two default policies – one for the Tenancy Admin and one called PSM-root-policy.
3.5. To see what a policy looks like, click on the Tenancy Admin policy. This policy grants the group Administrators access to
manage all resources in the tenancy.
3.6. Click on Policies in the breadcrumbs near the upper left to go back to the list of policies.
3.7. The first policy we want to write is to allow everyone in our tenancy to see the list of compartments. This will allow users
to see what compartments are available through the OCI Console or through the OCI API, however it will not allow users
to create compartments. Only administrators will be allowed to create compartments.
Under List Scope, select the root compartment so that we are viewing policies for the root compartment.
3.8. Click Create Policy. This will launch the create policy dialog.
Name: Default_User_Policy
Description: Default policy that will apply to all users
Keep Policy Current: Enabled
Compartment: (root)
This policy will let everyone in the tenancy read all compartments. Any-user is a special group that automatically refers to
every user in the tenancy.
3.9. Notice that a policy can have more than one statement, which is handy if you wish to group related policy statements into
a single policy.
Click on the Customize(Advanced) link and Create a new policy with the following parameters.
Name: Network_Management_Policy
Description: Network management policy
Compartment: root
© 2020 TechTipsOnDemand.com 138
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
The last portion of the policy statement specifies the location where the access is being granted, in this case the
OCI_Labs compartment, which will include any child compartments as well.
4.2. Let’s verify this policy statement actually works by logging in as the network admin and see if we can create a virtual
cloud network.
4.3. Log out of the OCI console and log back in as joe_smith. You will be asked to set a password for this user upon first
login.
4.4. Navigate to Networking > Virtual Cloud Networks from the left-hand navigation pane.
By default you are in the root compartment after logging into the OCI console. You should see an authorization failed
error on the Virtual Cloud Networks screen. This is because joe_smith has not been granted any network-related access
in the root compartment.
Let’s verify that right now by creating a virtual cloud network using the VCN Wizard.
d. Accept all other default values and finish creating the VCN.
The Wizard will create the VCN and all supporting networking services in the Networks compartment.
4.6. Let’s see if Joe can create any compute instances in the private subnet.
Navigate to Compute Instances and try provisioning a compute instance in the OCI Labs, Networks, or DevTeam
compartments.
You can tell immediately that the Joe, who is a network admin, cannot even see a list of available compute instances in
any compartment as the OCI Console displays an authorization error when trying to render the page.
A Network Admin should be able to at least see what compute instances are deployed in a VCN.
You will have to log back into the OCI Console as yourself to create the policy.
4.7. Log back into the OCI Console as Joe Smith and review the list of compute instances in the OCI Labs compartment by
going to Compute > Instances.
Joe should now be able to see the two compute instances that were created earlier in this lab: bastion1 and app1.
If you try to create an instance as Joe, you will be met with an authorization error since the NetworkAdmins only have
READ permission on compute instances.
The next policy you will write will allow the storage team the ability to create block volumes and take backups.
The first statement lets the storage admins manage volumes in the OCI Labs compartment, while the second policy
allows the storage admins to attach volumes to compute instances that are deployed in any compartment under OCI
Labs.
The verb USE includes the ability for the storage admins to read compute instances but also attach volumes as well.
5.2. Log into the OCI Console as Jane Doe and verify the following actions:
The first statement lets the dev team manage instance-family in the DevTeam compartment. Instance-family refers to a
family of compute resources. The verb manage lets the group do everything with those resources.
The second and third statements let the dev team attach block volumes to compute instances, however they cannot
create, delete, or backup those volumes.
The fourth statement lets the dev team use networking resources in the Networks compartment. This policy is required to
provision compute instances in a subnet. Similar to the second policy statement, the dev team only has permission to
7.2. Create an Always Free Eligible compute instance in the DevTeam compartment with the following parameters:
Under Networking…
Select the test-vcn from the Networks compartment.
Select the Private Subnet-test-vcn from the Networks compartment.
Accept all other default values and click Create. A compute instance should be provisioned in the DevTeam
compartment as shown below:
7.3. Try to attach the app_datavol2 block volume created earlier to the compute instance.
Click on the compute instance you just created, then select Attached Block Volumes under Resources.
Disregard the authorization error you may see in the OCI Console, as the Console is attempting to list block storage
volumes in the DevTeam compartment, to which you do not have access.
a. Select Paravirtualized
b. Select the app_datavol2 from the DevTeam compartment
c. Click Attach
Users and groups are created and managed in the Identity Provider and are federated with your OCI tenancy. The
federated groups are mapped to local OCI groups so that those federated users can be granted access to OCI resources
through IAM policies.
When you sign up for an Oracle cloud tenancy, you get a free Oracle Identity Cloud Service instance. This IDCS
instance is automatically federated with OCI.
In this lab you will learn how create and manage a federated user and group.
8.2. Log into the OCI Console as yourself or someone with tenancy administration privileges.
8.3. Under Identity select Federation.
8.5. On the OracleIdentityCloudService details page, click the link for the Oracle Identity Cloud Service Console.
This link will launch the login page for the IDCS console, which is a separate console from the OCI console.
8.6. Log in using your OCI credentials. You will be presented with the IDCS console.
IDCS is a full-featured Identity Management Service from Oracle that supports federation with on-prem IdP as well as
acting as an IdP itself. In this lab, IDCS is our IdP and we will create a user and group in the IdP.
8.7. In the upper left, click on the stacked bars and select groups.
© 2020 TechTipsOnDemand.com 143
A Practical Guide to Oracle Cloud for Infrastructure Lab Guide
8.8. Click the Add button to add a group, specifying the following parameters:
Name: NetworkAdminsFederated
Click Finish.
8.9. Click on Users in the left hand side then click the Add button to add a new user.
8.10. In the New User dialog, first uncheck the ‘Use the email address as the user name’ box enter the following information:
8.11. Click Next and then select the NetworkAdminsFederated group then click Finish.
IDCS will create the user and map it to the group. IDCS will also send an email with a link to activate the account and for
setting a password.
8.12. Before activating the account, log out of both IDCS and the OCI Console.
Activate the account and set a password using the link provided in the email from Oracle.
8.13. Now navigate back to the OCI console login page.
Select the oracleidentitycloudservice Identity Provider under Single Sign-On and click Continue.
8.14. Log in using joe_smith as the username and the password you specified.
8.15. Once you are logged in, you can tell that you are logged in through SSO using IDCS by clicking on the profile icon in the
upper right hand corner of the console. Your username will be prefixed with the name of the identity provider.
You will be taken to the user’s profile page. Under Groups you will see a message stating that group membership for
federated users is done by the identity provider, not by OCI.
When we created joe_smith in IDCS, we placed him in a group called NetworkAdminsFederated. This IDCS group is
also federated with OCI, so it is available for us to use in OCI.
8.17. Log out of the OCI Console and log back in as yourself or someone with tenancy admin privileges.
8.18. Navigate to Identity > Federation in the OCI Console and click on OracleIdentityCloudService.
Let’s map the NetworkAdminsFederated group to the NetworkAdmins local OCI group.
8.22. The federated group is now mapped to the NetworkAdmins group and is subject to all existing IAM policies. So Joe
Smith, our network admin, can log into OCI using SSO/IDCS and create and manage network resources just like a local
user.
Feel free to verify group mapping and policies work by logging in to OCI using SSO rather than Direct Sign-in.
References
Create an Oracle Account
https://login.oracle.com/mysso/signon.jsp
Appendix A : How to Access Private OCI Compute Instances using a Jump Server
To connect to a private compute instance that does not have a public IP address, you use another server to jump through that has a public IP
address. This jump server, sometimes called a bastion has both a public IP address and a private IP address that is part of the VCN where the
private compute instance lives. To connect to a private instance, you first ssh to the bastion using its public IP address, then jump to the
private instance using the private instance's private IP.
SSH agent forwarding handles passing your private SSH key to the private instance that you are trying to connect to without having to store
the private key on the bastion host.
This guide will show you how to set up SSH agent forwarding for both Windows and Linux
1. PuTTy installed
2. Paegant installed (usually comes bundled with PuTTy)
3. Private SSH keys for the bastion and private compute instance you want to connect to. This is covered in the lab on Core
Compute.
Step 1: Load your SSH keys into Paegant
Pageant is a Putty utility that allows you to load SSH keys into memory.
1) Launch Paegant from the Start Menu. Paegant will appear in the system tray.
Next we need to configure PuTTy to forward our SSH keys to the target private compute instance by configuring SSH agent forwarding.
1) Launch PuTTy
2) Create a new session for connecting to the bastion server by specifying the username and public IP address in the Hostname field. The
default username for Oracle Linux images is opc or oci. The default username for Ubuntu images is ubuntu.
3) Under Connections > SSH > Auth, check the box to allow agent forwarding.
4) On the same screen, under Private key file for authentication, specify the private key for the bastion server.