Skip to content

glassechidna/awsiot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Why

The AWS SDK for Go doesn't yet support bidirectional message sending for the AWS IoT service - see #706, #820, #1304. As such, I created a tiny library to fill the gap (at least as far as my needs extended) until AWS provides this support.

How

This library's usage is modelled on how AWS API clients are used in the official library. It should feel familiar to developers who have used those before. It returns a URL string, which can be used to initialise a client in the eclipse/paho.mqtt.golang MQTT library.

package main

import (
	MQTT "github.com/eclipse/paho.mqtt.golang"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
	"github.com/glassechidna/awsiot"
)

func main() {
	sessOpts := session.Options{
		SharedConfigState: session.SharedConfigEnable,
		AssumeRoleTokenProvider: stscreds.StdinTokenProvider,
	}

	sess := session.Must(session.NewSessionWithOptions(sessOpts))
	iot := awsiot.New(sess)
	theUrl, _ := iot.WebsocketUrl("a1kxjqeyezkt7")

	opts := MQTT.NewClientOptions().AddBroker(theUrl)
	opts.SetClientID("clientid")
	client := MQTT.NewClient(opts)
}

Releases

No releases published

Packages

No packages published

Languages