90.0k views
1 vote
What do you need to define on a Lambda function to send logs to CloudWatch Logs?

A. The Log Stream to send logs to and an IAM Role
B. An IAM Role
C. The Log Group to send logs to and an IAM Role
D. The Log Group and Log Stream to send logs to

User Kilojoules
by
7.6k points

1 Answer

1 vote

Final answer:

To enable an AWS Lambda function to send logs to CloudWatch Logs, it is necessary to define an IAM Role with appropriate permissions for logging. The Lambda service manages the creation of Log Groups and Log Streams as needed during function execution.

Step-by-step explanation:

To send logs to CloudWatch Logs from an AWS Lambda function, you need to define an Identity and Access Management (IAM) Role that has the necessary permissions to write logs to CloudWatch. Specifically, the role needs to have policies that allow actions such as logs:CreateLogGroup, logs:CreateLogStream, and logs:PutLogEvents. The Lambda service automatically creates the necessary Log Group and Log Stream the first time your Lambda function is invoked if they do not already exist. The Lambda function assumes the IAM Role you provide, and with the correct permissions, it writes the logs to the configured Log Group and Log Stream within CloudWatch.

User Tuyen Luong
by
7.7k points