Skip to content

Instantly share code, notes, and snippets.

AWSIotData iotDataClient = AWSIotDataClientBuilder
.standard()
.withRegion(Regions.US_WEST_2)
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(CLIENT_TOKEN, CLIENT_SECRET))).build();
String thingName = "plant-manager";
GetThingShadowResult getThingShadowResult = iotDataClient.getThingShadow(new GetThingShadowRequest().withThingName(thingName));
String state = new String( getThingShadowResult.getPayload().array(), StandardCharsets.UTF_8);
// state is now a JSON string representing the plant-manager Thing Shadow's state
/* {
// Build an authenticated client object
// This pattern repeats from https://www.linkedin.com/pulse/sending-sms-from-java-aws-sns-steve-perkins
AWSIot iotClient = AWSIotClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(CLIENT_TOKEN, CLIENT_SECRET)))
.withRegion(Regions.US_WEST_2)
.build();
// Send the ListThingsRequest to AWS IoT synchronously
ListThingsResult result = iotClient.listThings(new ListThingsRequest());
package org.lightside.notification;
import java.util.HashMap;
import java.util.Map;
import org.lightside.main.AwsClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.services.sns.model.MessageAttributeValue;
package org.lightside.demo;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.iotdata.AWSIotData;
import com.amazonaws.services.iotdata.AWSIotDataClientBuilder;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.amazonaws.services.sns.AmazonSNSClient;