【发布时间】:2020-03-09 18:41:33
【问题描述】:
我想向其他账户的 IAM 用户授予访问权限,以便能够调用我的 API。
我的 API Gateway 资源方法中有这些配置:
Authorization type: AWS_IAM(我也尝试过使用身份验证类型None..)
并将资源策略定义为:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<ACCOUNT_2>:user/ApiUser"
},
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:us-west-2:<ACCOUNT_1>:<API_ID>/*/*/*"
}
]
}
我还向其他账户的 IAM 用户授予了调用权限:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"execute-api:Invoke"
],
"Resource": "arn:aws:execute-api:us-west-2:<ACCOUNT_1>:<API_ID>:test/GET/*"
}
]
}
我已将 API 部署到名为 test 的阶段。
不过,当我使用其他帐户用户的凭据调用 API 时,我看到以下错误:
{
"message": "User: arn:aws:iam::<ACCOUNT_2>:user/ApiUser is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-west-<ACCOUNT_1>:<API_ID>/test/GET/foo/bar"
}
我在这里错过了什么?
【问题讨论】:
-
事实证明,我的所有更改都非常好。显然,AWS 在宣传政策变更方面花费了太多时间。所以,虽然政策更新了,但我只能在 5~6 小时后才能正确使用!
标签: amazon-web-services aws-api-gateway api-gateway