Ok so it’s me again… posted in <#C01PF3E1B8V|getti...
# pulumi-deployments
Ok so it’s me again… posted in #getting-started before not realizing this channel exists… I’m trying to get deployments to run with Poetry. I’d like to not specify
Copy code
  name: python
    virtualenv: venv
in my Pulumi.yaml because locally we use
poetry run pulumi up
and poetry uses the correct virtualenv automatically. Side note: we are using a custom docker image for deployments because we’re using python 3.10 so I built one:
Copy code
# based on <https://github.com/pulumi/pulumi-docker-containers/blob/main/docker/pulumi/Dockerfile>

FROM python:3.10-slim

RUN apt-get update -y && \
  apt-get install -y \

# Passing --build-arg PULUMI_VERSION=vX.Y.Z will use that version
# of the SDK. Otherwise, we use whatever <http://get.pulumi.com|get.pulumi.com> thinks is
# the latest

# Install the Pulumi SDK, including the CLI and language runtimes.
RUN curl -fsSL <https://get.pulumi.com/> | bash -s -- --version $PULUMI_VERSION

# Install Poetry
ENV POETRY_HOME=/usr/local
RUN curl -sSL <https://install.python-poetry.org> | python3 -

# Create wrappers such that pulumi commands always run with poetry
COPY ./create-poetry-wrappers.sh /usr/local/bin
RUN create-poetry-wrappers.sh

ENTRYPOINT ["/bin/bash", "-c"]
CMD [ "/bin/bash" ]
I thought that I could create some wrapper scripts to force
poetry run …
on pulumi, but it seems like the
is not ? somehow? using the pulumi located in the container’s $PATH?
<= where is this file coming from…? It’s not in my image. I’m installing to
and wrappers in
Just catching up with what's going on here...
should be installed along with the pulumi python SDK when you run
poetry install
for your project.
Hmm isn’t that installed by
curl -fsSL <https://get.pulumi.com/> | bash -s -- --version $PULUMI_VERSION
I believe that only installs the Pulumi CLI thinking taco - I'm not 100% on that though
okay you're right that is installed with the CLI
I install the CLI during my docker build….
so I’m wondering if the deploy executor re-installs it?
the deploy executor uses automation api and calls out to the pulumi on path.
Is there any way I can see the source for
curl -H "Authorization: token $PULUMI_ACCESS_TOKEN" "$PULUMI_SERVICE_URL/preview/deployments/executor" |gzip -d >/pulumi-deploy-executor && chmod +x /pulumi-deploy-executor
backing up, is the issue here the
ModuleNotFoundError: No module named pulumi
yeah, I’m trying to use poetry
poetry is finding my pyproject.toml and installing the correct packages
but then the operation fails:
okay yeah, i'm following now. so that's because the deployment executor is using automation api to run the program, and the program doesn't know about where the poetry env is. interesting.
I tried to write a wrapper:
Copy code

for file_path in ~/.pulumi/bin/*; do
  file_name=$(basename "$file_path")

  cat <<EOF > "$wrapper_path"
echo poetry run "$file_path" "\$@"

  chmod +x "$wrapper_path"
this basically creates a file in
that just does
poetry run
I made it do
echo poetry run
to confirm it was being called
but it’s not
I think maybe
poetry run
should wrap
since the deploy executor is what eventually calls out to pulumi
potentially… but the deployment executor gets downloaded into the container at runtime
I guess I could add a pre-run command to overwrite it
yah - i appreciate all the effort you're putting into this and definitely want this to be a better experience for you! i'm following up internally to see what else I can find
❤️ thank you so much for all your help @red-match-15116!!
getting closer! gotta run for now, but will try later
With the virtual environments, within the project folder, you can drop the
poetry run ...
way of doing things.
ahh interesting, thank you, @limited-rainbow-51650!
I don’t love treating each Pulumi project as a separate virtualenv… but it makes sense
I’ll talk to my team to see how they feel about it
I was able to get things to run with our set up (not using virtual envs) by wrapping the executor in a
poetry run…
I may go this route for now as I don’t want to change the way our team is running pulumi and poetry locally
but thank you again!