2 Replies Latest reply on Apr 7, 2018 2:00 AM by User939191-Oracle

    terraform-provider-oci for Mac OS X 64 bit?


      Is there an OCI provider for the Mac?

        • 1. Re: terraform-provider-oci for Mac OS X 64 bit?
          AnilBhagavatula -Oracle

          You can use Linux ZIP file it will work as shell is same on MAC also.



          • 2. Re: terraform-provider-oci for Mac OS X 64 bit?

            darwin_amd64 is the correct provider package to download. I validated the vnc sample works on the mac against my OCI tenancy:


            A. Download terraform binary for Mac OS X, then download darwin_amd64 OCI provider:

            1. $ gunzip darwin_amd64.tar.gz

            2. $ tar -xvf darwin_amd64.tar

            3. $ cp -r darwin_amd64 ~/.terraform.d/plugins/.


            B. Get required keys as documented: generate private key, and add public key to the user via OCI console


            C. Define in .bashrc

            export TF_VAR_tenancy_ocid=ocid1.tenancy.oc1...

            export TF_VAR_user_ocid=ocid1.user.oc1...

            export TF_VAR_compartment_ocid=ocid1.compartment.oc1...

            export TF_VAR_fingerprint=d6:...  (from OCI console for user's API Key or via openssl command)

            export TF_VAR_private_key_path=~/.oci/oci_api_key.pem

            export TF_VAR_region=us-phoenix-1


            Note: TF_VAR doc section is missing the region variable


            $ source ~/.bashrc


            D. Download vcn.tf sample into .vcn sub dir and execute steps from there as indicated


            Observe 'vcn1' get created / terminated






            Note: This is my cheat sheet in .bashrc



            export PATH=$PATH:/Users/<userid>/terraform


            # this could go into .bash_profile but on the mac .bashrc gets executed always

            export TF_VAR_tenancy_ocid=ocid1.tenancy.oc1...

            export TF_VAR_user_ocid=ocid1.user.oc1..

            export TF_VAR_compartment_ocid=ocid1.compartment.oc1..

            export TF_VAR_fingerprint=d6:32:c...

            export TF_VAR_private_key_path=~/.oci/oci_api_key.pem

            export TF_VAR_region=us-phoenix-1



            # TF Setup for OCI:

            # 1. Getting started with Terraform: https://www.terraform.io/intro/getting-started/install.html


            # 2. OCI Provider: https://github.com/oracle/terraform-provider-oci


            # --- gunzip darwin_amd64 .gz file, and move to  ~/.terraform.d/plugins/darwin_amd64/.   Directory should have as per below:

            #ex: ls ~/.terraform.d/plugins/darwin_amd64/



            # 3. Getting Required Keys: https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm

            # --- this is what I did to add public key to my OCI user (this is the API key TF will use to make OCI calls...this is what TF_VAR_private_key_path points to))

            #   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

            #   cat ~/.oci/oci_api_key_public.pem | pbcopy

            # --- added public key to OCI user

            # --- to get fingerprint (also shows up in OCI console): openssl rsa -pubout -outform DER -in ~/.oci/oci_api_key.pem | openssl md5 -c


            # to generate SSH key for spinning up OCI compute instance. Note: do not use '-' in the name of the key, OCI console will rejct with "Not Authenticated"

            # ssh-keygen -t rsa -N “” -b 2048 -C “mykey” -f mykey-oci-sshkey