I have a usecase where I want to create a gcp disk...
# python
h
I have a usecase where I want to create a gcp disk, with some data in it which should be populated 1 time. How can I build some logic around creating a vm (and attaching the disk so that I can populate the disk) only ie when I next run pulumi up it should know the disk already exists, and it wont create a new vm. One a disk has been writte to once, I dont want to touch it again in pulumi.
d
Pulumi tracks what it's created in state, so it should only create the disk once by default
h
yeah but it will also create a vm / want the vm running each time too, that's my question. My question is how do I check if a pulumi component already is in the stack, for example?
d
Is the vm temporary, for provisioning the disk only?
h
Yes, it needs to write data once which will the be read/used elsewhere -- and I dont want to overwite that later on. I'll create new disks if I need fresh data
It's a couple of Gi of data for training models which will be loaded as RO in k8s
d
It's not really a model that pulumi supports, it expects any resources defined to be part of the end state. You could look into dynamic providers so that provisioning is part of the disk creation, or use the Commands provider to do gcloud cli commands for creation/deletion of the vm
But there isn't a way to detect whether a resource is already created from your python code