TheKoguryo's Tech Blog

 Version 2024.05.05

Warning

This content has been generated by machine translation. The translations are automated and have not undergone human review or validation.

14.2.3 Obtaining Terraform OCI Provider Connection Information

  1. Tenancy OCID

    Click Tenancy in the user profile in the upper right corner and check the Tenancy OCID

  2. user OCID

    Click User Settings in the user profile in the upper right corner and check the user OCID

    image-20220118104730184

    image-20220118103801159

  3. region: Region Identifier to use

  4. API Key - private_key_path, fingerprint

    • Use the API Key used when installing OCI CLI.
    • Or create a new one.
      • Refer to 3.3 Creating Key Pair for SSH Connection to create SSH Key Pair to be used
      • Click User Settings in the upper right user profile
      • After selecting API Keys at the bottom left, click Add Key to copy and register the contents of the PEM format public key
      • Copy the fingerprint you see after registration
  5. variable “compartment_ocid”

    • Open the navigation menu in the OCI console. Go to Identity & Security » Identity » Compartments.
    • Click the desired compartment and check the OCID image-20220118180608358

Example of Terraform Variable File Creation

  • If the file name is different to change the variable according to the environment, the file name can be specified with the -var-file option when running terraform.

  • terraform.tfvars

    # OCI authentication
    tenancy_ocid     = "ocid1.tenancy.oc1..~~~"                       # Use the Tenancy OCID from #1
    user_ocid        = "ocid1.user.oc1..~~~"                          # Use the User OCID found in #2
    compartment_ocid = "ocid1.compartment.oc1..~~~"                   # Use the target Compartment OCID from 5
    private_key_path = "C:\\Users\\TheKoguryo\\.oci\\oci_api_key.pem" # Location of the private key among the SSH keys created in #3
    fingerprint      = "7b:e7:~~~~"                                   # Fingerprint of Public Key registered as API Key in #3
    region           = "ap-seoul-1"                                   # The target Region Name identified in 4
    


As an individual, this article was written with my personal time. There may be errors in the content of the article, and the opinions in the article are personal opinions.

Last updated on 18 Jan 2022