Getting Error while creating web server for POC through Terrafrom

  • Hello Team ,

I am getting error while creating two web servers through Terraform in Oracle Cloud . Please see below error and help us asap .

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.toronto: Refreshing state…

Error: Invalid index

on line 119, in resource “oci_core_subnet” “subnet2”:
119: availability_domain = data.oci_identity_availability_domains.toronto.availability_domains[1][“name”]
| data.oci_identity_availability_domains.toronto.availability_domains is list of object with 1 element

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


This ticket includes a secure attachment. Use this link to access the attached files:

Hi @Ayush28gokhru,

Unfortunately the “support uploads” service you used here is for sending files to Terraform Enterprise customer support and isn’t something that contributors to this forum have access to. If you’d like to share the information in there, you’ll need to include it in a forum message directly. (Alternatively, if you are a Terraform Enterprise customer you could send this question to the customer support team.)

Without seeing your full configuration it’s hard to understand fully what is going on here, but I can at least explain the meaning of this error message:

Terraform is reporting that data.oci_identity_availability_domains.toronto.availability_domains is a list with only one element, and therefore the only valid index for that list would be [0] to select the first element; lists in Terraform are zero-indexed.

So it seems that there are fewer availability domains in the selected compartment than you expected.