我知道我在这里缺少一些基本的东西,但我真的很难在AWS IOT的平台上尝试访问一个东西.
我正在使用以下代码创建一个新的东西:
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' => …Run Code Online (Sandbox Code Playgroud)