Hello. This presentation shows you how to install the Oracle Cloud Infrastructure command
line interface - or CLI - and terraform. You also see how to collect essential information,
and then deploy an Oracle Linux instance using two simple terraform language files.
In this demonstration, start with an Oracle Linux 7 instance in Oracle Cloud Infrastructure.
This instance operating system has been updated.
Install the Oracle Cloud Infrastructure CLI utility and Terraform with the command:
sudo yum install python36-oci-cli terraform -y
The installations complete in about a minute.
At this time, we must collect the user and tenancy OCID values to configure the CLI to
run.
Navigate through the profile and click on the user option to display the Oracle Cloud
Infrastructure console user details page. Click the Copy link next to the OCID snippet....
Then paste the value into a notes file which will later become a Terraform file with variable
assignments.
Navigate through the profile and click on the tenancy option to display tenancy details.
Click the Copy link next to the OCID snippet....
Then paste the value into the notes file.
Return to the terminal and enter the command oci setup config. This starts the configuration
process so that CLI calls made to the API are automatically authenticated.
Press enter to accept the configuration file /home/opc/.oci/config.
Copy the user OCID from the notes file, and paste it into the user OCID prompt.
Copy the tenancy OCID from the notes file, and paste it into the tenancy OCID prompt.
Copy the region from the list provided, and paste it into the prompt.
For this demonstration, I enter Y to generate an API signing key pair.
Press enter to accept the key file location at /home/opc/.oci.
Press enter to accept the key file name token oci_api_key.
For this demonstration, press enter to leave empty for no pass phrase.
The configuration setup completes and displays full key file names, fingerprint and confirmation
of the configuration file location.
With the configuration setup complete on the instance, return to the user details display
and click API Keys in the Resources menu. Click Add API key. For this demonstration,
paste the key, which is the public key from /home/opc/.oci.
Click add, and a preview of the config file appears on the screen. Note the five values
necessary to use the API: The user OCID, fingerprint, tenancy OCID, region, and location of the
private key file, although only a placeholder in this display.
Navigate through the console menu, through the Identity option, then click on Compartments.
Check all the pages, if necessary to locate the compartment for the instance. From the
Compartment details, click the Copy link next to the OCID snippet and paste the value into
the notes file.
Next, navigate to the details page for the subnet on which you want the instance primary
VNIC to be attached. Click the copy link next to the OCID snippent, then paste the value
into the notes file.
Use the browser to find the instance shape for the region. See docs.cloud.oracle.com/en-us/Iaas/Content/Compute/References/computeshapes.htm
Click the Standard Shapes link on the right side of the page, then select the name of
the shape to use.
For this demonstration, use the VMStandard2.1 shape. Copy and paste the value into the notes
file.
To get the image OCID, navigate to docs.cloud.oracle.com/en-us/Iaas/Images
On this page, click Oracle Linux 7 on the left side menu, then click on the name of
the latest Oracle Linux 7 shape. On the details page, scroll to find the OCID value for the
us-ashburn-1 region. Select, copy and paste the OCID value into the notes file.
Two Terraform Code files were created for this demonstration.
The file variables.tf was created from the notes file where all the collected OCID and
other values were stored. This file includes the variables used to authenticate access
to the Oracle Cloud Infrastructure, including the user_ocid, tenancy_ocid, key fingerprint,
the API private key file location, and region.....
Other variables are used to create the instance, including the compartment.. and subnet.. ocid
values, the instance shape name, image_ocid, Availability Domain, and location of the public
key that will be used by the instance.
The file main.tf includes the oci provider code block, which passes variable values to
the oci provider for authentication.....
The resource block is based on the oci_core_instance structure and includes values necessary to
create the Oracle Linux instance on an existing subnet.
The two files are in a directory called terraform-intro, which is located under /home/opc for this
demonstration.
To start, run the command terraform init. This command initializes Terraform and provides
some information about the current version of the provider plugin.
Clear the screen.
Run the command terraform plan. This command reviews the code and displays a message that
indicates one object will be added, which is the Oracle Linux Instance.
Clear the screen.
Run the command terraform apply.
A message appears confrming the plan to add one object and asking for the word "yes" to
approve it. Enter yes.
The code files are processed by Terraform, and the instance creation process begins as
periodic messages appear on the screen.
When the process completes, the messages include the instance OCID value and confirmation that
one object has been created.
Oracle provides an extensive number of resources you can use to learn more about this and related
topics. Use the links here to find more content about this video, Terraform and Oracle Linux
on Oracle Cloud Infrastructure.
This ends the presentation. Thank you for watching.