OCI Code Editor
We discussed
about OCI Resource manager in the previous post. Resource manager is a managed
service to execute terraform code. In this article, let’s look at
another powerful tool - OCI Code Editor, a serverless development environment
that allows us to write, store, and run Terraform code directly from the Oracle
Cloud Infrastructure console.
OCI Code
editor is part of OCI Developer services which comes with inbuilt developer
tools like python, oci command line, terraform, ansible, docker, yum, shell,
etc. We can create executables and can be executed through the appropriate
tools. The interface is similar to Microsoft visual studio, expect the plugins
are already installed. In this article we will discuss how to use OCI editor
and how to execute terraform code.
Code editor
can be invoked from dashboard in oci console. It will take few minutes to open
the code editor. Like OCI Resource manager the oci authentication happens
internally, code editor runs OCI Shell inside with direct access to OCI
resources. It doesn’t need explicit terraform provider or authentication protocol.
Code editor
has 4 components, Explorer, Search, Source control repository and Plugins.
Explorer –
File browser for Cloud shell.
Search – To
search files having specific keyword.
Source control
repository – Option to integrate with
OCI DevOps repository. We can store our code in OCI Devops repository and clone
it. Using Git operations we can pull, push, commit, branch. Its similar to visual
studio code.
Plugins – By
default it comes with Core, Data-flow, Functions, Data Science and Resource
manager. We can consider the resources that needs code support are available in
plugin section.
Core – It will
list our all the resources configured in each compartment.
Data-flow-
Dataflow application and projects can be configured in code editor.
Functions –
Applications can be created and configured.
Resource
Manager – OCI Resource manager stacks can be created and accessed from here.
Data
Science – Data science Projects can be accessed and configured.
Terraform
with Code editor
Code editor
uses Cloud Shell internally and Terraform comes installed in code editor by
default.
We will use Explorer option in code editor, In the explorer
we can create folders and Terraform files can be kept inside that.
As the Code
editor uses OCI Cloud Shell internally, we don’t need to include terraform provider
file and authentication variables (tenancy, user OCID).
Since the Code Editor runs on OCI Cloud Shell, Terraform is
already installed and ready to use. We can create a new folder and place our .tf
files inside it. Consider the
example – InstanceS folder in the above picture. This folder has terraform
files to create compute instance with shielding. It has created in module approach
and the module file is in “modules” folder. It has main.tf and variables.tf.
The main terraform code is available at main.tf and the required variables are declared
in variables.tf and its values are defined in terraform.tfvars file. The
terraform code is available at https://github.com/kmkittu/OCIRepo
The terraform
files can be created/edited here, or it can be uploaded from local storage.
Terraform
code execution
The terraform
code can be executed via Integrated terminal.
Right click
on Instance folder and click “Open in Integrated Terminal”
We can execute
all terraform commands (init, plan, apply, etc) here.
Terraform execution is seamless and fully supports
integration with version control (Git) operations for managing our
infrastructure as code.
No comments:
Post a Comment