Giter Site home page Giter Site logo

aws-samples / aws-iot-cqrs-example Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 4.0 97 KB

Sample illustrating how to setup an IoT client to use a CQRS (Command Query Responsibility Segregation) architecture pattern. Demonstrating how CQRS can be used to separate request/reply and publish/wake up messages from update and status messages

License: MIT No Attribution

Makefile 2.74% JavaScript 20.13% Dockerfile 1.68% Python 34.38% TypeScript 41.07%
aws iot iot-cloud containers cdk cqrs cqrs-pattern

aws-iot-cqrs-example's Introduction

Implementing CQRS using AWS IoT and Amazon Elastic Container Service

Introduction

This sample app will illustrate how to setup an IoT client device to use a CQRS (Command Query Responsibility Segregation, see more on https://www.martinfowler.com/bliki/CQRS.html architecture pattern. The goal is to demonstrate the CQRS concept can be used to separate request/reply and publish/wake up messages from update and status messages which can be useful in a constraint battery powered device for use cases like Firmware updates, positioning monitoring, and weather climate measuring. AWS Service included are:

  • IoT Core
  • DynamoDB
  • Simple Queue Service (SQS)
  • Elastic Container Service (ECS)
  • Elastic Container Registry (ECR)
  • IAM
  • CDK (Cloud Development Kit)

diagram

Deplyoment

After you have cloned the repository in a terminal windown run: make init. Make sure Docker is installed and that the docker daemon is running. Deployment is performed by issuing: make deploy.

IoT Sample Client Setup

Lets start by activating the virtual environment that was created during the Deployment phase. This is done by running the following command in your terminal

cd iot_client
source venv/bin/activate

Some of common patterns for registering IoT devices with AWS IoT core are Just-In-Time Provisioning (JITP) or Just-In-Time Registration (JITR). Going through those patterns are not part of this sample demo so to create a "Thing", create and download certificate + private key, and to attach the policy for your sample client you can run this command:

python3 create_thing_and_cert.py --thingname <Optional, give a thing name, if not supplied it defaults to CQRS-Sample-Thing>

You can accomplish the same task as the script by going into the AWS console, go to IoT Core > Manage > Things. Then choose to create a Thing followed by choosing Security > Create Certificate then to Attach a Policy. The policy created by the CDK stack that you should select is called "sample-cqrs-iot-policy" Do the following steps to configure the IoT test client:

Start the Sample Client by running this command in the terminal:

python3 sample_client.py --deviceid <set a deviceid, default is SampleClient1>

Clean-up

In order to tear down all the AWS resources created in the CDK stack you must first de-attach and remove the certificate created in the setup step. This is done using the following command (make sure you are in the iot-client directory):

python3 delete_thing_and_cert.py

You can accomplish the same task as the script by going in to the AWS console, go to IoT Core > Secure > Certificates. Then delete the certificate generated during setup

Remove the AWS resources by issuing the follwing command from the top folder in a terminal window from project root: make destroy

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-iot-cqrs-example's People

Contributors

amazon-auto avatar dependabot[bot] avatar nicgoth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.