- IAM console에 접속
https://console.aws.amazon.com/iamv2/home#/roles
- [Create roles]를 선택
- [Use case]에서 “API Gateway”를 선택하고 “Allows API Gateway to push logs to CloudWatch Logs”를 enable 한후에 [Next]를 선택한다.
- [Add permissions]에서 AmazonAPIGatewayPushToCloudWatchLogs를 확인하고 [Next]를 선택한다.
- [Role details]에서 [Role name]으로 “api-gateway-logs-seoul”을 입력하고 스크롤하여 [Create role]을 선택한다.
- [IAM] - [Roles] 에서 “api-gateway-logs-seoul”을 검색하여, 아래의 ARN 을 확인한다. 예) arn:aws:iam:::role/api-gateway-logs-seoul
- API Gateway의 console로 이동한다.
https://ap-northeast-2.console.aws.amazon.com/apigateway/main/apis?region=ap-northeast-2
- 왼쪽 메뉴 마지막의 [Settings]를 선택후, 아래와 같이 CloudWatch log role ARN을 입력하고 [Save]를 선택한다.
- [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 한다.
[Save Changes]를 선택했는데 아래와 같이 “CloudWatch Logs role ARN must be set in account settings to enable logging” 에러가 발생하는 경우는 상기와 같이 Roles의 API Gateway log에 대한 ARN이 [Settings]에 잘 설정되어 있는지 확인한다.
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/