bolec_kolec
bolec_kolec

Reputation: 510

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?

Upvotes: 1

Views: 1666

Answers (1)

Phil Winder
Phil Winder

Reputation: 116

I made this work by starting the container in --net host mode. I.e. 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?

Upvotes: 1

Related Questions