terraform-provider-oci: oci_identity_availability_domains returning ADs out of expected order

Terraform Version

Terraform v0.10.7

OCI Provider Version

terraform-provider-oci 2.0.2

Description:

oci_identity_availability_domains is seemingly returning ADs out of expected order. Looking through the docs, I don’t see that there is any contract that oci_identity_availability_domains return ADs in a specific order, but based on example code, people seem to be interpreting it that way. And as far as I remember, it used to work as expected.

In the example below, the returned list is:

data.oci_identity_availability_domains.ADs.availability_domains[0] ==> PHX-AD-2 data.oci_identity_availability_domains.ADs.availability_domains[1] ==> PHX-AD-1 data.oci_identity_availability_domains.ADs.availability_domains[2] ==> PHX-AD-3

Seems to apply to Ashburn as well.

Terraform File

provider "oci" {
  tenancy_ocid         = "${var.tenancy_ocid}"
  user_ocid            = "${var.user_ocid}"
  fingerprint          = "${var.fingerprint}"
  private_key_path     = "${var.private_key_path}"
  region               = "${var.region}"
}

variable "tenancy_ocid" {}
variable "user_ocid" {}
variable "fingerprint" {}
variable "private_key_path" {}

variable "region" {
  default = "us-phoenix-1"
}

data "oci_identity_availability_domains" "ADs" {
  compartment_id = "${var.tenancy_ocid}"
}

resource "null_resource" "echo-ad1" {
  provisioner "local-exec" {
    command = <<LOCAL_EXEC
echo ${lookup(data.oci_identity_availability_domains.ADs.availability_domains[0],"name")}
LOCAL_EXEC
  }
}

resource "null_resource" "echo-ad2" {
  provisioner "local-exec" {
    command = <<LOCAL_EXEC
echo ${lookup(data.oci_identity_availability_domains.ADs.availability_domains[1],"name")}
LOCAL_EXEC
  }
}

resource "null_resource" "echo-ad3" {
  provisioner "local-exec" {
    command = <<LOCAL_EXEC
echo ${lookup(data.oci_identity_availability_domains.ADs.availability_domains[2],"name")}
LOCAL_EXEC
  }
}

Terraform Apply

data.oci_identity_availability_domains.ADs: Refreshing state...
null_resource.echo-ad1: Creating...
null_resource.echo-ad2: Creating...
null_resource.echo-ad3: Creating...
null_resource.echo-ad1: Provisioning with 'local-exec'...
null_resource.echo-ad2: Provisioning with 'local-exec'...
null_resource.echo-ad3: Provisioning with 'local-exec'...
null_resource.echo-ad3 (local-exec): Executing: ["/bin/sh" "-c" "echo hXgQ:PHX-AD-3\n"]
null_resource.echo-ad1 (local-exec): Executing: ["/bin/sh" "-c" "echo hXgQ:PHX-AD-2\n"]
null_resource.echo-ad2 (local-exec): Executing: ["/bin/sh" "-c" "echo hXgQ:PHX-AD-1\n"]
null_resource.echo-ad2 (local-exec): hXgQ:PHX-AD-1
null_resource.echo-ad2: Creation complete after 0s (ID: 7543711477911731136)
null_resource.echo-ad1 (local-exec): hXgQ:PHX-AD-2
null_resource.echo-ad1: Creation complete after 0s (ID: 3504201122002210711)
null_resource.echo-ad3 (local-exec): hXgQ:PHX-AD-3
null_resource.echo-ad3: Creation complete after 0s (ID: 3285746276885397138)

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 16 (9 by maintainers)

Most upvoted comments

As of this morning I have the same problem. Yesterday a terraform plan was fine with no changes. This morning ALL subnets want to be destroyed and therefore ALL instances.

Example: -/+ oci_core_subnet.Production-priv01-AD1 (new resource required) id: “ocid1.subnet.oc1.iad.aaaaaaaawhnbmajiaajejaztyfoy6sgg5llozcfxqmpcaodsbxltabclitsa” => <computed> (forces new resource) availability_domain: “BDQS:US-ASHBURN-AD-1” => “BDQS:US-ASHBURN-AD-2” (forces new resource)