Hi guys, I want to create multiple GCE VMs using P...
# python
h
Hi guys, I want to create multiple GCE VMs using Pulumi. I can run the for loop to create multiple VMs but how do i export all the created VM's information. so basically "how do i export multiple VM's information after they are created ?" At the moment, pulumi is showing the information for last VM.
w
You can create an array, and then inside the loop add an item to the array for each VM. Then you can export that array. I recently did a workshop that covered this exact thing (well, in AWS :-)) - see: • labs: https://github.com/pulumi/infrastructure-as-code-workshop/tree/master/labs/aws/python/lab-02 • video:

https://youtu.be/emv0iMwCkkg

(this particular part at ~1:02)
h
cool. Thanks for that
One more thing, i was testing gcp-py-network-componet code available on github repo and i am getting the following error
error: Configuration 'gcp-py-network-component:subnet_cidr_blocks' value '192.168.0.0' is not a valid 'JSON object'
i do have config value set
KEY                 VALUE
subnet_cidr_blocks 192.168.0.0
Do you know, what am i missing ?
f
h
@faint-table-42725 thanks mate but i am still not able figure out. Can you please give some example value ?
So something like
pulumi config set subnet_cidr_blocks[0] 192.168.0.0
and it should be a range, so i’m guessing you’ll want that to be more like 192.168.0.0/16
h
pulumi config set gcp-py-network-component:subnet_cidr_blocks[0] 192.168.0.0/16
pulumi up is giving up this error now
`error: Missing required configuration variable 'gcp-py-network-component:subnet_cidr_blocks'`please set a value using the command
pulumi config set gcp-py-network-component:subnet_cidr_blocks <value>
f
you’ll need --path like in the doc
👍 1
you can also just edit the .yaml yourself if that’s easier
at the end of the day, it just needs to be yaml sequence
h
ah… --path did the trick
thank you so much for the help
this command worked fine
pulumi config set --path gcp-py-network-component:subnet_cidr_blocks[0] 192.168.0.0/16