Hey everyone, I have a question. We are trying to...
# getting-started
b
Hey everyone, I have a question. We are trying to stop an instance through pulumi, we used the Instance Gateway but its not working. The pulumi ai says that its not possible, and gives us examples with aws-sdk, to stop the instances. Is it possible to stop an aws instance through pulumi?
f
You mean stop as in "stop instance" and not "terminate instance"? No, you'd have to use something like the AWS CLI or SDK. Note if you're using Pulumi ESC you can use that to manage the credentials required to run e.g.
aws ec2 stop-instances
b
yes, stop instance, an then start it.
ok, that makes sense thanks for the response.
high five 1
Just for curiosity sake, so I understand the architecture of pulumi more, any particular reason its not supported? Is it just a missing feature, or is it by design?
f
Hm yeah, fair question. i'm not on the engineering team so I can only give my personal thoughts. I would say "by design". Pulumi tends to (perhaps always?) stay away from managing cloud resources "in flight" and deal with the declarative provisioning parts - that is, Pulumi manages your infrastructure's resource's state but not the internal state of each resource. A resource either exists (is "up") or doesn't (is "destroyed"/never existed). There's no in-between as it's assumed the end user would like to manage that (e.g. whether a provisioned resource is started or stopped). Depending on your scenario, Pulumi might be able to help you here a bit e.g. you could theoretically use
GetInstance
to get
State
and then act upon it, but I dunno if I'd personally advocate for that approach. There's probably more intuitive ways of accomplishing what you want to do e.g. only run an instance during EastUS work hours 9a-5p via instance schedule (which you could declare via Pulumi). Again, depends on your goals.