Reputation: 353
Is there any possible way to disable CloudWatch to log Lambda Function's events? If possible, then what are the steps to do this.
Upvotes: 28
Views: 19384
Reputation: 663
There is no flag/toggle/switch or a direct way to disable the CloudWatch logs for a lambda function. One workaround is you can add the following inline policy to your role to disable the CloudWatch logs.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:*:*:*"
]
}
]
}
You can change the "Deny" to "Allow" when you require logging again.
Upvotes: 27
Reputation: 246
As per my understanding log output is generated by as a default behavior if you do any tests with lambda function. However, the logs are stored in CloudWatch log group only if your lambda role has permission to write to CloudWatch.
Upvotes: 22