s3 event is not triggering AWS Lambda function while uploading jar file from bamboo build plan

+1 vote

s3 event is not triggering AWS Lambda function while uploading jar file from bamboo build plan. 

And if I upload Jar manually in s3 Bucket then S3Event is triggering AWS Lambda function correctly. Below are the permission Bucket.

Below is my LambdaFuncton code:

package com.lambda;


import com.amazonaws.services.lambda.AWSLambda;

import com.amazonaws.services.lambda.AWSLambdaClientBuilder;

import com.amazonaws.services.lambda.model.UpdateFunctionCodeRequest;

import com.amazonaws.services.lambda.model.UpdateFunctionCodeResult;

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

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

import com.amazonaws.services.lambda.runtime.events.S3Event;

import com.amazonaws.services.s3.AmazonS3;

import com.amazonaws.services.s3.AmazonS3ClientBuilder;

import com.amazonaws.services.s3.model.GetObjectRequest;

import com.amazonaws.services.s3.model.S3Object;

import org.apache.commons.io.IOUtils;


import java.io.IOException;

import java.nio.ByteBuffer;


public class TestLambdaS3Event implements RequestHandler<S3Event, String> {


private AmazonS3 s3 = AmazonS3ClientBuilder.standard().build();

AWSLambda s3EventClient = AWSLambdaClientBuilder.standard().build();


public TestLambdaS3Event() {

}



@Override

public String handleRequest(S3Event event, Context context) {

context.getLogger().log("Received event: " + event);


// Get the object from the event and show its content type

String bucket = event.getRecords().get(0).getS3().getBucket().getName();

String key = event.getRecords().get(0).getS3().getObject().getKey();

try {

S3Object response = s3.getObject(new GetObjectRequest(bucket, key));

String contentType = response.getObjectMetadata().getContentType();


byte[] byteArray = IOUtils.toByteArray(response.getObjectContent());

UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName("my_function")

.withZipFile(ByteBuffer.wrap(byteArray));

System.out.println("request## " + request);

UpdateFunctionCodeResult responseUpdate = s3EventClient.updateFunctionCode(request);

System.out.println("responseUpdate## "+responseUpdate);

return contentType;

} catch (IOException e) {

e.printStackTrace();

context.getLogger().log(String.format("Error getting object %s from bucket %s. Make sure they exist and"

+ " your bucket is in the same region as this function.", bucket, key));

return e.toString();

}


}


}
Apr 4, 2020 in Others by Abhishek
• 280 points
1,606 views
Can you share your error?

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer

what is aws lambda function?

AWS Lambda is a serverless computing service ...READ MORE

answered Jan 7, 2022 in Others by Edureka
• 12,690 points
248 views
0 votes
1 answer

AWS EC2: Instance from my own Windows AMI is not reachable

The existing administrator password (and other user ...READ MORE

answered Mar 9, 2022 in Others by gaurav
• 23,260 points
439 views
0 votes
1 answer

why aws s3 transfer acceleration is not working?

Essentially, rather than travelling the Internet to ...READ MORE

answered Mar 24, 2022 in Others by gaurav
• 23,260 points
1,009 views
0 votes
1 answer

why aws s3 transfer acceleration is not working?

Amazon S3 Transfer Acceleration is a bucket-level ...READ MORE

answered Mar 24, 2022 in Others by gaurav
• 23,260 points
705 views
0 votes
1 answer

how to install Amazon AWS Command Line Interface tools on Bamboo build agent.

Hi@Abhishek, You need to set the following parameters ...READ MORE

answered Apr 6, 2020 in Others by MD
• 95,440 points
1,485 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,460 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP