-
Notifications
You must be signed in to change notification settings - Fork 1k
Created two new patterns activemq-private-lambda-java-sam and rabbitmq-private-lambda-java-sam #2850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This reverts commit e43e02f.
…e Lambda Java SAM Project
…bitmq-private-lambda-java-sam patterns
ellisms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @indranil-banerjee-aws . Please review the requested changes. Also, check if the .prefs and .settings/* files/directories are required. If not, add to .gitignore.
| @@ -0,0 +1,172 @@ | |||
| # Java AWS Lambda ActiveMQ (in private subnets) consumer, using AWS SAM | |||
|
|
|||
| This pattern is an example of a Lambda function written in Java that consumes messages from Amazon MQ (Apache ActiveMQ). The pattern demonstrates how a SAM project can be configured to deploy an AWS Lambda function written in Java with an Amazon MQ (Apache ActiveMQ) event trigger. The pattern demonstrates how Amazon MQ (Apache ActiveMQ) messages can be parsed in an AWS Lambda function and the parsed content output to an Amazon DynamoDB table. The pattern provides an AWS CloudFormation template to install and set-up an Amazon MQ (Apache ActiveMQ) cluster inside private subnets in an Amazon VPC. The CloudFormation template also installs an Amazon EC2 instance with tools necessary to configure the Amazon MQ (Apache ActiveMQ) cluster to generate Amazon MQ (Apache ActiveMQ) messages and configuration needed by a Java producer that can generate the Amazon MQ (Apache ActiveMQ) messages. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This pattern is an example of a Lambda function written in Java that consumes messages from Amazon MQ (Apache ActiveMQ). The pattern demonstrates how a SAM project can be configured to deploy an AWS Lambda function written in Java with an Amazon MQ (Apache ActiveMQ) event trigger. The pattern demonstrates how Amazon MQ (Apache ActiveMQ) messages can be parsed in an AWS Lambda function and the parsed content output to an Amazon DynamoDB table. The pattern provides an AWS CloudFormation template to install and set-up an Amazon MQ (Apache ActiveMQ) cluster inside private subnets in an Amazon VPC. The CloudFormation template also installs an Amazon EC2 instance with tools necessary to configure the Amazon MQ (Apache ActiveMQ) cluster to generate Amazon MQ (Apache ActiveMQ) messages and configuration needed by a Java producer that can generate the Amazon MQ (Apache ActiveMQ) messages. | |
| This pattern is an example of a Lambda function written in Java that consumes messages from Amazon MQ (Apache ActiveMQ), located in an private subnet. The function parses the ActiveMQ messages and stores the results in an Amazon DynamoDB table. The pattern provides an AWS CloudFormation template to install and set-up an Amazon MQ (Apache ActiveMQ) cluster inside private subnets in an Amazon VPC. The CloudFormation template also launches an Amazon EC2 instance with tools necessary to configure the Amazon MQ (Apache ActiveMQ) cluster and generate Amazon MQ (Apache ActiveMQ) messages. |
|
|
||
| * [Run the AWS CloudFormation template using the file ActiveMQAndClientEC2.yaml] - You can go to the AWS CloudFormation console, create a new stack by specifying the template file. You can keep the defaults for input parameters or modify them as necessary. Wait for the AWS CloudFormation stack to be created. This AWS CloudFormation template will create an Amazon MQ (Apache ActiveMQ) cluster. It will also create an EC2 instance that you can use as a client. | ||
|
|
||
| * [Connect to the EC2 instance] - Once the AWS CloudFormation stack is created, you can go to the EC2 console and log into the machine using either "Connect using EC2 Instance Connect" or "Connect using EC2 Instance Connect Endpoint" option under the "EC2 Instance Connect" tab. In case you are using SSM Instance connect, you are not initially placed in the home directory. If you connect as ssm-user, you need to sudo su to ec2-user for this to work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include instructions for Session Manager. It is easier to use.
| * [Connect to the EC2 instance] - Once the AWS CloudFormation stack is created, you can go to the EC2 console and log into the machine using either "Connect using EC2 Instance Connect" or "Connect using EC2 Instance Connect Endpoint" option under the "EC2 Instance Connect" tab. In case you are using SSM Instance connect, you are not initially placed in the home directory. If you connect as ssm-user, you need to sudo su to ec2-user for this to work. | |
| * [Connect to the EC2 instance] - Once the AWS CloudFormation stack is created, you can go to the EC2 console and log into the instance using either "Connect using EC2 Instance Connect" or "Connect using EC2 Instance Connect Endpoint" option under the "EC2 Instance Connect" tab. In case you are using SSM Instance connect, you are not initially placed in the home directory. If you connect as ssm-user, you need to sudo su to ec2-user for this to work. |
|
|
||
| ## Pre-requisites to Deploy the sample Lambda function | ||
|
|
||
| The EC2 instance that was created by running the AWS CloudFormation template has all the software that will be needed to deploy the Lambda function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The EC2 instance that was created by running the AWS CloudFormation template has all the software that will be needed to deploy the Lambda function. | |
| The EC2 instance created by the AWS CloudFormation template has all the software required to deploy the Lambda function. |
|
|
||
| The AWS SAM CLI is a serverless tool for building and testing Lambda applications. | ||
|
|
||
| * Java - On the EC2 instance, we have installed the version of Java that you selected. We have installed Amazon Corrretto JDK of the version that you had selected at the time of specifying the input parameters in the Cloudformation template. At the time of publishing this pattern, only Java versions 11, 17 and 21 are supported by AWS SAM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Java - On the EC2 instance, we have installed the version of Java that you selected. We have installed Amazon Corrretto JDK of the version that you had selected at the time of specifying the input parameters in the Cloudformation template. At the time of publishing this pattern, only Java versions 11, 17 and 21 are supported by AWS SAM | |
| * Java - On the EC2 instance, we installed the version of Java and Amazon Corretto JDK you selected at deployment. At the time of publishing this pattern, only Java versions 11, 17 and 21 are supported by AWS SAM |
| The AWS SAM CLI is a serverless tool for building and testing Lambda applications. | ||
|
|
||
| * Java - On the EC2 instance, we have installed the version of Java that you selected. We have installed Amazon Corrretto JDK of the version that you had selected at the time of specifying the input parameters in the Cloudformation template. At the time of publishing this pattern, only Java versions 11, 17 and 21 are supported by AWS SAM | ||
| * Maven - On the EC2 instance, we have installed Maven (https://maven.apache.org/install.html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Maven - On the EC2 instance, we have installed Maven (https://maven.apache.org/install.html) | |
| * Maven - On the EC2 instance, we installed Maven (https://maven.apache.org/install.html) |
|
|
||
| When you run the above script, it sends messages with JSON records to the Amazon MQ (Apache ActiveMQ) cluster on the queue on which the lambda function is listening on. The lambda function listens on the published Amazon MQ (Apache ActiveMQ) messages on the queue. | ||
|
|
||
| The lambda code parses the Amazon MQ (Apache ActiveMQ) messages and outputs the fields in the messages to Amazon CloudWatch logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The lambda code parses the Amazon MQ (Apache ActiveMQ) messages and outputs the fields in the messages to Amazon CloudWatch logs | |
| The Lambda code parses the Amazon MQ (Apache ActiveMQ) messages and outputs the fields in the messages to Amazon CloudWatch logs |
|
|
||
| The lambda code parses the Amazon MQ (Apache ActiveMQ) messages and outputs the fields in the messages to Amazon CloudWatch logs | ||
|
|
||
| The lambda function also inputs each record into an Amazon DynamoDB table called ActiveMQDynamoDBTableJava (if you did not modify the default name in the sam template.yaml file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The lambda function also inputs each record into an Amazon DynamoDB table called ActiveMQDynamoDBTableJava (if you did not modify the default name in the sam template.yaml file) | |
| The Lambda function also inputs each record into an Amazon DynamoDB table called ActiveMQDynamoDBTableJava (if you did not modify the default name in the sam template.yaml file) |
|
|
||
| private static final String mqEventJson = "{\n" | ||
| + " \"eventSource\": \"aws:rmq\",\n" | ||
| + " \"eventSourceArn\": \"arn:aws:mq:us-west-2:664251831272:broker:ib-rabbitmq-broker:b-22450561-3f76-4004-813d-392346f054fe\",\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anonymize the account number
|
|
||
| private static final String mqEventJson = "{\n" | ||
| + " \"eventSource\": \"aws:rmq\",\n" | ||
| + " \"eventSourceArn\": \"arn:aws:mq:us-west-2:664251831272:broker:ib-rabbitmq-broker:b-22450561-3f76-4004-813d-392346f054fe\",\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anonymize the account number
| @@ -0,0 +1,500 @@ | |||
| James,Butt,"Benton, John B Jr",6649 N Blue Gum St,New Orleans,Orleans,LA,70116,504-621-8927,504-845-1427,jbutt@gmail.com,http://www.bentonjohnbjr.com | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file used? If so, anonymize all the data. If not, remove.
Issue #, if available:
Description of changes:
Created two new patterns activemq-private-lambda-java-sam and rabbitmq-private-lambda-java-sam. The existing patterns create public clusters and include the AmazonMQ clusters inside the SAM template. These new patterns separate out the AmazonMQ cluster creation from the Lambda function SAM template. CloudFormation templates are provided for creating the clusters inside private subnets, which is more real-life as customers won't create public AmazonMQ clusters. The patterns also create an EC2 machine that has all the tools installed to be able to deploy the Lambda function using SAM templates. Generator programs that will generate messages to AmazonMQ are also provided. Instructions in the Readme guide the user step-by-step.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.