弹性豆茎不连接到dynamodb

This is a very strange problem. I have just setup my application on elastic beanstalk, the connection which I made with dynamodb is working fine but when i made a connection through an AJAX call , it is not connecting and also it is not showing any error. Please help me guys

I have tried changing my role from aws-elasticbeanstalk-service-role to aws-elasticbeanstalk-ec2-role. But still no luck!

I am using the below code to make the connection -

     $credentials = new \Aws\Credentials\Credentials(AWS_KEY, AWS_SECRET);
    $client = new \Aws\DynamoDb\DynamoDbClient([
        'region'  => 'us-west-2',
        'version' => 'latest',
        'credentials' => $credentials
    ]);