Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverlose IoT-Applikationen

Serverlose IoT-Applikationen

Softwareentwickler sehen sich heutzutage mit einer Vielzahl von Anforderungen konfrontiert. Bereits das Verstehen der Domäne für die Implementierung der Geschäftslogik kann beliebig komplex werden. Hinzu kommen nun immer mehr Themen wie Skalierung und Ausfallsicherheit. Ganz zu schweigen von Benutzerauthentifizierung und -autorisierung oder Logging, Monitoring und Betrieb der Anwendung. Im IoT-Umfeld bereiten uns zusätzlich noch die Anbindung von Geräten über unsichere und instabile Verbindungen Kopfzerbrechen.

Andererseits bieten mittlerweile viele der großen Cloud-Plattformen zusätzlich zu Datenbanken und Messaging-Systemen auch ein reiches Portfolio an Diensten, die speziell auf die Bedürfnisse von IoT-Applikationen zugeschnitten sind. In Kombination mit serverlosen Funktionen lassen sich so bereits in einigen Tagen bis wenigen Wochen erste Konzepte praktisch erproben oder sogar komplett umsetzen. Darüber hinaus kann durch den Verzicht auf eigene Backend-Services ein Großteil der typischen Betriebsthemen entfallen.

Dieser Vortrag zeigt am Beispiel von Amazon Web Services (AWS), wie sich Geräte schnell und sicher an eine Cloud-Plattform anbinden lassen. Außerdem lernen die Teilnehmer, wie sie durch Kombination der vorhandenen Dienste und einiger weniger serverloser Funktionen zu einer produktiv einsetzbaren IoT-Applikation kommen.

Niko Will

June 19, 2018
Tweet

More Decks by Niko Will

Other Decks in Programming

