{"id":15652914,"url":"https://github.com/garutilorenzo/oracle-cloud-terraform-examples","last_synced_at":"2025-04-30T17:22:09.541Z","repository":{"id":59830803,"uuid":"422193598","full_name":"garutilorenzo/oracle-cloud-terraform-examples","owner":"garutilorenzo","description":"Oracle cloud terraform examples, provision oracle cloud resources using terraform","archived":false,"fork":false,"pushed_at":"2023-11-10T11:39:41.000Z","size":65,"stargazers_count":33,"open_issues_count":0,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T07:47:09.052Z","etag":null,"topics":["automation","iac","k3s","load-balancer","oci-terraform-modules","oracle","oracle-cloud","oracle-cloud-infrastructure","oracle-compute","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garutilorenzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-28T12:22:40.000Z","updated_at":"2024-12-04T20:04:34.000Z","dependencies_parsed_at":"2024-10-03T12:44:23.708Z","dependency_job_id":"c9b6197a-f85b-4b66-bd71-95f6dccfa22d","html_url":"https://github.com/garutilorenzo/oracle-cloud-terraform-examples","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garutilorenzo%2Foracle-cloud-terraform-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garutilorenzo%2Foracle-cloud-terraform-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garutilorenzo%2Foracle-cloud-terraform-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garutilorenzo%2Foracle-cloud-terraform-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garutilorenzo","download_url":"https://codeload.github.com/garutilorenzo/oracle-cloud-terraform-examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251749136,"owners_count":21637460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","iac","k3s","load-balancer","oci-terraform-modules","oracle","oracle-cloud","oracle-cloud-infrastructure","oracle-compute","terraform"],"created_at":"2024-10-03T12:44:14.441Z","updated_at":"2025-04-30T17:22:09.517Z","avatar_url":"https://github.com/garutilorenzo.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub issues](https://img.shields.io/github/issues/garutilorenzo/oracle-cloud-terraform-examples)](https://github.com/garutilorenzo/oracle-cloud-terraform-examples/issues)\n![GitHub](https://img.shields.io/github/license/garutilorenzo/oracle-cloud-terraform-examples)\n[![GitHub forks](https://img.shields.io/github/forks/garutilorenzo/oracle-cloud-terraform-examples)](https://github.com/garutilorenzo/oracle-cloud-terraform-examples/network)\n[![GitHub stars](https://img.shields.io/github/stars/garutilorenzo/oracle-cloud-terraform-examples)](https://github.com/garutilorenzo/oracle-cloud-terraform-examples/stargazers)\n\n# Oracle Cloud terraform examples\n\nDeploy Oracle Cloud services using Oracle [always free](https://docs.oracle.com/en-us/iaas/Content/FreeTier/freetier_topic-Always_Free_Resources.htm) resources\n\n**Note** choose a region with enough ARM capacity\n\n### Important notes\n\n* This is repo shows only how to use terraform with the Oracle Cloud infrastructure and use only the **always free** resources. This examples are **not** for a production environment.\n* At the end of your trial period (30 days). All the paid resources deployed will be stopped/terminated\n* At the end of your trial period (30 days), if you have a running compute instance it will be stopped/hibernated\n\n### Table of Contents\n\n* [Repository structure](#repository-structure)\n* [Requirements](#requirements)\n  * [Setup RSA Key](#example-rsa-key-generation)\n* [Oracle provider setup](#oracle-provider-setup)\n* [Project setup](#project-setup)\n* [Firewall](#firewall)\n* [OS](#os)\n* [Shape](#shape)\n* [Useful documentation](#useful-documentation)\n\n### Repository structure\n\nIn this repositroy there are 7 terrafrom modules, in order of dependency:\n\n* [simple-vcn](simple-vcn/) - Setup a VCN with two PUBLIC subnets\n* [private-vcn](private-vcn/) - Setup a VCN with one PUBLIC subnet and one PRIVATE subnet\n* [nat-instance](nat-instance/) - Setup a NAT instance (with the Oracle always free account you can't deploy a NAT gateway)\n* [simple-instance](simple-instance/) - Deploy a simple instance in a private or public subnet\n* [instance-pool](instance-pool/) - Deploy multiple instances using a Oracle instance pool and instance configurations\n* [load-balancer](load-balancer/) - Deploy a public load balancer (Layer 7 HTTP)\n* [network-load-balancer](network-load-balancer/) - Deploy a private load balancer (Layer 4 TCP)\n\nFor more information on how to use this modules follow the examples in the *examples* directory. To use this repository, clone this repository and use the *example* directory as base dir.\n\n### Requirements\n\nTo use this repo you will need:\n\n* an Oracle Cloud account. You can register [here](https://cloud.oracle.com)\n\nOnce you get the account, follow the *Before you begin* and *1. Prepare* step in [this](https://docs.oracle.com/en-us/iaas/developer-tutorials/tutorials/tf-provider/01-summary.htm) document.\n\nYou need also:\n\n* [Terraform](https://www.terraform.io/) - Terraform is an open-source infrastructure as code software tool that provides a consistent CLI workflow to manage hundreds of cloud services. Terraform codifies cloud APIs into declarative configuration files.\n* [kubectl](https://kubernetes.io/docs/tasks/tools/) - The Kubernetes command-line tool (optional)\n* [oci cli](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/cliconcepts.htm) - Oracle command line interface (optional)\n\n#### Example RSA key generation\n\nTo use terraform with the Oracle Cloud infrastructure you need to generate an RSA key. Generate the rsa key with:\n\n```\nopenssl genrsa -out ~/.oci/\u003cyour_name\u003e-oracle-cloud.pem 4096\nchmod 600 ~/.oci/\u003cyour_name\u003e-oracle-cloud.pem\nopenssl rsa -pubout -in ~/.oci/\u003cyour_name\u003e-oracle-cloud.pem -out ~/.oci/\u003cyour_name\u003e-oracle-cloud_public.pem\n```\n\nreplace *\u003cyour_name\u003e* with your name or a string you prefer.\n\n**NOTE** ~/.oci/\u003cyour_name\u003e-oracle-cloud_public.pem this string will be used on the *terraform.tfvars* used by the Oracle provider plugin, so please take note of this string.\n\n### Project setup\n\nOnce you have cloned this repo, change directory to [examples](examples/) dir and choose the example you prefer: *private subnet* or main.tf or *public subnet* main.tf-public file. Edit the example file and set the needed variables (*change-me* variables). Crate a *terraform.tfvars* file, for more detail see [Oracle provider setup](#oracle-provider-setup) and read all the modules requirements in each module directory.\n\nOr if you prefer you can create a new empty directory in your workspace and start a new project from scratch. To setup the project follow the README.md in the [examples](examples/) directory.\n\n### Oracle provider setup\n\nThis is an example of the *terraform.tfvars* file:\n\n```\nfingerprint      = \"\u003crsa_key_fingerprint\u003e\"\nprivate_key_path = \"~/.oci/\u003cyour_name\u003e-oracle-cloud_public.pem\"\nuser_ocid        = \"\u003cuser_ocid\u003e\"\ntenancy_ocid     = \"\u003ctenency_ocid\u003e\"\ncompartment_ocid = \"\u003ccompartment_ocid\u003e\"\n```\n\nTo find your tenency_ocid in the Ocacle Cloud console go to: Governance and Administration \u003e Tenency details, then copy the OCID.\n\nTo find you user_ocid in the Ocacle Cloud console go to User setting (click on the icon in the top right corner, then click on User settings), click your username and then copy the OCID\n\nThe compartment_ocid is the same as tenency_ocid.\n\nThe fingerprint is the fingerprint of your RSA key, you can find this vale under User setting \u003e API Keys\n\n#### How to find the availability doamin name\n\nTo find the list of the availability domains run this command on che Cloud Shell:\n\n```\noci iam availability-domain list\n{\n  \"data\": [\n    {\n      \"compartment-id\": \"\u003ccompartment_ocid\u003e\",\n      \"id\": \"ocid1.availabilitydomain.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n      \"name\": \"iAdc:EU-ZURICH-1-AD-1\"\n    }\n  ]\n}\n```\n\n#### How to list all the OS images\n\nTo filter the OS images by shape and OS run this command on che Cloud Shell:\n\n```\noci compute image list --compartment-id \u003ccompartment_ocid\u003e --operating-system \"Canonical Ubuntu\" --shape \"VM.Standard.A1.Flex\"\n{\n  \"data\": [\n    {\n      \"agent-features\": null,\n      \"base-image-id\": null,\n      \"billable-size-in-gbs\": 2,\n      \"compartment-id\": null,\n      \"create-image-allowed\": true,\n      \"defined-tags\": {},\n      \"display-name\": \"Canonical-Ubuntu-20.04-aarch64-2022.01.18-0\",\n      \"freeform-tags\": {},\n      \"id\": \"ocid1.image.oc1.eu-zurich-1.aaaaaaaag2uyozo7266bmg26j5ixvi42jhaujso2pddpsigtib6vfnqy5f6q\",\n      \"launch-mode\": \"NATIVE\",\n      \"launch-options\": {\n        \"boot-volume-type\": \"PARAVIRTUALIZED\",\n        \"firmware\": \"UEFI_64\",\n        \"is-consistent-volume-naming-enabled\": true,\n        \"is-pv-encryption-in-transit-enabled\": true,\n        \"network-type\": \"PARAVIRTUALIZED\",\n        \"remote-data-volume-type\": \"PARAVIRTUALIZED\"\n      },\n      \"lifecycle-state\": \"AVAILABLE\",\n      \"listing-type\": null,\n      \"operating-system\": \"Canonical Ubuntu\",\n      \"operating-system-version\": \"20.04\",\n      \"size-in-mbs\": 47694,\n      \"time-created\": \"2022-01-27T22:53:34.270000+00:00\"\n    },\n```\n\n**Note:** this setup was only tested with Ubuntu 20.04\n\n### Firewall\n\nBy default firewall on the compute instances is disabled (except for the nat instance).\n\n### Software installed\n\nIn the simple-instance example and in the instance-pool example nginx will be installed by default.\nNginx is used for testing the security list rules an the correct setup of the Load Balancer.\n\nOn the k3s-cluster example, k3s will be automatically installed on all the machines. **NOTE** k3s-cluster setup has moved to [this](https://github.com/garutilorenzo/k3s-oci-cluster) repository.\n\n### OS\n\nThe operating system used is Ubuntu 20.04\n\n### Shape\n\nAll the provisioned instances are VM.Standard.A1.Flex (Arm processor) with 6GB of ram and 1 CPU.\n\nWith the Oracle always free you can run 4 VM.Standard.A1.Flex instances for free (24 GB of ram an 4 CPU).\n\n**Note** choose a region with enough ARM capacity\n\n### Useful documentation\n\nSetup the [default vcn resources](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformbestpractices_topic-vcndefaults.htm) documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarutilorenzo%2Foracle-cloud-terraform-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarutilorenzo%2Foracle-cloud-terraform-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarutilorenzo%2Foracle-cloud-terraform-examples/lists"}