Julio
Julio

Reputation: 551

How deploy several VCN on different compartments inside Oracle Cloud?

i have a big problem and i would like to know if there is someone here that can help me.

I create a small github project to show you the steps done, but at the end without positive results.

I need to create dynamic VCN on different compartments, using a json input file. The steps done was:

  1. On the xxxxxxxx_v1.tfvars.json you can see the next. If I send the OCID of the compartment where i would like to set the new VCN's --> it works. But wht happens if instead using OCID i just know the name of the comparment instead OCID of the compartments?
  2. For that reason I create xxxxxxxx_v2.tfvars.json where I'm sending the name of the compartments where i would like to deploy VCN. And also on the modeule folder there is a new version folder for network module. Where i use "data" to get compartment ID for each Compartment that comes on the json file, filtering per each compartment name.

But i have some error:

enter image description here

So about my question: how can I deploy VCN's on different compartment filtering by compartment_name dynamically.

So I upload my code on this public repo : https://github.com/juliovg/multiples_vcns.git

If some can help me with this and also how can i OUTPUT the list of compartments ID's.

Upvotes: 0

Views: 265

Answers (1)

ssolbach
ssolbach

Reputation: 96

Not sure, but I think the line

compartment_id = data.oci_identity_compartments.compartment_id.0.id

should be:

compartment_id = data.oci_identity_compartments.compartment_id[0].id

And maybe, you should work with a lookup...

compartment_id = lookup(data.oci_identity_compartments.compartment_id[0], "id")

Upvotes: 1

Related Questions