

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

# 에 대한 API 키 예제 AWS SAM
<a name="serverless-controlling-access-to-apis-keys"></a>

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

다음은 API 키에 대한 예제 AWS SAM 템플릿 섹션입니다.

```
Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Auth:
        ApiKeyRequired: true # sets for all methods

  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: .
      Handler: index.handler
      Runtime: nodejs12.x
      Events:
        ApiKey:
          Type: Api
          Properties:
            RestApiId: !Ref MyApi
            Path: /
            Method: get
            Auth:
              ApiKeyRequired: true
```

API 키에 대한 자세한 내용은 *API Gateway 개발자 가이드*의 [API 키로 사용 계획 생성 및 사용](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html)을 참조하세요.