How to automate OCI with Terraform

This content is protected, please and enroll course to view this content!

8 thoughts on “How to collect TF_VAR environment variables for OCI Terraform Provider

  1. Hi Martin,

    I’m having a problem applying terraform plan command.

    This is the command output:

    $ terraform plan
    Refreshing Terraform state in-memory prior to plan…
    The refreshed state will be used to calculate this plan, but will not be
    persisted to local or remote state storage.

    data.oci_identity_availability_domains.ADs: Refreshing state…
    data.oci_core_images.OSImageLocal: Refreshing state…

    Error: Invalid index

    on datasources.tf line 14, in data “oci_core_vnic_attachments” “FoggyKitchenWebserver1_VNIC1_attach”:
    14: availability_domain = lookup(data.oci_identity_availability_domains.ADs.availability_domains[1], “name”)
    |—————-
    | data.oci_identity_availability_domains.ADs.availability_domains is list of object with 1 element

    The given key does not identify an element in this collection value.

    It seems like there is a problem with the list index number in the variable “availabilty_domain”. If I change de index value to cero the following happens:

    Error: Invalid index

    on webserver1.tf line 2, in resource “oci_core_instance” “FoggyKitchenWebserver1”:
    2: availability_domain = lookup(data.oci_identity_availability_domains.ADs.availability_domains[1], “name”)
    |—————-
    | data.oci_identity_availability_domains.ADs.availability_domains is list of object with 1 element

    The given key does not identify an element in this collection value.

    Error: Invalid index

    on webserver1.tf line 8, in resource “oci_core_instance” “FoggyKitchenWebserver1”:
    8: source_id = lookup(data.oci_core_images.OSImageLocal.images[0], “id”)
    |—————-
    | data.oci_core_images.OSImageLocal.images is empty list of object

    The given key does not identify an element in this collection value.

    —————————————–
    The terraform version I’m running is:

    $ terraform -version
    Terraform v0.12.16
    + provider.null v3.1.0
    + provider.oci v4.15.0

    —————————————–
    My environment variables setup is as follows:

    TF_VAR_compartment_ocid=ocid1.tenancy.oc1..aaaaaaaapsjmvyv22s4tf4fnucgeq2vonwlrk3zsbvnu55m4vfildbxb72dq
    TF_VAR_region=us-sanjose-1
    TF_VAR_private_key_oci=path to key
    TF_VAR_private_key_path=path to key
    TF_VAR_region1=us-ashburn-1
    TF_VAR_region2=us-phoenix-1
    TF_VAR_tenancy_ocid=ocid1.tenancy.oc1..aaaaaaaapsjmvyv22s4tf4fnucgeq2vonwlrk3zsbvnu55m4vfildbxb72dq
    TF_VAR_user_ocid=ocid1.user.oc1..aaaaaaaacmv26erdkcagbiyctniyecvvtbpuxiy56hanaksxiez7myedjikq
    TF_VAR_public_key_oci=path to key
    TF_VAR_fingerprint=c9:69:f5:6c:41:ad:af:69:f3:4d:71:96:29:e5:02:02

    Reply
    1. What lesson are you using? Looks like your region has only one availability domain. In case of instances maybe referenced image is not available. I need to know what exact lesson of the course you are testing…

      Reply
      1. Hi, thanks for your feedback. That could be the problem. I’m using San Jose (US) which has only one AD. I applied the terraform plan command on the Lesson 1 files. Thanks.

Leave a Reply

8 thoughts on “How to automate OCI with Terraform

  1. Didn’t see anything that course has a time limit to complete. Not possible to complete this course in that time wouldn’t have signed up if that was case

    1. This is LearnPress timer which will reach zero, but the course will be still available (lifetime access). I am working on disabling this feature which is misleading.

  2. Hello, I can not see the course, Its showing locked for me. Can you please suggest?

    Thanks
    Rashi

Comments are closed.