Search code examples
amazon-web-servicesamazon-ec2amazon-dynamodbamazon-elastic-beanstalkaws-php-sdk

Elastic Beanstalk can't connect DynamoDB


I'm really newbie with aws, then sorry if it's a silly question.

I did a website which connects with an online DynamoDB table and it is fully working on my local, but when I deploy the website code in my Elastic Beanstalk environment, it doesn't connect to the DynamoDB table.

Is there some configuration I should have done?

I am afraid nobody else had this problem.

My website have been written in using the aws php sdk by the aws.phar.

I did create a policy for the iam user as follow:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": [
                    "dynamodb:GetItem",
                    "dynamodb:PutItem"
                ],
                "Effect": "Allow",
                "Resource": [DynamoDB table],
                "Condition": {
                    "ForAllValues:StringEquals": {
                        "dynamodb:Attributes": [
                            [Lists of attributes]
                        ]
                    }
                }
            }
        ]
    }

Solution

  • This was solved by adding the correct permission of the role automatically created by Elastic Beanstalk to the EC2 instance.

    http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html