AWS API 网关:匿名用户无权执行 API [英] AWS API Gateway: User anonymous is not authorized to execute API

查看:39
本文介绍了AWS API 网关:匿名用户无权执行 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试发布到我在 API 网关中创建的 API:

Trying to post to an API I've created in API gateway:

{
    "Message": "User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-west-2:***********:jrr7u1ekrr/v0/POST/user"
}

如何更新 CloudFormation 中的策略以公开 POST 端点?我使用 AWS::ApiGateway::RestApi 资源类型声明 API.

How can I update the policy in CloudFormation to make publicly available the POST endpoint? I'm declaring the API with the AWS::ApiGateway::RestApi resource type.

API 策略属性是:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": "execute-api:/*/POST/user"
        }
    ]
} 

推荐答案

让我失望的事情:如果 API 之前已部署在 API Gateway 控制台中,则您需要重新部署它以使资源策略采用效果."

Something that tripped me up: "If the API has been deployed previously in the API Gateway console, you'll need to redeploy it for the resource policy to take effect."

https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies-create-attach.html

这篇关于AWS API 网关:匿名用户无权执行 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