Is there way to build proper integration test for few AWS Lambdas interacting each other via AWS SNS topic?
I deployed two lambdas using Java.
The first one is subscribed to AWS SNS_topic#1. It filters and transforms SNS message and pushes modified data onto SNS_topic#2.
The second one lambda is subscribed to SNS_topic#2. It modifies SNS message and do http request onto external endpoint.
I need to build end-to-end Integration test to check whole interaction.
Actually there is a better way, you should check out the
https://github.com/localstack/localstack
and https://github.com/localstack/localstack-java-utils
This two tools will help you to test your serverless apps built on AWS
You can use the amazon-cli if you want to test it from your local.
amazon-cli will help you to manually trigger your lamda via aws lambda invoke the command.
Please install amazon-cli at your local from this link.
After that you can invoke the amazon 1st lamda from your cli with aws lamda command. It comes with many options like you can pass payload (supposed to be pass from SNS in actual scenario).
Executing AWS Lamda from Amazon-CLI Command details description
Example command:
aws lambda invoke --function-name your_function_name --invocation-type RequestResponse outfile.txt --payload file:requestFile.txt
I hope it helps.
Related
I am able to run AWS lambda using postman. I want to use the event to run unit test along it. I am not sure how I can generate the event.json file.
I tried logging event that I receive in my handleRequest method on cloudwatch logs but it does not seem to be the right one.
you can find the Lambda event structures in the documentation. Here is the list for all the different event types, https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html.
In your case I would say the event you are looking for coming from API Gateway, you can find it here: https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html#apigateway-example-event
My use case requires to publish metering data to AWS hourly, I am a seller on Marketplace where buyers can subscribe to my SaaS application.
Currently We are handling the use case by having a TaskTimer class and calling meter-usage command on aws to publish data hourly, now I want to convert this timer class to a RestAPI where i can leverage BatchMeterUsage to send/publish data to AWS, as BatchMeter will allow me to send 25 subscequent requests in a batch instead me having to call MeterUsage 25 times.
Any suggestions on this are welcomed. It will be great if I can get Java based solution, Complete Rest flow not needed, controller and services are in place just need to integrate BatchMeterUsage utility in that, can any help me with that.
I have a AWS Lambda function which is deployed in console. Since, it will consume the message from some external queue automatically,I want it to be keep on running continuously instead of scheduling.
How can I make aws lambda to run continuously?
You can add a trigger to your Lambda, and set the SQS queue you want to respond to. In the AWS console (on the web), you can either do this from the Lambda functions itself, or from SQS (i'd advise this strategy). The console will guide you through the details for setting up the proper security stuff.
More info on the setup:
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html
Some general info on consuming SQS messages in Lambda:
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
Your preferred programming language probably has a client library that implements the API for you.
IMPORTANT: If you want to process your queue sequentially, make sure you set the reserved concurrency of your lambda to 0.
Also, if you use CLI or other automatic deploy tools, make sure to update your config files, so you don't overwrite your Lambda's settings on deploy.
EDIT: when you say external queue; you mean a non SQS queue?
I guess it could still be done with another system. Best way to do it is to raise an event. Trigger the Lambda with a http request when a message is added. If for some reason you can't do this, you could add a schedule for your Lambda, and run it, let's say every 5 minutes. More info on scheduling: https://docs.aws.amazon.com/eventbridge/latest/userguide/run-lambda-schedule.html
If instead of an external queue you could use the SQS provided by AWS you could set that queue as a trigger to your Lambda function and have it execute once a new item is set on the queue.
I need to invoke an AWS lambda function using an SQS trigger.
The lambda function needs to include spring boot features - because it needs to transform the message from SQS into another input form and then call an external REST API using spring cloud feign.
I'm supernew to spring & lambda so I'm not sure exactly how to do this.
I would like to understand if my expected workflow is supported by spring and aws, if so, can anyone share some sample code to learn how to achieve this?
I am not able to figure out how to make api calls to amazon elastic transcoder pipeline in java.What should be the base url for the service call or should i make the pipelines manually using the console and create jobs through my code.
You could refer to the API Reference docs and create your own client using any HTTP library, but ideally, you would use the Java SDK for AmazonElasticTranscoderClient, not create your own REST clients.
Specifically, you would want the createPipeline(CreatePipelineRequest request) method
The endpoints for all AWS services are listed on a single page