Transcript

  1. 2 IoT Meetup Bodensee / Niko Will / serverless IoT-Applications

    „Reality eats plans for breakfast“ Niko Will
 senior consultant at innoQ Deutschland GmbH • Developer since 2005 • living in a Smarthome since 2012 • became an IoT Geek • worked on Bosch IoT Suite for 2 years • Senior Consultant at innoQ since 2017
  2. agenda 3 • microservices approach • AWS / Lambda &

    IoT • use-cases • JITR / on-boarding / pairing • list & search things / command & control / telemetry • connected / disconnected / LWT IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  3. 4 microservices approach IoT Meetup Bodensee / Niko Will /

    serverless IoT-Applications Source / http://www.unesourisetmoi.info/data/medias/photos/152/fond-ecran-chiots-adopter-gratuit-photos-2.jpg
  4. microservices approach 5 • fault tolerance • scalability • agility

    • visibility • security • cost-efficiency IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  5. microservices approach 6 IoT Meetup Bodensee / Niko Will /

    serverless IoT-Applications mobile client browser thing IoT-application API gateway MQTT Broker Analytics Users Devices Policies Rules ... database
  6. Service Discovery docker / kubernetes Devices Devices Devices Devices microservices

    approach 7 IoT Meetup Bodensee / Niko Will / serverless IoT-Applications microservices API gateway MQTT Broker Devices ... database IAM Message Broker HSM
  7. docker / kubernetes microservices approach 8 IoT Meetup Bodensee /

    Niko Will / serverless IoT-Applications microservices Devices operations (DevOps) logging monitoring alerting Alert Manager elasticsearch fluentd Kibana prometheus Grafana
  8. 9 microservices approach IoT Meetup Bodensee / Niko Will /

    serverless IoT-Applications Source / Hermann Zacher https://www.pictrs.com/logofoto
  9. 10 microservices approach IoT Meetup Bodensee / Niko Will /

    serverless IoT-Applications Source / http://rebrn.com/re/my-beagle-posing-with-its-kill-1304356/
  10. 11 AWS IoT Meetup Bodensee / Niko Will / serverless

    IoT-Applications Source / https://www.talheimer-beagle.de/
  11. Fast Data State 12 AWS IoT Meetup Bodensee / Niko

    Will / serverless IoT-Applications AWS Lambda AWS IoT Amazon API Gateway Amazon Cognito Amazon DynamoDB Amazon Elasticsearch Amazon S3 Amazon SQS Amazon SNS Amazon Kinesis
  12. 14 • Functions-as-a-Service (FaaS) • serverless • „small“ functions •

    stateless compute containers • event-driven AWS Lambda IoT Meetup Bodensee / Niko Will / serverless IoT-Applications Quelle / Vantage Data Centers
  13. 15 • scalable • pay-per-execution • no upfront capacity planning

    • significantly reduce operational costs AWS Lambda / advantages IoT Meetup Bodensee / Niko Will / serverless IoT-Applications Quelle / Vantage Data Centers
  14. 16 • vendor lock-in • startup latency • testing •

    debugging • execution duration AWS Lambda / disadvantages IoT Meetup Bodensee / Niko Will / serverless IoT-Applications Quelle / Vantage Data Centers
  15. Fast Data State 17 AWS IoT Meetup Bodensee / Niko

    Will / serverless IoT-Applications AWS Lambda AWS IoT Amazon API Gateway Amazon Cognito Amazon DynamoDB Amazon Elasticsearch Amazon S3 Amazon SQS Amazon SNS Amazon Kinesis
  16. AWS IoT 18 IoT Meetup Bodensee / Niko Will /

    serverless IoT-Applications
  17. 19 • managed service • message broker • rules engine

    • shadows • registry • security AWS IoT Quelle / https://blog.hackster.io/first-thoughts-on-the-pocketbeagle-83cea4fa92ea IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  18. message broker 20 • topic based • publish / subscribe

    topic wildcards • protocols MQTT MQTT + WebSockets HTTP $aws/events/presence/connected/clientId $aws/events/presence/disconnected/clientId $aws/things/thingName/shadow/update $aws/things/thingName/shadow/update/delta IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  19. rules engine 21 • SQL-like syntax • augument or filter

    data • rule actions state stores fast data pipelines CloudWatch Lambda republish SELECT *, newuuid() AS requestId, clientId() AS clientId, timestamp() AS timestamp, topic(2) AS deviceId, topic(4) AS sensorId FROM 'device/+/sensor/+/v1' WHERE temperature > 50 AND color <> 'red' IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  20. shadows 22 • JSON document • current state of thing

    • connection independent • supports client tokens • supports versioning • MQTT topics • RESTful API { "state" : { "desired" : { "color" : "RED" }, "reported" : { "color" : "GREEN" } }, "metadata" : { "desired" : { "color" : { "timestamp" : x }}, "reported" : { "color" : { "timestamp" : y }} }, "version" : 10, "clientToken" : "UniqueClientToken", "timestamp": 123456789 } IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  21. registry 23 • manage your things physical device or sensor

    logical entity • attributes • thing types { "version": 3, "thingName": "MyLightBulb", "defaultClientId": "MyLightBulb", "thingTypeName": "LightBulb", "attributes": { "model": "123", "wattage": "75" } } IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  22. security 24 • mutual authentication with X509 certificates + TLS

    1.2 or SigV4 for HTTPS and WebSockets • bring your own certificate JITR Atmel ECC508 • policy based access with dynamic values • role based rules action execution IoT Meetup Bodensee / Niko Will / serverless IoT-Applications
  23. just in time registration (JITR) 26 IoT Meetup Bodensee /

    Niko Will / serverless IoT-Applications AWS IoT thing IoT registry $aws/events/certificates/ registered/caCertificateID IoT rule AWS Lambda IoT policy
  24. on-boarding 27 IoT Meetup Bodensee / Niko Will / serverless

    IoT-Applications AWS IoT thing AWS Lambda IoT policy custom/clientId/register Amazon DynamoDB IoT device shadow IoT rule
  25. thing pairing 28 IoT Meetup Bodensee / Niko Will /

    serverless IoT-Applications thing AWS IoT mobile client AWS Lambda IoT device shadow IoT policy Amazon Cognito Amazon API Gateway exchange OAuth token for AWS credentials
  26. list & search things 29 IoT Meetup Bodensee / Niko

    Will / serverless IoT-Applications things AWS IoT mobile client AWS Lambda Amazon Cognito Amazon API Gateway Amazon DynamoDB
  27. command & control 30 IoT Meetup Bodensee / Niko Will

    / serverless IoT-Applications things AWS IoT mobile client AWS Lambda Amazon Cognito Amazon API Gateway IoT device shadow
  28. command & control 31 IoT Meetup Bodensee / Niko Will

    / serverless IoT-Applications things AWS IoT mobile client Amazon Cognito IoT device shadow
  29. 32 what’s about Alexa? 32 IoT Meetup Bodensee / Niko

    Will / serverless IoT-Applications
  30. command & control 33 IoT Meetup Bodensee / Niko Will

    / serverless IoT-Applications things AWS IoT mobile client Amazon Cognito IoT device shadow Amazon Echo AWS Lambda Alexa Skill
  31. telemetry 34 IoT Meetup Bodensee / Niko Will / serverless

    IoT-Applications things AWS IoT Amazon DynamoDB telemetry topic telemetry rule Amazon Kinesis Amazon EMR
  32. connected / disconnected / LWT 35 IoT Meetup Bodensee /

    Niko Will / serverless IoT-Applications things AWS IoT IoT device shadow shadow update topic { "state": { "reported": { "connected": true } } } { "state": { "reported": { "connected": true } } }
  33. { "state": { "reported": { "connected": true } } }

    { "state": { "reported": { "connected": false } } } connected / disconnected / LWT 36 IoT Meetup Bodensee / Niko Will / serverless IoT-Applications things AWS IoT IoT device shadow shadow update topic { "state": { "reported": { "connected": false } } }
  34. { "state": { "reported": { "connected": true } } }

    { "state": { "reported": { "connected": false } } } connected / disconnected / LWT 37 IoT Meetup Bodensee / Niko Will / serverless IoT-Applications things AWS IoT IoT device shadow LWT custom LWT topic IoT rule shadow update topic republish { "state": { "reported": { "connected": false } } }
  35. summary 38 • scalable plattform • common IoT use-cases •

    w/o own infrastructure • w/o upfront capacity planning • very secure • very extensible IoT Meetup Bodensee / Niko Will / serverless IoT-Applications