Amazon API Gateway REST API to Amazon CloudWatch

Amazon API Gateway → Amazon CloudWatch

Create a REST API that has CloudWatch execution and access logs enabled.

A REST API is created that has an IAM role with managed policy 'AmazonAPIGatewayPushToCloudWatchLogs' which allows API Gateway to write CloudWatch logs to your account.
In the API stage, CloudWatch execution logs are enabled with INFO Log level selected as well as custom access logging to generate execution and access logs for all requests.
The API has a AWS Lambda function integration which returns 'Hello from Lambda' in response.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-execution-access-logs

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Noor Bari

Noor Bari

Cloud Support Engineer @ AWS.

Follow on LinkedIn