Set Up a Simple Infrastructure with OCI Terraform

Use Terraform to set up a simple infrastructure in your Oracle Cloud Infrastructure account.

Key tasks include how to:

  • Copy existing scripts from other Terraform tutorials.
  • Edit the scripts to combine all the resources in one directory.
  • Run an apply command to create the following resources:
    • a compartment
    • a virtual cloud network
    • a compute instance
A diagram of the components needed to create a simple Infrastructure with Terraform. From a local Linux environment, the user creates a virtual cloud network with Terraform. This network has a public subnet and a compuete instance that can be reached from the internet. The network also has a private subnet that connects to the internet through a NAT gateway, and also privately connects to the Oracle Services Network. The CIDR block for the virtual cloud network is 10.0.0.0/16, for the public subnet is 10.0.0.0/24, and for the private subnet is 10.0.1.0/24.A diagram of a user connected from a local machine to an Oracle Cloud Infrastructure tenancy.

For more information, see:

Before You Begin

To successfully perform this tutorial, you must have the following:

1. Prepare

Copy the scripts you created in previous Terraform tutorials into a new directory.

2. Edit the Scripts

Edit the scripts to assign a new name for your compartment and to replace all hard-coded OCIDs with references.

3. Create a Simple Infrastructure

Run your Terraform scripts to create a compartment, a virtual cloud network, and a compute instance in the public subnet.

References:

What's Next

Congratulations! You have successfully created a simple infrastructure using Terraform, in your Oracle Cloud Infrastructure account.

Now that you know how to use data sources, resources and modules, go ahead and add new objects from Oracle Cloud Infrastructure Provider to your simple infrastructure.

To explore more information about development with Oracle products, check out these sites: