https://pulumi.com logo
#automation-api
Title
# automation-api
l

lemon-agent-27707

09/04/2020, 11:42 PM
@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

important-appointment-55126

09/05/2020, 1:21 AM
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

chilly-rainbow-79265

09/05/2020, 6:20 AM
WOW.. Thanks @lemon-agent-27707 Appreciate it! Lemme check the script out.
t

tall-librarian-49374

09/06/2020, 9:52 AM
c

chilly-rainbow-79265

09/07/2020, 4:57 AM
@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 ?