how do i run stack programatically without using `...
# general
how do i run stack programatically without using
pulumi up
welcome to the wonderful world of Pulumi Automation ! also check out #automation-api channel
Caveat: you still need to have the CLI available as automation api is a wrapper around the CLI
@brave-planet-10645 thank you 😉
🙂 Having said that, it is an extremely powerful way of building Pulumi into your application and something I definitely recommend if you're looking at building a PAAS or similar
Use case using the Automation API: integration of Pulumi with Concourse CI:
@brave-planet-10645 I might have missed your reply when I asked the following a week or two ago. Is it possible to link all Pulumi libraries into an automation program to avoid the dependency on a prior CLI install? I wish to run a C# Pulumi automation program in a transient host environment such as an Azure function app or Kubernetes container.
the pulumi automation actually calls out to the CLI so it is required. (in dotnet it boils down to a
etc) i do not know much about azure functions, but i know in aws lambda functions you can run a full docker container, or even in a regular dotnet function people have had some success cramming various libs in particular tmp folders but it seems a bit hacky for k8s though you can build a docker container with the cli installed easily enough. we use the c# pulumi automation api, so our base image is the dotnet container. our dockerfile looks something like this
Copy code
FROM <|> AS build
# fetch pulumi tarball during build stage, while curl is available
ARG pulumi_version
ARG pulumi_checksum
RUN curl <${pulumi_version}-linux-x64.tar.gz> > /tmp/pulumi.tar.gz \
    && echo "$pulumi_checksum /tmp/pulumi.tar.gz" | sha256sum --check

FROM <|>
# install pulumi: extract to /usr/share and symlink to /usr/bin (mimicking dotnet)
COPY --from=build /tmp/pulumi.tar.gz /tmp/pulumi.tar.gz
RUN tar -xvzf /tmp/pulumi.tar.gz -C /usr/share \
    && rm /tmp/pulumi.tar.gz \
    && ln -s /usr/share/pulumi/pulumi /usr/bin \
    && pulumi version

COPY . .
ENTRYPOINT ["dotnet", "my.service.dll"]
and you provide the pulumi version and its checksum during your
docker build
🙌 1
I've got it running in a lambda container (which a little bit of wrangling) so if an azure function can run a container then in theory you can do it
@bumpy-grass-54508 the reason for the use of the
folders is that this is the only writeable folder. Everything else is readonly
ah right, and i shouldn't have said hacky - wrangling is a better word. i haven't tried pulumi in lambda specifically but seen similar attempts with other cli tools like running git in a lambda function etc. it is usually possible but not as straight forward as just installing through a package manager
hacky is fine. It does describe it well