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

April 13, 2018
Tweet

More Decks by Niko Will

Other Decks in Programming

Transcript

  1. 2 code.talks commerce special 2018 / 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 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  3. 4 microservices approach code.talks commerce special 2018 / 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 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  5. microservices approach 6 code.talks commerce special 2018 / 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 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications microservices API gateway MQTT Broker Devices ... database IAM Message Broker HSM
  7. docker / kubernetes microservices approach 8 code.talks commerce special 2018

    / Niko Will / serverless IoT-Applications microservices Devices operations (DevOps) logging monitoring alerting Alert Manager elasticsearch fluentd Kibana prometheus Grafana
  8. 9 microservices approach code.talks commerce special 2018 / Niko Will

    / serverless IoT-Applications Source / Hermann Zacher https://www.pictrs.com/logofoto
  9. 10 microservices approach code.talks commerce special 2018 / Niko Will

    / serverless IoT-Applications Source / http://rebrn.com/re/my-beagle-posing-with-its-kill-1304356/
  10. 11 AWS code.talks commerce special 2018 / Niko Will /

    serverless IoT-Applications Source / https://www.talheimer-beagle.de/
  11. Fast Data State 12 AWS code.talks commerce special 2018 /

    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 code.talks commerce special 2018 / 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 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications Quelle / Vantage Data Centers
  14. 16 • vendor lock-in • startup latency • testing •

    debugging • execution duration AWS Lambda / disadvantages code.talks commerce special 2018 / Niko Will / serverless IoT-Applications Quelle / Vantage Data Centers
  15. Fast Data State 17 AWS code.talks commerce special 2018 /

    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. 19 • managed service • message broker • rules engine

    • shadows • registry • security AWS IoT Quelle / https://blog.hackster.io/first-thoughts-on-the-pocketbeagle-83cea4fa92ea code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  17. 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 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  18. 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' code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  19. 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 } code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  20. 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" } } code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  21. 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 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications
  22. just in time registration (JITR) 26 code.talks commerce special 2018

    / Niko Will / serverless IoT-Applications AWS IoT thing IoT registry $aws/events/certificates/ registered/caCertificateID IoT rule AWS Lambda IoT policy
  23. on-boarding 27 code.talks commerce special 2018 / Niko Will /

    serverless IoT-Applications AWS IoT thing AWS Lambda IoT policy custom/clientId/register Amazon DynamoDB IoT device shadow IoT rule
  24. thing pairing 28 code.talks commerce special 2018 / 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
  25. list & search things 29 code.talks commerce special 2018 /

    Niko Will / serverless IoT-Applications things AWS IoT mobile client AWS Lambda Amazon Cognito Amazon API Gateway Amazon DynamoDB
  26. command & control 30 code.talks commerce special 2018 / Niko

    Will / serverless IoT-Applications things AWS IoT mobile client AWS Lambda Amazon Cognito Amazon API Gateway IoT device shadow
  27. command & control 31 code.talks commerce special 2018 / Niko

    Will / serverless IoT-Applications things AWS IoT mobile client Amazon Cognito IoT device shadow
  28. 32 what’s about Alexa? 32 code.talks commerce special 2018 /

    Niko Will / serverless IoT-Applications
  29. command & control 33 code.talks commerce special 2018 / Niko

    Will / serverless IoT-Applications things AWS IoT mobile client Amazon Cognito IoT device shadow Amazon Echo AWS Lambda Alexa Skill
  30. telemetry 34 code.talks commerce special 2018 / Niko Will /

    serverless IoT-Applications things AWS IoT Amazon DynamoDB telemetry topic telemetry rule Amazon Kinesis Amazon EMR
  31. connected / disconnected / LWT 35 code.talks commerce special 2018

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

    { "state": { "reported": { "connected": false } } } connected / disconnected / LWT 36 code.talks commerce special 2018 / Niko Will / serverless IoT-Applications things AWS IoT IoT device shadow shadow update topic { "state": { "reported": { "connected": false } } }
  33. { "state": { "reported": { "connected": true } } }

    { "state": { "reported": { "connected": false } } } connected / disconnected / LWT 37 code.talks commerce special 2018 / 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 } } }
  34. summary 38 • scalable plattform • common IoT use-cases •

    w/o own infrastructure • w/o upfront capacity planning • very secure • very extensible code.talks commerce special 2018 / Niko Will / serverless IoT-Applications