Intellipaat Back

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

How do get logging from custom authorizer lambda function in API Gateway? I do not want to enable logging for API. I need logging from authorizer lambda function. I use a python lambda function and have prints in the code. I want to view the prints in Cloud Watch logs. But logs are not seen in cloud watch. I do not get errors either. What am I missing?

Lambda has execution role role/service-role/MyLambdaRole. This role has the policy to write to cloud watch.

{

    "Version": "2012-10-17",

    "Statement": [

        {

            "Effect": "Allow",

            "Action": "logs:CreateLogGroup",

            "Resource": "arn:aws:logs:us-east-1:123456:*"

        },

        {

            "Effect": "Allow",

            "Action": [

                "logs:CreateLogStream",

                "logs:PutLogEvents"

            ],

            "Resource": [

                "arn:aws:logs:us-east-1:123456:log-group:MyCustomAuthorizer:*"

            ]

        }

    ]

}

I also tested by adding CloudWatchLogsFullAccess policy to role/service-role/MyLambdaRole role.

{

  "Version": "2012-10-17",

  "Statement": [

    {

      "Action": [

        "logs:*"

      ],

      "Effect": "Allow",

      "Resource": "*"

    }

  ]

}

1 Answer

0 votes
by (44.4k points)

You have to recreate it after deleting it. Delete the Lambda function and Custom Authorizer from API Gateway and then recreate it with the same settings. It will work.

Related questions

31k questions

32.4k answers

500 comments

693 users

Browse Categories

...