本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
IAM 权限示例
您可以通过在自己的中定义 IAM 权限来控制对 API 的访问。Amazon SAMTemplate 要执行此操作,请使用ApiAuth数据类型。
以下是示例:Amazon SAMIAM 权限的模板部分:
Resources: MyApi: Type: AWS::Serverless::Api Properties: StageName: Prod Auth: DefaultAuthorizer: AWS_IAM MyFunction: Type: AWS::Serverless::Function Properties: CodeUri: . Handler: index.handler Runtime: nodejs12.x Events: GetRoot: Type: Api Properties: RestApiId: !Ref MyApi Path: / Method: get
有关 IAM 权限的更多信息,请参阅。针对调用 API 的访问控制中的API Gateway 开发人员指南.