looking to run a python file in an ecs task that h...
# aws
p
looking to run a python file in an ecs task that has pulumi on the requirements.txt?
s
I'm not sure what your question is.
p
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
Ahh, I see.
Why'd you choose Fargate for that use case?
(As opposed to a CodeBuild pipeline or something?)
p
@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
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
@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
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
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
I think a token is more appropriate. I'm not sure whether it's possible without setting a token.
p
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