amazon-web-services - 如何配置 AWS API Gateway 以从另一个 AWS 账户访问它
问题描述
我想向其他账户的 IAM 用户授予访问权限,以便能够调用我的 API。
我的 API Gateway 资源方法中有这些配置:
Authorization type: AWS_IAM
(我也尝试过使用 Auth 类型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"
}
我在这里想念什么?
解决方案
这曾经咬过我,也可能是你的问题。
保存资源策略后,还必须部署 API。
- 在左侧菜单中,单击上一级
- 然后在操作下,选择部署 API
推荐阅读
- c - 以最小的字节变化数修补 ELF
- python - Python:如何绘制具有中心坐标的图像?
- date-conversion - MS SQL Server 在年份(日期字段)中添加“12-31”
- c++ - 有条件地并行填充向量
- excel - 将excel公式转换为vba
- java - 如何在 Testng assertEquals 中使用 hamcrest 匹配器?
- css - 为什么 MuiThemeProvider 会覆盖组件样式?
- plugins - Logstash 字段拆分和合并
- javascript - 如何在我的角度组件中动态呈现带有样式和 *ngFor 的 HTML 选择框?
- javascript - 无法加载源。服务器响应 500