IAM 許可の例 - AWS Serverless Application Model

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

IAM 許可の例

API へのアクセスは、 AWS SAM テンプレート内で IAM 許可を定義することによって制御できます。これを実行するには、ApiAuth データ型を使用します。

IAM AWS SAM アクセス権限に使用するテンプレートの例を以下に示します。

AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: MyApi: Type: AWS::Serverless::Api Properties: StageName: Prod Description: 'API with IAM authorization' Auth: DefaultAuthorizer: AWS_IAM #sets AWS_IAM auth for all methods in this API MyFunction: Type: AWS::Serverless::Function Properties: Handler: index.handler Runtime: python3.10 Events: GetRoot: Type: Api Properties: RestApiId: !Ref MyApi Path: / Method: get InlineCode: | def handler(event, context): return {'body': 'Hello World!', 'statusCode': 200}

IAM 許可の詳細については、API Gateway デベロッパーガイドの「API を呼び出すためのアクセスの制御」を参照してください。