awsiot

package module
v0.0.0-...-3b4e87a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

README

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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AwsIot

type AwsIot struct {
	// contains filtered or unexported fields
}

func New

func New(p client.ConfigProvider, cfgs ...*aws.Config) *AwsIot

func (*AwsIot) WebsocketUrl

func (a *AwsIot) WebsocketUrl(endpoint string) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL