https://pulumi.com logo
#general
Title
# general
p

proud-easter-54321

07/15/2021, 11:42 AM
how do i run stack programatically without using
pulumi up
?
b

bumpy-grass-54508

07/15/2021, 12:30 PM
welcome to the wonderful world of Pulumi Automation ! also check out #automation-api channel
b

brave-planet-10645

07/15/2021, 1:06 PM
Caveat: you still need to have the CLI available as automation api is a wrapper around the CLI
p

proud-easter-54321

07/15/2021, 1:10 PM
@brave-planet-10645 thank you 😉
b

brave-planet-10645

07/15/2021, 1:11 PM
🙂 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

limited-rainbow-51650

07/15/2021, 1:12 PM
Use case using the Automation API: integration of Pulumi with Concourse CI: https://github.com/ringods/pulumi-resource
i

icy-football-94152

07/15/2021, 2:28 PM
@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

bumpy-grass-54508

07/15/2021, 2:42 PM
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

brave-planet-10645

07/15/2021, 2:43 PM
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

bumpy-grass-54508

07/15/2021, 2:46 PM
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

brave-planet-10645

07/15/2021, 3:02 PM
hacky is fine. It does describe it well
2 Views