https://pulumi.com logo
Title
h

hundreds-yacht-71603

01/03/2023, 4:16 PM
Hey there, is there a way to use pulumi purely as a library? No
pulumi [up|...]
, purely from withing existing code.
e

echoing-dinner-19531

01/03/2023, 4:25 PM
h

hundreds-yacht-71603

01/04/2023, 10:01 AM
Nice! That's a good starting point. Thank you!
Not directed "you", I see it as a general pattern: I find it interesting that "_ as Code" seems to always require a local tool rather than only a library. cdk, pulumi, ... all require the commands to be present. Is there a specific reason everyone chooses this? Why would it be "worse" to just expect someone to instantiate a sort of config (or provide options) and just run the code... •
go run main.go [my-personal-flags]
e

echoing-dinner-19531

01/04/2023, 12:08 PM
In my experience (having built a couple of tools like this) it's a few reasons: 1. Handling argument parsing correctly rather than trusting the user will pass argv down to the tool. Even more fun if you expect the run api to be well typed and not just take a string[]. 2. Having a consistent "start point". Everything you do with pulumi is started from the pulumi command, rather than like stack configuration being done via
pulumi
but running your actual program being done via
go run
3. Ensuring that the right pulumi binary is used. Even if we supported something like
go run
it would somewhere internally have to shell out to the
pulumi
binary, we can't write an actual native library for all of pulumi in every language. I think the main point is two. Just having that consistent start point for everything. We do have an issue around supporting this "just go run" it approach https://github.com/pulumi/pulumi/issues/5538 but it hasn't had a lot of traction.