You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentdb-lambda-java-sam/README.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Java AWS Lambda Amazon DocumentDB Streams consumer, using AWS SAM
2
2
3
-
This pattern is an example of a AWS Lambda function written in Java that consumes messages from Amazon DocumentDB Streams. The pattern demonstrates how a SAM project can be configured to deploy an AWS Lambda function written in Java with an Amazon DocumentDB event trigger. The pattern demonstrates how Amazon DocumentDB streams 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 DocumentDB cluster. The CloudFormation template also installs an Amazon EC2 instance with tools necessary to configure the Amazon DocumentDB cluster to generate Amazon DocumentDB streams and configuration needed by a Java producer that can generate the Amazon DocumentDB streams.
3
+
This pattern demonstrates consuming messages from an Amazon DocumentDB stream with AWS Lambda. This Java Lambda function parses the stream data and writes the results to an Amazon DynamoDB table. The pattern provides an AWS CloudFormation template to install and configure an Amazon DocumentDB cluster, configures an Amazon EC2 instance with Amazon DocumentDB tools, and creates a Java producer for generating sample data.
4
4
5
5
This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.
6
6
@@ -20,7 +20,8 @@ Important: this application uses various AWS services and there are costs associ
20
20
21
21
*[Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
22
22
23
-
## Run the Cloudformation template to create the Amazon DocumentDB Cluster and Client Amazon EC2 instance
23
+
## Deployment instructions
24
+
### Run the Cloudformation template to create the Amazon DocumentDB Cluster and Client Amazon EC2 instance
24
25
25
26
*[Run the Cloudformation template using the file DocumentDBAndMongoClientEC2.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 Cloudformation stack to be created. This CloudFormation template will create an Amazon DocumentDB cluster. It will also create an EC2 instance that you can use as a client.
26
27
@@ -34,7 +35,7 @@ The AWS SAM CLI is a serverless tool for building and testing Lambda application
34
35
*[Check if the database and cluster are available] - Once you are inside the EC2 instance, you should be in the /home/ec2-user folder. cd to the mongoshell folder and then run ./connect_to_mongo_shell.sh. This connects the mongosh tool to the Amazon DocumentDB cluster created by the CloudFormation template. Once inside the mongosh, you can issue commands like show dbs to see if the database was created, use <databasename> to switch to the created database, and then show collections to see if the collection was created. If you did not modify the defaults in the CloudFormation template, then the name of the database should be DocumentDBJavaLambdaDB and the name of the collection should be DocumentDBJavaLambdaCollection
35
36
36
37
37
-
## Pre-requisites to Deploy the sample Lambda function
38
+
###Pre-requisites to Deploy the sample Lambda function
38
39
39
40
* Java - On the EC2 machine, 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
40
41
* Maven - On the EC2 machine, we have installed Maven (https://maven.apache.org/install.html)
@@ -49,7 +50,7 @@ Change directory to the pattern directory:
49
50
cd serverless-patterns/documentdb-lambda-java-sam
50
51
```
51
52
52
-
## Use the SAM CLI to build and deploy the lambda function
53
+
###Use the SAM CLI to build and deploy the lambda function
53
54
54
55
Make sure you are connected to the EC2 instance as mentioned in the "Connect to the EC2 instance" step above
To deploy your application for the first time, run the following in your shell. Make sure the shell variable $AWS_REGION is set. If not, replace $AWS_REGION with the region in which you are deploying the AWS Lambda function:
@@ -120,7 +121,7 @@ The sam deploy command will package and deploy your application to AWS, with a s
120
121
***SAM configuration file [samconfig.toml]**: Name of the configuration file to store configuration information locally
121
122
***SAM configuration environment [default]**: Environment for storing deployment information locally
122
123
123
-
You should get a message "Successfully created/updated stack - <StackName> in <Region>" if all goes well
124
+
The message "Successfully created/updated stack - <StackName> in <Region>" indicates a successful deployment.
124
125
125
126
**Note: In case you want to deploy the Lambda function by pointing to an existing DocumentDB Cluster and not the one created by running the CloudFormation template provided in this pattern, you will need to modify the values of the above parameters accordingly**
126
127
@@ -198,4 +199,4 @@ sam delete
198
199
Confirm the delete by selecting Y at both prompts.
199
200
AWS SAM confirms the stack deletion with the "Deleted successfully" message in the terminal.
200
201
201
-
Next you need to delete the Amazon CloudFormation template containing the Amazon DocumentDB cluster and the Amazon EC2 instance. Open the Amazon CloudFormation console, select the stack, then choose Delete. The delete will take some time.
202
+
Next you need to delete the Amazon CloudFormation template containing the Amazon DocumentDB cluster and the Amazon EC2 instance. Open the Amazon CloudFormation console, select the stack, then choose Delete. The delete will take some time.
0 commit comments