you can just wrap the declaration in a normal Go `...
# golang
you can just wrap the declaration in a normal Go
condition - if the resource is declared, Pulumi will ensure it exists.. if it isn’t declared but the condition evaluated to false, then Pulumi will remove it if it already exists in the same way it would if you deleted the resource from your program normally
To make my question more specific, I've created 2 vms and both has specific time stamps. vm1: 100 vm2: 200 I want to delete only vm2 because the time stamp is more than 150. Is there any way to programatically do that ?
not the logical part, but select the vm, and deletion part
Can you explain more about the system you're trying to design and it's goals? I feel like there's a way to express this that takes advantage of the desired state nature of pulumi. How are the VMs created, why do you want to delete them?
Hi @lemon-agent-27707 I want to create a pulumi program, which creates vms with specific lifespan. Means a developer can create a VM for 5days. After 5th day Pulumi have to delete the vm. We'll run the pulumi program as a cron every night to check the lifespan.
Copy code
  azure:location: centralindia
  # Cassandra Cluster
  - count: 1
    data_disk_size: 50
    name: cassandra
    resource_group: pu_demo
    type: Standard_A8_v2
    user_name: deployer
    life_span: 5 # Lifespan in days, after this time, this machine will get autodelted
    image_id: cassandra # From which image the machine should be created from
      secure: XXXXXX
field in yaml will create a tag called
in machine, along with the
in epoch. every night, we'll run this pulumi program, which will check
today - creationTime > lifespan
then take a snapshot and delete the VM
@lemon-agent-27707 Any direction will be very helpful, as this will allow devs to create disposible vms. in a very cost effective manner
I think this would be a good use case for automation api. You would create a stack per VM, and then output the VM creation time as a stack output. Then the automation API lists all stacks, iterates through each one looking for stacks that have old timestamp outputs, and destroys them.
How will developers create the VMs? Will they run pulumi directly?
Or will it be through some sort of API or ticketing system
Nope. 1. They'll raise a PR after updating the in git, 2. will get approved and merged, 3. which in turn trigger a jenkins ci
What cloud do you use
@lemon-agent-27707 any pointers ? I think This can be a great value add for many out there, who want a ready made solution for throwaway infra, or quick infra for testing
I can prototype something to get you started.
🎉 1
woohooo... awesome. That'll be a huuuge help to get things started. Once this is done, We'll contribute back to pulumi example, as I told I searched a lot for a ready made solution.
I have an example for you, but let's continue the discussion in #automation-api