【发布时间】:2021-01-27 16:14:02
【问题描述】:
我们有一个使用 AWS SAM 构建的服务。现在我们要为其添加身份验证。我们有一个 HTTP ApiGateway,我们想向它添加一个 IAM 身份验证器。不幸的是,我找不到任何关于如何做到这一点的示例或文档?我试过了,以下选项:
exampleApi:
Type: AWS::Serverless::HttpApi
Properties:
CorsConfiguration: True
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: 'openapi.yaml'
StageName: v2
Auth:
DefaultAuthorizer: AWS_IAM
和
exampleApi:
Type: AWS::Serverless::HttpApi
Properties:
CorsConfiguration: True
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: 'openapi.yaml'
StageName: v2
fnExample:
Type: AWS::Serverless::Function
Properties:
Handler: index.example
Role: !GetAtt dataLambdaRole.Arn
Events:
getExample:
Type: HttpApi
Properties:
Path: /example
Method: get
ApiId: !Ref exampleApi
Auth:
Authorizer: AWS_IAM
不幸的是,他们都以错误结束。能否请您分享一个关于如何在 AWS SAM 模板中为 HTTP ApiGateway 配置 IAM 授权方的示例或说明。
【问题讨论】: