Oracle Cloud Infrastructure Cloud Shell - integrated OCI CLI, kubectl, terraform, SQL Plus, Docker and Maven image 2

Oracle Cloud Infrastructure Cloud Shell – integrated OCI CLI, kubectl, terraform, SQL Plus, Docker and Maven

Cloud Shell in Oracle Cloud Infrastructure is a free browser based command line tool for various types of interactions within your OCI Tenancy. When you start Cloud Shell, a command line is opened in your browser. You are in a Linux environment (Oracle Linux 7.7) that runs within the OCI Tenancy and has access to your OCI resources with your user’s permissions. Note: if you are a Tenancy Owner or member of the Administrators group, you can use Cloud Shell without further ado. Other users need to be in a group that through an IAM policy have been granted the permission to use cloud shell (policy text: allow group <GROUP-NAME> to use cloud-shell in tenancy) .

The Cloud Shell comes with many tools pre-installed, including:

  • OCI CLI (2.9.5) – the Oracle Cloud Infrastructure Command Line tool
  • Terraform (0.12.21) – the infrastructure as code resource provision tool with the OCI provider to manage OCI resources from Terraform templates’
  • Ansible (2.8.4) – to orchestrate, provision and configure your infrastructure on OCI using OCI modules in Ansible Playbooks
  • Fn client (0.5.92) – for working with Project Fn Serverless Functions
  • Git client – to clone Git repos for example with CLI scripts, Terraform templates or other resources
  • kubectl (and helm) – to manage Kubernetes resources
  • Java (1.8) , Python (2 and 3) , Node (10.19) and NPM (6.13.4), Go (1.13.8), Perl (5.16.3), PHP (7.2.28), Ruby (2.5.5)
  • Docker (19.03)
  • Maven and Gradle – to build Java applications
  • SQL*Plus (no SQLcl) (19.5) – to interact with DBaaS and Autonomous Database
  • MySQL Client (8.0.19)
  • nano, vi, jq

(the version labels are the ones I wrote down on March 15th 2020; I am assuming that the Cloud Shell VM Image will be updated regularly with later versions of these tools)

image

Cloud Shell is a small VM that runs a Bash shell with many tools installed (see overhead) and comes with 5GB of storage for the home directory. Whatever you do in Cloud Shell is persisted across sessions of the shell. Files you create will be retained. However, if you do not access Cloud Shell for more than 6 months, the storage is purged.

Cloud Shell is really useful to very quickly – from the comfort of the console – run scripts in the proper context of the cloud tenancy. Most things you can do in OCI CLI and Terraform can be done in the console as well – although not in an automated fashion. The Cloud Shell makes using the CLI and Terraform especially convenient and also adds easy support for other tools to interact with OCI resources.

Some examples:

  • query resources with CLI
  • manage resource with Terraform
  • operate on OCI resources using Ansible
  • invoke OCI REST API from Node
  • clone project from a Git repo, build containers, push containers to registry and run containers locally in Docker or on the OCI Kubernetes cluster
  • create Fn functions in Go, Java,  Node and deploy them to FaaS

For clipboard operations, Windows users can use Ctrl-C or Ctrl-Insert to copy, and Shift-Insert to paste. For Mac OS users, use Cmd-C to copy and Cmd-V to paste.

Note: Cloud Shell was first released in February 2020, Initially, Cloud Shell was not available in trial OCI accounts. I first saw Cloud Shell in my trial account on March 14th 2020.

For me, the scrollbar does not work (in Google Chrome). I managed to scroll the page using mouse click + hold mouse + move mouse up or down.

Example: query resources with CLI

Start Cloud Shell. Paste this snippet (using Shift Insert in Windows and Cmd-V on Mac)

#list compartments in your tenancy (the ones you an see)
oci iam compartment list
# list the Object Storage buckets - replace the OCID for one of your own compartments' OCID values
oci os bucket list -c ocid1.tenancy.oc1..aaaaaaaag7c7sl
# list the objects in one of the buckets; replace the bucketname with one of your own
oci os object list -bn cloud-native-lab-resources
# download one of the files in the bucket; replace the bucket name and file name with your own
oci os object get -bn cloud-native-lab-resources --name lab-user-in-AMIS-LAB-USER3 --file localfile.txt

image

The final result:

image

Resources

OCI Documentation on Cloud Shell: https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/cloudshellintro.htm

3 minute video – introducing Cloud Shell: https://www.youtube.com/watch?v=J51BXxlCbOY

Blog article announcing Cloud Shell: https://blogs.oracle.com/cloud-infrastructure/announcing-oracle-cloud-shell