Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a python script and files located in an aws s3 bucket

I have python script pscript.py which takes input parameters -c input.txt -s 5 -o out.txt. The files are all located in an aws s3 bucket. How do I run it after creating an instance? Do I have to mount the bucket on EC2 instance and execute the code? or use lambda? I am not sure. Reading so many aws documentations kinda confusing.

Command line run is as follows:

python pscript.py -c input.txt -s 5 -o out.txt
like image 283
Starter Avatar asked Jan 29 '26 07:01

Starter


1 Answers

You should copy the file from Amazon S3 to the EC2 instance:

aws s3 cp s3://my-bucket/pscript.py

You can then run your above command.

Please note that, to access the object in Amazon S3, you will need to assign an IAM Role to the EC2 instance. The role needs sufficient permission to access the bucket/object.

like image 87
John Rotenstein Avatar answered Jan 31 '26 22:01

John Rotenstein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!