01/24/2023, 10:38 AM
Hey all! I’m trying to run an inline program on AWS Lambda. The only writeable area of the filesystem is
, so I’ve set my work dir and pulumi home there.
stack = pulumi.automation.create_stack(
            program=get_bucket, # simple program that just gets the ARN of a named AWS S3 Bucket
            opts=pulumi.automation.LocalWorkspaceOptions(work_dir="/tmp/", pulumi_home="/tmp/.pulumi"))
This works fine locally and I see the yaml etc generated in my local /tmp. When I run this on Lambda though, I get
FileNotFoundError: [Errno 2] No such file or directory: 'pulumi'
This is strange to me - why is it looking for a directory named
in the first place, when my workspace config is different? I’d love any pointers on this.
I’ve narrowed it down a bit - the failure is happening when pulumi tries to create a LocalWorkspace:
2023-01-24T12:34:51 File "/var/task/", line 2589, in test_pulumi
2023-01-24T12:34:51 return CadenceUnsubscribeService(self).sense_check()
2023-01-24T12:34:51 File "/var/task/", line 112, in sense_check
2023-01-24T12:34:51 ws = pulumi.automation.LocalWorkspace(work_dir="/tmp/", pulumi_home="/tmp/.pulumi")
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/site-packages/pulumi/automation/", line 125, in __init__
2023-01-24T12:34:51 pulumi_version = self._get_pulumi_version()
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/site-packages/pulumi/automation/", line 411, in _get_pulumi_version
2023-01-24T12:34:51 result = self._run_pulumi_cmd_sync(["version"])
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/site-packages/pulumi/automation/", line 430, in _run_pulumi_cmd_sync
2023-01-24T12:34:51 return _run_pulumi_cmd(args, self.work_dir, envs, on_output)
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/site-packages/pulumi/automation/", line 55, in _run_pulumi_cmd
2023-01-24T12:34:51 with subprocess.Popen(
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/site-packages/sentry_sdk/integrations/", line 193, in sentry_patched_popen_init
2023-01-24T12:34:51 rv = old_popen_init(self, *a, **kw)  # type: ignore
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/", line 951, in __init__
2023-01-24T12:34:51 self._execute_child(args, executable, preexec_fn, close_fds,
2023-01-24T12:34:51 File "/var/lang/lib/python3.9/", line 1821, in _execute_child
2023-01-24T12:34:51 raise child_exception_type(errno_num, err_msg, err_filename)
Looks like the attempt to run
pulumi version
is failing. Must be something wrong in my setup?
🙂 looks like I’m missing the crucial step of installing pulumi CLI, in addition to installing the python lib


01/24/2023, 3:32 PM
@fierce-rose-25366 yes, automation API requires the pulumi CLI but that includes the Pulumi engine. you can run Pulumi inside a lambda if you use the docker image support


01/24/2023, 3:43 PM
Thanks @billowy-army-68599! Yeah I’m using Docker on Lambda - I managed to get a step further by installing pulumi CLI in the docker image, but I’m now facing permission issues - looks like the lambda user isn’t able to invoke the docker CLI. Here are my various attempts at fixing this so far in my dockerfile:
# install pulumi
RUN curl -fsSL <> | sh

# add pulumi to path
ENV PATH="${PATH}:/root/.pulumi/bin"

# test that pulumi can run
RUN pulumi version

# make the lambda user able to execute it - NOT WORKING SO FAR
RUN chmod a+rx /root/.pulumi/bin/pulumi

RUN chmod -R a+wrx /root/.pulumi

RUN chown -R sbx_user1051 /root/.pulumi/bin/pulumi

RUN chown -R sbx_user1051 /root/.pulumi
I recognise this is mostly a lambda/docker question now rather than a pulumi one, but it’d be super helpful if you have any pointers from past experience of doing this.


01/24/2023, 3:45 PM
it’s been a really long time since I did this i’m afraid 😞 I’d recommend installing into
’s home directory


01/25/2023, 2:10 PM
No worries, thanks for the pointers @billowy-army-68599 !