Posts

AWS IOT Thing Groups (Static VS Dynamic)

AWS IOT Thing Groups (Static VS Dynamic) Share AWS IOT Thing Group is a logical group of things to manage several things. There are two type of Thing Group supported by AWS IOT Core Static Thing Group:- A static Thing Group can contain the several things as well as other static group, the devices are added once can not be updated during any on going operation  Like OTA,  Dynamic Thing Group:- On the other hand Dynamic Thing group is a group where we can add multiple things by define a query condition.  Ex:-   During the OTA Update the list of devices are fixed if we create the OTA on Static Thing Group while if we pass a query to create a dynamic group like do OTA only on devices which is online.  Command to create a Static Group:- $ aws iot create-thing-group --thing-group-name TestStaticGroup Command to create a Dynamic Group:-   $ aws iot create-dynamic-thing-group --thing-group-name "RoomTooWarm" --query-string "attributes.temperature>60" C...

AWS IOT Create OTA With RollOut and Abort Configuration.

Image
  What is OTA? Over-the-air (OTA) Updated allows you to deploy update firmware updates on one or more devices in your fleet. Below is the bash command to create OTA. aws iot create-job \ --job-id "example-cli-job" \ --document file://IOTCore/jobDocument.json \ --description "Job test for dynamic group" \ --target-selection SNAPSHOT \ --job-executions-retry-config file://IOTCore/config/retries.json \ --job-executions-rollout-config file://IOTCore/config/rollout.json \ --abort-config file://IOTCore/config/abort.json \ --targets "arn:aws:iot:us-east-1:test_account_id:thinggroup/testdevices" You need a latest AWS Cli version for creating OTA with above given command (mine is 2.5.8). targets:-   Targets can be single Device, group of Devices Or Groups like Static and Dynamic Group.  retry-config:-   Retry config is a config on how failed devices should behave. Like below JSON i have used to retry 2 times on Failed OTA Update. It ...

Go-Lang Making API Gateway Call via login with AWS Cognito using AWS4 Signer

Go-Lang Making API Gateway Call via login with AWS Cognito using AWS4 Signer Share Below is the sample code to making AWS API Gateway call using AWS4 signer  package main import ( "bytes" "context" "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" "io/ioutil" "net/http" "time" ) // SignHTTP signs AWS v4 requests with the provided payload hash, service name, region the // request is made to, and time the request is signed at. The signTime allows // you to specify that a request is signed for the future, and cannot be // used until then. // // The payloadHash is the hex encoded SHA-256 hash of the request payload, and // must be provided. Even if the request has no payload (aka body). If the // request has no payload you should use the hex encoded SHA-256 of an empty // string as t...

Bash Script to Create Multiple AWS Things

 Prerequisites of creating multiple things at once. Proper aws cli setup. Certificate already created via IOT Core. You should have permission to create things via CLI. Below is the bash script to create multiple things and register via certificate. #! /bin/bash for i in {1..400} do aws iot create-thing --thing-type-name IF31 --thing-name PNR01ABC1000$i aws iot attach-thing-principal --principal $1 --thing-name PNR01ABC1000$i done Below is the command to run the above script considering file name is  createThing.sh bash ./createThings.sh arn_of_certificate The above script will create 400 devices and register on one certificate whos ARN is provided via CLI. Vishal Gupta Senior Technical Architect Sourcefuse Technologies 9811258678 vishal.gupta.sf@gmail.com Subscribe me on Youtube Linkedin

Download the List of All IOT Devices via AWS CLI AS CSV File Via Node JS

Image
Below is the script for downloading the list of all IOT Devices from the AWS via AWS CLI. You shoule have aws cli properly setup. Node Should be installed. Packages required for running the script are child_process fs Below script will download all things with Thing type name ABC1, assuming file name is  export.js "use strict"; const { exec } = require("child_process"); const fs = require("fs"); const byDevice = "ABC1"; const arr = [["Thing Name", "Thing Type", "Arn", "Version"]]; const command = "aws iot list-things --max-items 200 "; const exportThings = (NextToken) => { let command1 = command; if (byDevice.length > 0) { command1 += " --thing-type-name " + byDevice + " "; } if (NextToken) { command1 += " --starting-token " + NextToken; } console.log("Executing command :- " + command1); exec(command1, (erro...

Amazon App Flow

Image
Amazon AppFlow is a fully managed integration service that enables you to securely transfer data between Software-as-a-Service (SaaS) applications like Salesforce, SAP, Zendesk, Slack, and ServiceNow, and AWS services like Amazon S3 and Amazon Redshift, in just a few clicks. With AppFlow, you can run data flows at enterprise scale at the frequency you choose — on a schedule, in response to a business event, or on demand. You can configure data transformation capabilities like filtering and validation to generate rich, ready-to-use data as part of the flow itself, without additional steps. AppFlow automatically encrypts data in motion, and allows users to restrict data from flowing over the public Internet for SaaS applications that are integrated with AWS PrivateLink, reducing exposure to security threats. Integration of Salesforce with App Flow:- First we need to setup App Flow for which first we need to create a connector between Salesforce and AWS account. (For Connector we need a s...