Overview
In this section, we will initilize the terraform for our environment. Now, it is important to remember that, terraform is Infrastructure as a Code tool, meaning, we write the code and terraform configure the infrastructure on cloud side. Because of that we have to install the necessary providers (Cloud Providers: OCI, AWS, Azure, etc) So let's get started with OCI:
Setting up a provider
There are several cloud providers:
- Oracle: OCI
- Amazon: AWS
- Microsoft: Azure
- Alibaba: No idea
- Others: No idea
So let's focus on the OCI for now. From your account, (top right corner in OCI), you can generate new API key value pairs and when you do, you will have the followng information:
OCI API key info
[DEFAULT] user=ocid1.user.oc1..**************************** fingerprint=***************************** tenancy=ocid1.tenancy.oc1..********************** region=us-******-1 key_file=<path to your private keyfile> # TODO
These values are important for us. So choose a folder, where you want to have your terraform repository initialized and created the following file:
provider.tf
julien.andonov@julienaonovsMBP adi_redis % cat provider.tf provider "oci" { tenancy_ocid = "ocid1.tenancy.oc1..************************" user_ocid = "ocid1.user.oc1..****************************" private_key_path = "/Users/Julien.andonov/***************/oracle_oci_julien_andonov_private_key.pem" fingerprint = "5a:79:c4:4*****************a:9d:26:5a:2d:f8" region = "us-phoenix-1" }
After that, we need to initiliza the environment:
Initialization
julien.andonov@julienaonovsMBP adi_redis % terraform init Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/oci... - Installing hashicorp/oci v4.118.0... - Installed hashicorp/oci v4.118.0 (signed by HashiCorp) Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. ╷ │ Warning: Additional provider information from registry │ │ The remote registry returned warnings for registry.terraform.io/hashicorp/oci: │ - For users on Terraform 0.13 or greater, this provider has moved to oracle/oci. Please update your source in required_providers. ╵ Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. julien.andonov@julienaonovsMBP adi_redis %