Deploy an Amazon MQ broker and an AWS Lambda function that can publish to it. This project also includes a sample Node.js client application that can connect to the Amazon MQ broker and receive messages published by the Lambda function.
.
├── README.MD <-- This instructions file
├── src
│ └── PublishMessage <-- Source code for a lambda function
│ └── app.js <-- Lambda handler to publish messages to an MQTT endpoint on Amazon MQ
│ └── package.json <-- NodeJS dependencies and scripts
├── client-app
│ └── app.js <-- Node.js app to subscribe to messages from an MQTT endpoint on Amazon MQ
│ └── package.json <-- NodeJS dependencies and scripts
├── template.yaml <-- SAM template
- A Lambda function for publishing messages to Amazon MQ over MQTT.
- An Amazon MQ SINGLE_INSTANCE broker.
- AWS CLI already configured with Administrator permission
- NodeJS 8.10+ installed
- Create an AWS account if you do not already have one and login.
- Go to the app's page on the Serverless Application Repository and click "Deploy"
- Provide the required app parameters (see parameter details below) and click "Deploy"
- AdminUsername: (Required) A username for AmazonMQ console access.
- AdminPassword: (Required) A password for AmazonMQ console access. 12 characters and at least 4 unique characters.
- ClientUsername: (Required) A username for a client.
- ClientPassword: (Required) A password for a client. 12 characters and at least 4 unique characters.
To run the Node.js client-app run the following commands in the client-app directory in this repository. Replacing the arguments with credentials from your Amazon MQ broker.
npm install
node app.js "username" "password" "wss://endpoint:port" "some/topic"
Testing the Lambda function:
- Navigate to the AWS Lambda console and choose the newly created PublishMessage function.
- Create a test event.
- Run a test invocation.
- Messages published will appear in the console of the Node.js client-app.
==============================================
This library is licensed under the MIT-0 License. See the LICENSE file.