Is there a way to get a stack export from the pulu...
# general
Is there a way to get a stack export from the pulumi backend over an api call? (vs using the cli)
Yes, we haven’t documented our REST API or published a Swagger spec. But you can use the stack export endpoint yourself by using
. For example:
Copy code
export PULUMI_ACCESS_TOKEN="pul-..."
# Fully-qualified stack name, with organization
# project, and stack name.
export STACK="pulumi/"
curl -H "Authorization: token ${PULUMI_ACCESS_TOKEN}" \
Cool! Thanks! cc @dazzling-memory-8548
That will return the checkpoint of the latest version of the stack. To get an earlier version (e.g. that deployment from two weeks ago) you can specify a specific “version” (from the Pulumi Service), using:
Copy code
… /api/stacks/${STACK}/export/{version}
👍 1
💯 1
Great stuff…stupid followup question: how can I do the same thing from the CLI? (i.e. access stack exports outside of a stack context). I’ve been scouring the docs and can’t find this
I usually do:
Copy code
pulumi stack export > my-stack.json
Ah, I was thinking in the context of running from a different directory: I have some local tests in a separate project that run against a db deployed from a stack, so it would be ideal to programmatically get the deployed endpoint and inject it to those
I could also reorganize my projects, but was just curious in general about CLI querying arbitrary stack exports
I don’t quite follow what you are saying, but you should be able to provide
parameters to
pulumi stack export
. So you can in theory export the checkpoint file of another stack you have access to, or perhaps in the context of running
from a different directory.
yes, that’s exactly what I was (unclearly) asking for, I’ll go play with it now. Thanks!
Oh one more q: is there a similar API endpoint just for stack outputs?
Unfortunately no, there isn’t a stack-output specific API endpoint. You’ll need to run the stack export and then search for the output properties of the “stack” resource (there should be exactly one resource with type
or similar). We’ll probably add something like that when we start documenting the v1.0 of our REST API, but for now that’s the way to get a stack’s outputs.