简体   繁体   English

如何运行AWS S3存储桶中的python脚本和文件

[英]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. 我有带输入参数-c input.txt -s 5 -o out.txt的python脚本pscript.py。 The files are all located in an aws s3 bucket. 文件全部位于aws s3存储桶中。 How do I run it after creating an instance? 创建实例后如何运行它? Do I have to mount the bucket on EC2 instance and execute the code? 我是否必须将存储桶安装到EC2实例上并执行代码? or use lambda? 或使用lambda? I am not sure. 我不确定。 Reading so many aws documentations kinda confusing. 阅读这么多的AWS文档有点令人困惑。

Command line run is as follows: 命令行运行如下:

python pscript.py -c input.txt -s 5 -o out.txt

You should copy the file from Amazon S3 to the EC2 instance: 您应该将文件从Amazon S3复制到EC2实例:

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. 请注意,要访问Amazon S3中的对象,您需要将IAM角色分配给EC2实例。 The role needs sufficient permission to access the bucket/object. 该角色需要足够的权限才能访问存储桶/对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM