https://pulumi.com logo
Title
t

thousands-engineer-52020

11/16/2022, 10:29 AM
Another question, I'm trying to run Automation API on an AWS Lambda, it works well on a custom container image locally, but when I try to run it on AWS directly, the function
create_or_select_stack()
seems to crash but I don't have any error. I know it because log just after this function is not printed. Is there a way to print pulumi debug log on python ?
b

brave-planet-10645

11/16/2022, 10:32 AM
Where are you running Pulumi from in the container file system. I think it needs to be from
/tmp
because that’s the only writable location, plus it’s not available until after the lambda container has started so you’ll need to copy the pulumi binaries there (and make sure the correct env vars are pointing there too)
It’s great that you’re trying this, but in my experience Pulumi can take a while to run (especially if you’re doing stuff with databases or clusters etc) so could start to be expensive. My advice would be to run this in fargate or similar (if you’re trying to go down the serverless option) and maybe kick off the task from a lambda (if you’re trying to trigger it with events)
t

thousands-engineer-52020

11/16/2022, 10:34 AM
I'm running it from
${LAMBDA_TASK_ROOT}
specified on Dockerfile, which is the official AWS dockerfile
Just in case :
FROM public.ecr.aws/lambda/python:3.8

# Install the function's dependencies using file requirements.txt
# from your project folder.
RUN yum install -y tar gzip && \
    yum clean all

COPY requirements.txt pulumi-v3.44.2-linux-x64.tar ./
RUN  pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
RUN  tar -xvf ./pulumi-v3.44.2-linux-x64.tar --strip-components=1 -C /usr/local/bin
     

# Copy function code
COPY lambda_function.py ${LAMBDA_TASK_ROOT}

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "lambda_function.lambda_handler" ]
b

brave-planet-10645

11/16/2022, 10:36 AM
Your Pulumi program can run from the
${LAMBDA_TASK_ROOT}
but you’ll still need the Pulumi CLI in there
t

thousands-engineer-52020

11/16/2022, 10:40 AM
Pulumi CLI is on my $PATH, but I'll try to run it from /tmp
b

brave-planet-10645

11/16/2022, 10:40 AM
Also your
$PULUMI_HOME
needs to be there as well (as we explicitly write to that folder)
t

thousands-engineer-52020

11/16/2022, 2:52 PM
I've tested to set
PULUMI_HOME
to
/tmp
, but still aws lambda failed without explicit error (I've check and pulumi files are well created in /tmp). Is there a way to activate debug mode (like
logger.setLevel(logging.DEBUG)
)