<@U019FRV06KT> <@U012H5R25PX> I put together an ex...
# automation-api
l
@chilly-rainbow-79265 @important-appointment-55126 I put together an example of Automation API for provisioning temporary VMs. You'll probably have to make some adjustments to parameterize the VMs to your specifications but I think this should be a good starting point. It's a higher level CLI called
vmgr
that has two functions: •
vmgr add
creates a new VM (webserver in this instance) and prints out the public IP. Given that this is just plain Go code, you could extend it to email VM credentials to someone, put them in a queue somewhere, etc. •
vmgr cron <expiration>
ie `vmgr cron 5d`: runs a minutely job scanning for VMs older than the specified expiration. It will retry on failures, etc. You could run this on your laptop, or on a VM/container somewhere https://github.com/EvanBoyle/automation-api-examples/tree/main/vm_manager_azure
@tall-librarian-49374 built something similar using https://temporal.io/ which may be another option
i
nice; will definitely have to take a closer look at this! I currently have a stack for dev vms and redeploy the stack whenever we want to add/delete one (though dev can hibernate one anytime) .. nice thing is the code documents the machines, but this would be good for more ad-hoc environments
c
WOW.. Thanks @lemon-agent-27707 Appreciate it! Lemme check the script out.
t
c
@lemon-agent-27707 Thanks for the code. It gave me the power which pulumi has on automation, especially with the auto api. But I've to keep the state as it is.. means I've to commit that in to the version control. I've to keep the stack file, as
Pulumi.dev.yaml
for keeping the infra state. In your code, stack is something very disposible. But may I know is it possible, to 1. If I'm creating vms(5 vm) in the loop, and has seperate expiry times. 2. Is it possible to delete specific one ( expired one ) in the loop ?