Do I somehow need to initialize pulumi before pulu...
# general
f
Do I somehow need to initialize pulumi before pulumi.run will work?
w
Not sure what you mean by
pulumi.run
To execute a Pulumi program, you use
pulumi up
where
pulumi
is the Pulumi CLI. So, confirming a few things: • you have the Pulumi CLI installed as per: https://www.pulumi.com/docs/get-started/install/ • You have a pulumi program written in go - something along the lines of the go example here: https://www.pulumi.com/registry/packages/equinix-metal/ • You have your Pulumi project/stack set up with the necessary Equinix credentials as per: https://www.pulumi.com/registry/packages/equinix-metal/installation-configuration/ • You’ve initialized the stack as per https://www.pulumi.com/docs/intro/concepts/stack/ If so, what output do you get from
pulumi up
?
f
I was running my script directly, as pulumi.run() is part of a larger function that's called by a http request, is that possible with pulumi up?
er, I run pulumi,run inside of another function, to be more specific
The entire point is to be able to spin up servers on-demand
w
There is the automation API package that essentially wraps the Pulumi CLI in an SDK: https://www.pulumi.com/docs/guides/automation-api/ So you could use that to manage Pulumi stacks (and the resources within).
f
I also see that I never actually got
pulumi new
to run, as it kept asking me to run it in an empty directory
but I already wrote my code, do I need to re-make my entire project structure?
and how can I tell it to not use a template
w
Don’t do a
pulumi new
at this point. You would do a
pulumi stack init
as per the link provided above.
I know this is in Python, but it may help to get a sense of the overall flow: https://github.com/pulumi/examples/tree/master/equinix-metal-py-webserver
f
Oh, I ran pulumi stack init and it errored but I guess it did actually work?
Copy code
┌──(gido5731㉿gtux0)-[~/AutoDeployVM/masterapi]
└─$ pulumi stack init masterapi                                                                                                                                                          255 ⨯
Created stack 'masterapi'
error: no Pulumi project found in the current working directory. Move to a directory with a Pulumi project or try creating a project first with `pulumi new`.
                                                                                                                                                                                               
┌──(gido5731㉿gtux0)-[~/AutoDeployVM/masterapi]
└─$ pulumi stack init                                                                                                                                                                    255 ⨯
stack name: (dev) masterapi
error: stack 'masterapi' already exists
and it still didn't make the pulumi.yaml that it wants
w
So, although you have some code, you do need to add some files so Pulumi knows how to run it. I would recommend going through one of the getting started sequences here: https://www.pulumi.com/docs/get-started/ to understand the overall flow and main concepts.
f
I didn't originally plan to make this project with Pulumi, but no one seems to have any way to take my project that I already wrote and tell pulumi to make the files it needs around it
w
Well, if it’s written using Pulumi SDKs (https://www.pulumi.com/registry/) and is in a directory with a
Pulumi.yaml
(project file) and (possibly) a
Pulumi.XXX.yaml
(stack file for stack named XXX) then
pulumi up
should work.
There are some go examples here (not Equinix specifically) but should provide some context. https://github.com/pulumi/examples
f
No pulumi commands want to create a yaml file, they all want either an empty folder or to use a template I don't want. Can I make a yaml manually?
I've read through many of the examples and they either want me to use pulumis cloud thing or gloss over the details
w
Yes. Look at some of the “go” examples in that link I just provided and emulate what you see there.
Sorry, my internet dropped out there for a few minutes.
f
No problem, I'll try feeding it a pulumi.yaml and see if it cooperates
w
The Pulumi SaaS is free for individuals. Or you can use a self-managed backend to store state as per: https://www.pulumi.com/docs/intro/concepts/state/
You do need to
pulumi login
to something though whether it’s the SaaS or an S3 bucket of file since Pulumi needs that for state management.
f
Right now I have it configured to be logged in to a local backend, as I don't really want any cloud nonsense from some randos service. If I can run my own servers I can run my own authentication
w
Understood. I just wanted to make sure you knew you did have to
pulumi login
to something.
f
Yes, I definitely am not a fan of the number of steps required to provide an auth token
Ok now it's giving actual errors (I forgot to give it a BillingCycle) so I'll see how this works out, thanks for that
w
Good luck!