Hi,
I have trouble creating instances in Terraform with json variables, need to add multiple disks using JSON format, but I am unable to get the proper syntax to add a loop in the list of list in json variables.
variable:
instance_data": [
{
“SERVICEID”: 123,
“TENANCY”: “dbdevtest”,
“REGION”: “phx”,
“INSTANCENAME”: “test-stage-01”,
“IMAGEID”: “ocid1.image.oc1.phx.aaaaaaaata336uboudlw4uhz5drg7rjejnownyyg2sdyyoolk677fjm3oiuq”,
“OCPU”: 2,
“MEMORY”: 32,
“BOOTVOLUMESIZE”: 88,
“SHAPE”: “VM.Standard.E3.Flex”,
“OWNER”: “rajinil”,
“SUBNETID”: “ocid1.subnet.oc1.phx.aaaaaaaazqxpkf3dhapuh7wlbp4hnxele2xgk7mb3z3zwia4upyepkkx”,
“REQUESTEDBY”: "rajini,
“COMPARTMENTID”: “ocid1.compartment.oc1…aaaaaaaasubrys3qzccuxdbbbos32q6lmoblvouoakgv5tqvo3h4w5p”,
“NSGID”: “NSGID”,
“COMPUTEDEPLOYMENTID”: 8,
“LASTUPDATEDATE”: null,
“BLOCKVOLUMESIZE”:[{ “50” , “50” }],
“BLOCKVOLUMENAME”: “test-stage-01”,
“BLOCKVOLUMEATTACHMENTTYPE”: “iscsi”
}
terraform volume code:
resource “oci_core_volume” “test_volume” {
for_each = { for i in local.instances.instance_data : i.INSTANCENAME => i }
# for_each = { for i in local.blockvolume : i.COMPUTEDEPLOYMENTID => i }
compartment_id = each.value.COMPARTMENTID
availability_domain = lookup(local.AD, each.value.DEPLOYMENTAD)
display_name = each.value.BLOCKVOLUMENAME
size_in_gbs = each.value.BLOCKVOLUMESIZE
}
Blockvolume I need to add two disks for one instance. unable to do so.
i can able to add one block volume, need to add two vloume I need loop through the list of lists in json.
Could you please help me with how to loop through the block volume