how do i run stack programatically without using `...
# general
p
how do i run stack programatically without using
pulumi up
?
b
welcome to the wonderful world of Pulumi Automation ! also check out #automation-api channel
b
Caveat: you still need to have the CLI available as automation api is a wrapper around the CLI
p
@brave-planet-10645 thank you 😉
b
🙂 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
l
Use case using the Automation API: integration of Pulumi with Concourse CI: https://github.com/ringods/pulumi-resource
i
@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.
b
the pulumi automation actually calls out to the CLI so it is required. (in dotnet it boils down to a
Process.Start
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 <http://mcr.microsoft.com/dotnet/sdk:5.0|mcr.microsoft.com/dotnet/sdk:5.0> AS build
# fetch pulumi tarball during build stage, while curl is available
ARG pulumi_version
ARG pulumi_checksum
RUN curl <https://get.pulumi.com/releases/sdk/pulumi-${pulumi_version}-linux-x64.tar.gz> > /tmp/pulumi.tar.gz \
    && echo "$pulumi_checksum /tmp/pulumi.tar.gz" | sha256sum --check

FROM <http://mcr.microsoft.com/dotnet/aspnet:5.0|mcr.microsoft.com/dotnet/aspnet:5.0>
# 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

WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "my.service.dll"]
and you provide the pulumi version and its checksum during your
docker build
step
🙌 1
b
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
/tmp
folders is that this is the only writeable folder. Everything else is readonly
b
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
b
hacky is fine. It does describe it well