【问题标题】:How to configure AWS API Gateway to access it from another AWS account如何配置 AWS API Gateway 以从另一个 AWS 账户访问它
【发布时间】: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"
}

我在这里错过了什么?

我遵循了本指南: https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies-examples.html

【问题讨论】:

  • 事实证明,我的所有更改都非常好。显然,AWS 在宣传政策变更方面花费了太多时间。所以,虽然政策更新了,但我只能在 5~6 小时后才能正确使用!

标签: amazon-web-services aws-api-gateway api-gateway


【解决方案1】:

这个问题以前也困扰过我,也可能是你的问题。

保存资源策略后,您还必须部署 API。

  • 在左侧菜单中,点击上一级
  • 然后在操作下,选择部署 API

【讨论】:

  • gaganbm@这回答了你的问题吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-22
  • 2020-03-18
  • 2021-06-10
  • 2020-01-18
  • 1970-01-01
相关资源
最近更新 更多