Code Monkey home page Code Monkey logo

terraform-oci's Introduction

Terraform-OCI

License Oracle Terraform OpenTofu Ansible AlmaLinux Oracle Linux Ubuntu Shell Script

Provision an instance ARM on Oracle OCI with Always Free features and standard machine type.

Important

Be aware of what is included in Always Free mode.
https://www.oracle.com/cloud/free/#free-cloud-trial

📋 Requirements:

📌 Before executing:

Note

It is necessary to get credentials for Terraform execution.

  1. These values are taken directly from the OCI Cloud Console:
  • tenancy_ocid:

Login into your OCI Cloud Console account and then go to this address. In OCID click on Copy or Show, copy and paste into a notepad.

Clique to show example

  • user_ocid:

Main Menu » Domains » OracleIdentityCloudService (Current domain) » Users. Click on your user. In OCID click on Copy or Show, copy and paste into a notepad.

  • Run the commands below to generate a key pair required for authentication:
mkdir ~/.oci
openssl genrsa -out ~/.oci/oci_api_key.pem 2048
chmod go-rwx ~/.oci/oci_api_key.pem
openssl rsa -pubout -in ~/.oci/oci_api_key.pem -out ~/.oci/oci_api_key_public.pem
  • fingerprint:

Capture the public_key generated in the previous step (cat ~/.oci/oci_api_key_public.pem) » access Main Menu » Domains » OracleIdentityCloudService (Current domain) » Users » <<your-email>> » API Keys » Add API Key » Paste Public Key and paste the public key content.

This will generate your fingerprint And access information that you will need to add to the file ~/.oci/config.

  • SSH:

A key pair may be required for SSH access to the instance. If not, generate a new pair with the command ssh-keygen -b 2048 -t rsa.

  1. Add some variables to your .bashrc or .zshrc file by filling them in with the values obtained earlier:
export TF_VAR_tenancy_ocid=<your credencials>
export TF_VAR_user_ocid=<your credencials>
export TF_VAR_fingerprint=<your credencials>
export TF_VAR_private_key_path=~/.oci/oci_api_key.pem
export TF_VAR_public_key_path=$(cat /home/your-username/.ssh/<your-pub-key>.pub)

💻 Usage

Note

You will be able to choose between Ubuntu 20.04 or 22.04 or Oracle Linux or AlmaLinux (Marketplace) images.

  1. Clone this repo.
  2. By default an instance with Ubuntu 22.04 with ARM hardware will be provisioned, if you want another OS modify the instance.tf file on lines 28 and 29, if you wish.
  3. Run terraform init, terraform plan -out= name-of-the-plan and terraform apply. At the end, terraform destroy for deletion of what was created in the OCI.

💾 Remote state

You might want to store your states remotely in an OCI bucket. For this Main Menu » Storage » Object Storage & Archive Storage » create a uniquely named Bucket » Create Pre-Authenticated Request » Permit object reads and writes, and copy the given URL.

In the main.tf file, uncomment lines 9 to 12 and insert the given URL in the address field. This is a purely optional step.

🔧 Post Install Scripts

You can also apply post-installation scripts to your instance through. This project counts as example scripts for nginx provisioning provided by Ansible Galaxy.

To work with these settings, uncomment line 34 in the instance.tf file.

🎁 Sponsoring

If you like this work, give me it a star on GitHub, and consider supporting it buying me a coffee:

PayPal

terraform-oci's People

Contributors

ciro-mota avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.