douyeyan0650 2017-09-08 16:21
浏览 64
已采纳

无法从我的EC2实例中提取SQS消息

When I deploy my application to a EC2 instance, it fails to fetch messages from my SQS queue. And instead throws an exception with the status code 403 Forbidden, access to the resource {sqs queue} is denied. However, when I run the same code from my local environment my application can fetch messages from the SQS queue.

My application uses the symfony framework and passes pre-configured AWS credentials, for a user who has access to this queue, from the parameters.yml into \Aws\Sqs\SqsClient().

If on the EC2 instance I run aws configure and configure the aws cli with the same credentials the application can pull messages from the SQS queue. I am concerned here because it is like the aws sdk is overriding the credentials I pass it.

As a example the following code even with hard coded parameters which I have checked are valid credentials, returns a 403 when ran on a EC2 instances.

 $sqs = new \Aws\Sqs\SqsClient([
        [
            'key' => '{my key}',
            'secret' => '{my secret}'
        ],
        'region' => 'us-east-1',
        'version' => 'latest'
    ]);

    $response = $sqs->receiveMessage([
        'QueueUrl' => 'https://sqs.us-east-1.amazonaws.com/{my account}/{my queue}'
    ]);

Does anyone have any suggestions about what may be happening here?

  • 写回答

2条回答 默认 最新

  • dongyi1524 2017-09-08 17:14
    关注

    Try with credentials key in config.

    $sqs = new \Aws\Sqs\SqsClient([
        'credentials' => [
                'key'    => '{my key}',
                'secret' => '{my secret}',
            ],
            'region' => 'us-east-1',
            'version' => 'latest'
        ]);
    
        $response = $sqs->receiveMessage([
            'QueueUrl' => 'https://sqs.us-east-1.amazonaws.com/{my accoun}/{my queue}'
        ]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件