简体   繁体   English

在 AWS 上的 docker 容器要求中运行 python boto3

[英]Running python boto3 inside a docker container requirements on AWS

So, I'm using boto3 s3 with a python script just to list the bucket.因此,我使用带有 python 脚本的 boto3 s3 来列出存储桶。

s3_client = boto3.client('s3') s3_client = boto3.client('s3')

It works fine when I run it on my desktop because I setup the aws_access_key_id and aws_secret_access_key with my aws configure command.当我在桌面上运行它时它工作正常,因为我使用我的 aws configure 命令设置了 aws_access_key_id 和 aws_secret_access_key。

When I run it on AWS as a container, am I going to need to run my container with environmental variables for the aws_access_key_id and aws_secret_access_key when I use boto3 or if I have my setup for my container user having access to s3, will that work and I don't need to use the keys?当我在 AWS 上将它作为容器运行时,我是否需要在使用 boto3 时使用环境变量为 aws_access_key_id 和 aws_secret_access_key 运行容器?我不需要使用密钥?

would I still need to setup the aws key and secret key in boto3 or will it work off the permissions I give to my task execute user我是否仍需要在 boto3 中设置 aws 密钥和密钥,或者它是否会取消我授予任务执行用户的权限

You don't have to hard code anything.你不必硬编码任何东西。 Instead you provide the permissions using IAM Roles for Tasks .相反,您使用IAM Roles for Tasks提供权限。 So S3 permissions are granted through this role.所以 S3 权限是通过这个角色授予的。 Boto3 will automatically inherit the permissions. Boto3 将自动继承权限。

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

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