【问题标题】:S3 Notifications to SQS: "Unable to validate the following destination configurations"S3 到 SQS 的通知:“无法验证以下目标配置”
【发布时间】:2017-06-12 17:22:20
【问题描述】:

我正在尝试使用 SQS 创建 S3 存储桶通知。

$downArn = $client->getQueueArn($downUrl);

$client->addPermission([
    'QueueUrl' => $downUrl,
    'Label' => 'S3Watcher',
    'AWSAccountIds' => [
        'AWS' => '*' // This will throw error; Setting to plain * does not work too
    ],
    'Actions' => ['*']
]);

$s3->putBucketNotificationConfiguration([
    'Bucket' => 's3-to-sqs-test',
    'QueueConfigurations' => [
        [
            'Id' => 'Files upload watcher',
            'QueueArn' => $downArn,
            'Events' => [
                's3:ObjectCreated:Put',
            ],
        ],
    ]
]);

问题是未经许可我无法创建通知,我收到错误

无法验证以下目标配置

当手动进入 SQS 并添加权限时,我可以为所有用户标记Everybody (*),但我不能从 PHP 端做同样的事情。

TL;DR如何使用 PHP AWS SDK 为每个 Principal (AWSAccountIds) 添加 SQS 权限

【问题讨论】:

    标签: php aws-sdk


    【解决方案1】:

    这是 SDK v2 中的 AWS SDK 限制。您可以通过在创建 SQS 时将 Attributes > Policy 设置为 JSON 字符串来绕过此问题。

    $client
        ->createQueue([
            'QueueName' => $name,
            'Attributes' => [
                'Policy' => json_encode([
                    'Version' => '2012-10-17',
                    'Id' => $id,
                    'Statement' => [
                        [
                            'Sid' => 'Sid1',
                            'Effect' => 'Allow',
                            'Principal' => '*',
                            'Action' => 'SQS:*',
                            'Resource' => 'arn:aws:sqs:*:*:*',
                        ]
                    ],
                ]),
            ]
        ])
    

    Resource 的格式为arn:aws:{service}:{region}:{accountID}:{resourceName},所以我只是把* 用于从任何帐户和资源申请任何区域。

    IdSid 似乎允许任何文本。

    Version 必须是2012-10-17

    【讨论】:

      猜你喜欢
      • 2020-06-06
      • 2021-03-16
      • 2020-05-16
      • 2021-07-04
      • 2017-12-17
      • 2021-11-26
      • 2019-07-14
      • 2018-04-23
      • 2021-08-27
      相关资源
      最近更新 更多