[英]AWS API Gateway: User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:
[英]Receiving error "User: arn:aws:iam::11345636234528:user/my_Api is not authorized to perform: secretmanager:GetSecretValue on resouce: my_Resource"?
我正在尝试从我的 ide 执行我的代码并通过 boto3 连接到 aws 资源。 我 go 进入 aws 控制台的 Secrets 门户。 在 aws secrets manager 中,我找到了名为 my_api 的资源,其中存储了我的秘密。 我复制该名称,以便我可以访问所需值的字典响应。 我在我的 ide 中使用以下代码来尝试检索该字典响应:
import boto3
client=boto3.client("secretmanager")
reponse=client.get_secret_value(
secretId="my_api"
)
print(response)
我将该代码添加到我的 ide 中的一个 python 文件中,并在 vscode 中使用内置终端写入运行它: python my_boto3.py
并收到以下错误:
raise error_class(parsed_reponse, operation_name) botocore.exception.ClientError: An error
occured (AccessDeniedException) when calling the GetSecretValue operation:
User: arn:aws:iam::11345636234528:user/my_Api is not authorized to perform:
secretmanager:GetSecretValue on resouce: my_Resource because no identity-based policy allows
the secretsmanager:GetSecretValue action"
但是当我 go 进入我的 aws 以找到关联的 lambda function 并在 aws 代码编辑器中使用相同的代码行时,它运行良好并打印结果。 是什么导致我的本地环境出现该错误与打印所需结果的 aws 环境之间断开连接?
在我收到此错误之前: Unable to parse config file: /Users/hugo/.aws/config
。 但是我通过简单地打开 aws 配置文件并复制并粘贴在 my_api 的秘密管理器中找到的aws_access_key_id
和aws_secret_access_key
来解决这个问题,如下所示:
[default]
region=us-west-2
aws_access_key_id=xxxxxx
aws_secret_access_key=xxxxxx
任何帮助表示赞赏。
谢谢
my_Api
没有secretmanager:GetSecretValue
权限。 您可以向用户添加内联策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "secretmanager:GetSecretValue",
"Resource": "*"
}
]
}
您可以将*
替换为密钥的 ARN 以更加安全。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.