How to automate OCI with Terraform

Lesson 1 – VCN, Subnet and Single Webserver

In this lesson you will create the simplest set of OCI resources, starting with one compartment, one VCN, and one subnet in this VCN. The subnet will be regional (covering all availability domains AD1-AD3). Inside this public subnet, we will nest one VM for Webserver. Public subnet means that VM will have public IP associated – VM will be exposed to the public Internet (via Internet Gateway and proper route table). After this deployment, one basic Security List will permit access from the public Internet to VM via protocol SSH (port 22) & HTTP/HTTPS protocols (port 80, 443). For the software provisioning, we will utilize null_resource and remote-exec capability of Terraform Null Provider – Terraform will install the HTTP server with root webpage content. As a consequence, after successful terraform apply, we should be able to visit VM public IP address with our web browser and expect their simple webpage content – Welcome to! This is WEBSERVER1…


Here is GitHub repo where you can download the code for this lesson.

5 thoughts on “Lesson 1 – VCN, Subnet and Single Webserver

  1. It will require some small changes in the code. You should remove file and in each other tf file you should change the value of compartment_id the attribute (for example compartment_id = var.compartment_ocid). In that case each and every resource will be created in the compartment value populated within TF_VAR_compartment_id system environment (it can be tenant OCID for root compartment or any other compartment below the root compartment).

  2. Hi Luke … I have a question why this command doesn’t work on the subnet (security_list_ids = without brackets … like others resources like a compartment_id …

  3. Super quick course which completely packed with lot of great information. Great 🙂


Leave a Reply

8 thoughts on “How to automate OCI with Terraform

  1. Didn’t see anything that course has a time limit to complete. Not possible to complete this course in that time wouldn’t have signed up if that was case

    1. This is LearnPress timer which will reach zero, but the course will be still available (lifetime access). I am working on disabling this feature which is misleading.

  2. Hello, I can not see the course, Its showing locked for me. Can you please suggest?


Comments are closed.