I know that I am missing something basic, but I'm really stuck trying to access the shadow shadow system on the AWS IOT platform.
I use the following code to create a new thing:
use Aws\Iot\IotClient; $thingName = '<string uuid>'; $awsIoTClient = new IotClient([ 'version' => 'latest', 'region' => <region>, 'credentials' => [ 'key' => <aws_access_key>, 'secret' => <aws_secret_key>, ] ]); $policyName = 'Global_Hub_Policy'; // # !--------------------------- // # !- Implementation // # !--------------------------- $result = $awsIoTClient->createThing([ 'thingName' => $thingName, ]); $result = $awsIoTClient->createKeysAndCertificate([ 'setAsActive' => TRUE, ]); $certArn = $result['certificateArn']; $certId = $result['certificateId']; $certPem = $result['certificatePem']; $privateKey = $result['keyPair']['PrivateKey']; $awsIoTClient->attachPrincipalPolicy([ 'policyName' => $policyName, 'principal' => $certArn ]); $awsIoTClient->attachThingPrincipal([ 'principal' => $certArn, 'thingName' => $thingName ]);
The above code successfully creates a thing. I see a thing created at startup:
$awsIoTClient->listThings();
Then, when I try to access the shadow tag with the following code:
Use Aws\IotDataPlane\IotDataPlaneClient; $client = new IotDataPlaneClient([ 'version' => 'latest', 'region' => <region>, 'credentials' => [ 'key' => <aws_access_key>, 'secret' => <aws_secret_key>, ] ]); $result = $client->getThingShadow([ 'thingName' => '<string uuid>',
I get the following error:
Aws\IotDataPlane\Exception\IotDataPlaneException: Error executing "GetThingShadow" on "https://data.iot.us-east-1.amazonaws.com/things/<string uuid>/shadow"; AWS HTTP error: Client error: 404 ResourceNotFoundException (client): No shadow exists with name: '<string uuid>' - {"message":"No shadow exists with name: '<string uuid>'","traceId":"<traceId>"} in Aws\WrappedHttpHandler->parseError() (line 152 of /<docroot>/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php).
Compatible things: The user whose access and secret keys are used to create this thing have the following AWS rules (we will block them as soon as we get this):
- AWSIoTLogging - AWSIoTConfigAccess - AWSIoTRuleActions - AWSIoTConfigReadOnlyAccess - AWSIoTDataAccess - AWSIoTFullAccess