Skip to content

Latest commit

 

History

History
73 lines (30 loc) · 2.99 KB

api-gateway-log.md

File metadata and controls

73 lines (30 loc) · 2.99 KB

API Gateway Log 설정

Set up the IAM Role

  1. IAM console에 접속

https://console.aws.amazon.com/iamv2/home#/roles

image

  1. [Create roles]를 선택

image

  1. [Use case]에서 “API Gateway”를 선택하고 “Allows API Gateway to push logs to CloudWatch Logs”를 enable 한후에 [Next]를 선택한다.

image

  1. [Add permissions]에서 AmazonAPIGatewayPushToCloudWatchLogs를 확인하고 [Next]를 선택한다.

image

  1. [Role details]에서 [Role name]으로 “api-gateway-logs-seoul”을 입력하고 스크롤하여 [Create role]을 선택한다.

image

  1. [IAM] - [Roles] 에서 “api-gateway-logs-seoul”을 검색하여, 아래의 ARN 을 확인한다. 예) arn:aws:iam:::role/api-gateway-logs-seoul

image

Configure the IAM Role in API Gateway

  1. API Gateway의 console로 이동한다.

https://ap-northeast-2.console.aws.amazon.com/apigateway/main/apis?region=ap-northeast-2

  1. 왼쪽 메뉴 마지막의 [Settings]를 선택후, 아래와 같이 CloudWatch log role ARN을 입력하고 [Save]를 선택한다.

image

Configure logging in each API

  1. [API:api-filesharing] - [Stages] - [dev] - [dev Stage Editor] - [Logs/Tracing]에서 [Enable CloudWatch Logs]를 enable, [log lever]은 INFO로, [Log full requests/responses data], [Enable Detailed CloudWatch Metrics]을 모두 enable 한다.

image

Trouble shooting

[Save Changes]를 선택했는데 아래와 같이 “CloudWatch Logs role ARN must be set in account settings to enable logging” 에러가 발생하는 경우는 상기와 같이 Roles의 API Gateway log에 대한 ARN이 [Settings]에 잘 설정되어 있는지 확인한다.

image

Reference

https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/?nc1=h_ls

https://kennbrodhagen.net/2016/07/23/how-to-enable-logging-for-api-gateway/