Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
Logging with AWS Lambda from Java seems to be broken

I have created the same function in Python and Java (simple hello world) following the guide. Using the same role the Python version works as expected generating the log stream entry and printing "ok".

from __future__ import print_function
import json
print('Loading function')
def lambda_handler(event, context):
    return "ok"

However the Java version does not log anything with the same role and settings.

package com.streambright;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class Dbmgmt implements RequestHandler<Object, Object> {
    @Override
    public String handleRequest(Object in, Context ctx) {
        System.out.println("test");
        ctx.getLogger().log("o hai");
        return "ok";
    }
}

I am wondering why it does not put anything into CloudWatch Log Groups. Does anybody have the same experience with Java? Does anybody have the same experience? Is there a fix workaround for this?

Also posted on the AWS forum: https://forums.aws.amazon.com/thread.jspa?threadID=254747

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Found the root cause of this. The role policy was not allowing the correct log resource to be created, and it silently failed. The AWS UI was not too helpful to help identify this issue, I was running into it accidentally during an audit. After changin the resource to * the lambda function was able to create the log resource.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "xray:PutTraceSegments",
                "xray:PutTelemetryRecords",
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents",
                "ec2:CreateNetworkInterface",
                "ec2:DeleteNetworkInterface",
                "ec2:DescribeNetworkInterfaces",
                "kms:Decrypt"
            ],
            "Resource": "*"
        }
    ]
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!