【发布时间】:2021-09-02 00:34:47
【问题描述】:
我有一个在 ECS Fargate 1.14 上运行的 php 应用程序。 aws-sdk-php 版本是 3.
出于安全原因,我想通过 IAM 角色而不是 AWS 访问密钥/ID 获取存储在 AWS SecretsManager 中的秘密值。 我这样设置 SecretsManagerClient。
$config = [
'version' => '2017-10-17',
'region' => 'ap-northeast-1',
];
return new SecretsManagerClient($config);
我没有添加“凭据”,因为我想通过 IAM 角色访问 SecretsManager。
我的容器的“任务角色”(不是任务执行角色)具有“SecretsManagerReadWrite”策略。
但是,由于此错误,我无法访问 SecretsManager。
Error: [Aws\Exception\CredentialsException] Error retrieving credentials from the instance profile metadata service. (cURL error 7: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)) in /share/swell/cgi-bin/vendor/aws/aws-sdk-php/src/Credentials/InstanceProfileProvider.php on line 240
这条消息是什么意思?
我知道 AWSClient 按以下顺序查找凭证:
1 Load credentials from environment variables.
2 Load credentials from a credentials .ini file.
3 Load credentials from an IAM role.
这种情况不适用于3号吗?
还是我附加了错误的政策?
添加 2021/06/18 的信息
我将附加到 ECS 任务角色的策略更改为“PowerUserAccess”。错误信息更改为 404。
2021-06-18 01:52:12 Error: [Aws\Exception\CredentialsException] Error retrieving credentials from the instance profile metadata service. (Client error: `GET http://169.254.169.254/latest/meta-data/iam/security-credentials/` resulted in a `404 Not Found` response:
【问题讨论】:
标签: amazon-iam aws-secrets-manager aws-php-sdk