简体   繁体   中英

How to assume AWS role in docker container run on Elasticbeanstalk environment?

I use elasticbeanstalk with multicontainer version and I have docker container with boto3 inside. I would like to assume role to save files on S3 using python.

Based on this question: Fetching AWS instance metadata from within Docker container?

urlopen('http://169.254.169.254/latest/meta-data/iam/instance-id-credentials/s3access').read().decode('utf-8')

returns 404.

I don't want use hardcoded credentials in my docker image. Is there a way to somehow assume role?

I made this work by starting the container in --net host mode. Ie use the host's networking stack to make AWS think that you are requesting from the EC2 host.

This was the comment that provided this solution: Fetching AWS instance metadata from within Docker container?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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