问题描述
我有这个 SAM:
"ApiGatewayApi":
{
"Type": "AWS::Serverless::Api","Properties": {
"StageName": "Prod","Name" : "MainGateway","Cors": {
"AllowMethods": "'POST,GET,PUT,DELETE'","AllowHeaders": "'access-control-allow-headers,access-control-allow-methods,access-control-allow-origin,authorization,content-type'","AllowOrigin": "'*'","MaxAge": "'1'"
}
}
},
我尝试添加这样的授权人:
"RESTAuthorizerGeneral":
{
"Type" : "AWS::ApiGateway::Authorizer","Properties" : {
"Name" : "HTTPAuthorizer","Type" : "TOKEN","IdentitySource" : "method.request.header.Authorization","RestApiId" : {"Ref": "ApiGatewayApi"},"AuthorizerUri" : ""
}
},
1 - 我收到此错误:ApiGatewayApi 是此引用的无效类型。
2 - 如何填写“AuthorizerUri”字段?
解决方法
不是 JSON,但有关于如何执行此操作的 YAML 示例:https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-api-apiauth.html