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

purple-market-1813

12/12/2022, 10:04 PM
looking to run a python file in an ecs task that has pulumi on the requirements.txt?
s

stocky-restaurant-98004

12/13/2022, 2:05 AM
I'm not sure what your question is.
p

purple-market-1813

12/13/2022, 2:09 PM
I'm trying to run an ecs task that provisions infrastructure
Hey @stocky-restaurant-98004 thank you for replying!
the ecs task (fargate) would run an index.py that imports pulumi and pulumi_aws
s

stocky-restaurant-98004

12/13/2022, 2:09 PM
Ahh, I see.
Why'd you choose Fargate for that use case?
(As opposed to a CodeBuild pipeline or something?)
p

purple-market-1813

12/13/2022, 2:11 PM
@stocky-restaurant-98004 its part of a step function and it is provisioning cloudfront resources that could take longer than 15 mins (otherwise I'd use a docker based lambda instead of fargate)
I was unsuccessful when creating a dockerfile for the fargate task while trying to install the python libs with a reqs.txt file
was wondering if there was something I might be missing
s

stocky-restaurant-98004

12/13/2022, 2:13 PM
Ahh. You'll probably want to package your deps in the image itself.
Start with the image for your language (the
pulumi/pulumi
image is huge and not where I'd start): https://github.com/pulumi/pulumi-docker-containers
p

purple-market-1813

12/13/2022, 2:15 PM
@stocky-restaurant-98004 what if I wanted to run a python env that did more than using the pulumi cli?
or would it still be possible to run (for example:
python index.py
in the env of an image based off of
pulumi/pulumi-python?
s

stocky-restaurant-98004

12/13/2022, 2:19 PM
Are you familiar with the Automation API? I think that's what you probably want: https://www.pulumi.com/docs/guides/automation-api/ Basically, it flips the dependency on the Pulumi CLI: You can run
python index.py
and in
index.py
, you can run Pulumi commands programmatically.
(as opposed to
pulumi up
, which then will find and run
__main__.py
as a Pulumi program)
p

purple-market-1813

12/13/2022, 2:20 PM
correct, I would like to run a python file that imports pulumi, pulumi_aws, and utilizes create_pulumi_program
I'll try that out, thank you so much @stocky-restaurant-98004
@stocky-restaurant-98004 would this be possible w/o setting a pulumi_access_token?
so far I only set the PULUMI_CONFIG_PASSPHRASE when running
Copy code
create_pulumi_program
https://www.pulumi.com/blog/automation-api-python/
s

stocky-restaurant-98004

12/13/2022, 5:10 PM
I think a token is more appropriate. I'm not sure whether it's possible without setting a token.
p

purple-market-1813

12/13/2022, 11:12 PM
what if I use an s3 backend and don't have a token? I am still running into the same error on the fargate task about
PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions