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
future-hairdresser-70637
07/22/2024, 3:28 PM
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
bland-house-72269
07/22/2024, 6:19 PM
yes, stop instance, an then start it.
bland-house-72269
07/22/2024, 6:19 PM
ok, that makes sense thanks for the response.
high five 1
bland-house-72269
07/22/2024, 6:21 PM
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
future-hairdresser-70637
07/22/2024, 6:44 PM
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.
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.