github.com/aavshr/aws-sdk-go@v1.41.3/service/iotdataplane/endpoint_example_test.go (about)

     1  package iotdataplane_test
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  
     7  	"github.com/aavshr/aws-sdk-go/aws"
     8  	"github.com/aavshr/aws-sdk-go/aws/session"
     9  	"github.com/aavshr/aws-sdk-go/service/iot"
    10  	"github.com/aavshr/aws-sdk-go/service/iotdataplane"
    11  )
    12  
    13  func ExampleIoTDataPlane_describeEndpoint() {
    14  	sess, err := session.NewSession(aws.NewConfig())
    15  	if err != nil {
    16  		log.Fatal("Failed to create aws session", err)
    17  	}
    18  
    19  	// we need to use an IoT control plane client to get an endpoint address
    20  	ctrlSvc := iot.New(sess)
    21  	descResp, err := ctrlSvc.DescribeEndpoint(&iot.DescribeEndpointInput{})
    22  	if err != nil {
    23  		log.Fatal("failed to get dataplane endpoint", err)
    24  	}
    25  
    26  	// create a IoT data plane client using the endpoint address we retrieved
    27  	dataSvc := iotdataplane.New(sess, &aws.Config{
    28  		Endpoint: descResp.EndpointAddress,
    29  	})
    30  	output, err := dataSvc.GetThingShadow(&iotdataplane.GetThingShadowInput{
    31  		// specify a ThingName
    32  		ThingName: aws.String("fake-thing"),
    33  	})
    34  	// prints the string representation of GetThingShadowOutput
    35  	fmt.Println(output.GoString())
    36  }