

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 에 대한 IAM 권한 예제 AWS SAM
<a name="serverless-controlling-access-to-apis-permissions"></a>

귀하의 AWS SAM 템플릿 내에서 IAM 권한을 정의하여 API에 대한 액세스를 제어할 수 있습니다. 이 작업을 수행하려면 [ApiAuth](sam-property-api-apiauth.md) 데이터 유형을 사용합니다.

다음은가 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 호출을 위한 액세스 제어](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html)를 참조하세요.