Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (19.1k points)

I'm trying to set up a Lambda function that will process a file when it's uploaded to an S3 bucket. I need a way to see the output of console.log when I upload a file, but I can't figure out how to link my Lambda function to CloudWatch.

I figured about by looking at the context object that my log group is /aws/lambda/wavToMp3 and the log stream is 2016/05/23/[$LATEST]hex_code_redacted. So I created that group and stream in CloudWatch, yet nothing is being logged to it.

1 Answer

0 votes
by (44.4k points)

I guess the problem is the IAM role permissions. The lambda function should be given permission to access CloudWatch. So, include the below actions in your Role:

{

    "Statement": [

        {

            "Action": [

                "logs:CreateLogGroup",

                 "logs:CreateLogStream",

                 "logs:PutLogEvents"

            ],

            "Effect": "Allow",

            "Resource": "arn:aws:logs:*:*:*"

        }

    ]

}

Also, after updating the Role do a test once to refresh your function settings or it might not work. 

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...