I'm using Elastic Beanstalk to run a flask app. I want to use DynamoDB as the database. In order to access DynamoDB, I'm using PynamoDB, which access DynamoDB service by botocore. As the AWS document says, I have created the credentials file at ~/.aws/credentials
on my Mac and set the AWS user access_key. The flask app can access DynamoDB running on my Mac. However, after deploy to Elastic Beanstalk by eb deploy
, I don't know to how to add the credentials file.
I have tried:
- copy the credentials file under my project root directory. and create a config file:
02_dynamodb.config
under.ebextensions
.
commands: 01makecredentials: command: mkdir ~/.aws/;cp ./credentials ~/.aws/credentials
it failed to deploy after adding the config file.
- I have read the botocore document, which says that I can set the access_key by session. However, PynamoDB could not use a custom session. It will create a session if it need and the session will read access_key from
~/.aws/credentials
, or.boto
I have read lots of document but don't know how to set the access_key to botocore application after deploying the app to Elastic Beanstalk. The AWS document only tell me how to set the access_key on my development Mac.
Any help would be appreciate.
Update Thanks @mbaird! The solution is to grant DynamoDB Access permission for aws-elasticbeanstalk-ec2-role!