You can insert logging statements into your code to help you validate that your code is working as expected. Lambda automatically integrates with CloudWatch Logs and pushes all logs from your code to a CloudWatch Logs group associated with a Lambda function, which is named/ aws/ lambda/ <function name>.
You can view logs for Lambda functions using the Lambda console, the CloudWatch console, the AWS Command Line Interface( AWS CLI>
, or the CloudWatch API. This page describes how to view logs using the Lambda console.
Your execution role needs permission to upload logs to CloudWatch Logs. You can add CloudWatch Logs permissions using the AWSLambdaBasicExecutionRole AWS managed policy provided by Lambda. To add this policy to your role, run the following command
aws iam attach- role- policy-- role- name your- role-- policy- arn arna