Invoke multiple aws services from lambda function in java - aws-lambda

I have a use case where I want to invoke multiple AWS services from an AWS Lambda function written using the Lambda runtime Java API. For example, I would like to invoke SNS, and Pinpoint. Is this possible?

You can write a Lambda function that invokes multiple AWS Services by using the Java Lambda runtime API. This AWS tutorial steps you through the process and then uses the Lambda functions to create a workflow using AWS Step Functions.
Using AWS Step Functions and the AWS SDK for Java to build workflows that sends notifications over multiple channels

Related

How to expose ARN of resource created by the Serverless Framework to Terraform

We are planning to use the Serverless framework to create AWS lambda functions, and Terraform to provision other infrastructure in AWS. We use SSM parameters to get access in Serverless to resources created by Terraform.
However, I am wondering: is there any way to access in Terraform resources created by Serverless? The use case is as follows: in terraform we need to give explicit bucket permissions for a lambda created in Serverless. At the moment we need to hard code the ARN of the lambda. Is there any way to avoid that?
Serverless uses CloudFormation under the hood and there is no direct way to share data between CloudFormation and terraform. Most common way is to use SSM to share data in both directions, so I think you are on the right track (you can use data source to fetch value from SSM).
There is an overview how to use Serverless framework with terraform in this blog post

What is the difference between AWS Lambda and AWS Athena?

I only used Lambda, not Athena, so it seems like they are very similar to me. Serverless and all.
What is the difference between AWS Lambda and AWS Athena?
Aws athena is used to run SQL queries.
whereas,
aws lambda is like a file or package you want to run when required. Itt supports many languages like python,java. You can also interact with different services inside lambda suing boto3 api.

AWS Cloud9 and Lambda Alias

I am trying to understand how AWS Cloud9 works with AWS Lambda alias and version system.
When deploying a lambda from Cloud9, does it always deploy on $LATEST ?
When importing a lambda in Cloud9, does it always import $LATEST ?
Can we choose versions ?
Can we choose alias ?
If this is somewhere is the doc, sorry, I just can't find it.
The Lambda section of the AWS Resources window in the AWS Cloud9 IDE currently does not provide any features for working with Lambda function versions or aliases. Instead, you can use the terminal in the IDE to run the AWS CLI and AWS SAM CLI with the corresponding commands, actions, and arguments. For details, see the following:
Introduction to AWS Lambda Versioning in the AWS Lambda Developer Guide
Introduction to AWS Lambda Aliases in the AWS Lambda Developer Guide
Managing Versioning Using the AWS Management Console, the AWS CLI, or Lambda API Operations in the AWS Lambda Developer Guide

Aws Lambda Deployment via CodePipeline

I would like to deploy my Lambda methods by using Aws Codepipeline. However, when i follow Aws Codepipeline creation wizard, i couldn't understand which one should i choose at beta stage. Because, not only Aws Codedeploy, but also Elastic Beanstalk are concerning only EC2 instances. There is lack of tutorial about telling step by step to create pipeline for our lambda, apigateway deployments. How can i skip beta stage without choosing one of them?, or which one should i choose for my serverless architecture's deployments?.
There are no direct integrations for Lambda/API Gateway -> CodePipeline at the moment. You could certainly do something with Jenkins like #arjabbar suggested. Thanks for the feedback, we'll take this on our backlog.
CloudFormation is available in CodePipeline now. This allows you to target cloudformation templates as Actions in the CodePipeline.
Here's an overview (the implementation was moved to a private repository after I changed positions):
https://aws.amazon.com/blogs/compute/continuous-deployment-for-serverless-applications/
In this pipeline we deploy a staging lambda, test its functionality, then deploy the production lambda.

How to connect microservice to SQS/SNS

I have a java microservice that runs in a Docker container in a Ec2 instance .
It has to get notified when a file is dropped in a S3 bucker. We have a SNS and SQS that is connected to the S3 bucket. How can i connect the microserice to the SNS/SQS ? If there is a better way to get the java microservice get notified when the files is dropped into S3 bucket please let me know ?
The AWS SDK for Java is pretty good.
You can either:
write an HTTP endpoint that SNS can post to (see http://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.example.java.html)
or
subscribe to an SQS topic (see https://github.com/aws/aws-sdk-java/blob/master/src/samples/AmazonSimpleQueueService/SimpleQueueServiceSample.java).
Yes, this is one use case of AWS Lambda:
As an event-driven compute service where AWS Lambda runs your code in
response to events, such as changes to data in an Amazon S3 bucket or
an Amazon DynamoDB table.
http://docs.aws.amazon.com/lambda/latest/dg/welcome.html
Since it runs your code, you are free to write something that places a request to a microservice.

Resources