本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
资源策略示例
您可以在Amazon SAMTemplate 要执行此操作,请使用ApiAuth数据类型。
以下是示例:Amazon SAM资源策略的模板部分:
Resources: ExplicitApi: Type: AWS::Serverless::Api Properties: StageName: Prod EndpointConfiguration: PRIVATE Auth: ResourcePolicy: CustomStatements: { Effect: 'Allow', Action: 'execute-api:Invoke', Resource: ['execute-api:/*/*/*'], Principal: '*' } MinimalFunction: Type: 'AWS::Serverless::Function' Properties: CodeUri: s3://sam-demo-bucket/hello.zip Handler: hello.handler Runtime: python2.7 Events: AddItem: Type: Api Properties: RestApiId: Ref: ExplicitApi Path: /add Method: post
有关资源策略的更多信息,请参阅。使用 API Gateway 资源策略控制对 API 的访问中的API Gateway 开发人员指南.