我的AWSIotTopic类中具有onMessage函数,该类在创建AWS IoT作业时启动AWS作业(侦听主题$ aws / things /%s / jobs / notify-next)。我无法从本地Java应用程序更改作业状态。当我将具有所有权限的策略附加到我的注册证书时,即:]
"Action": "*",
"Resource": "*"
我的应用程序可以工作,我可以更改工作状态。我必须添加哪些权限才能更改工作状态?
"Effect": "Allow",
"Action": [
"iot:UpdateJobExecution",
"iot:StartNextPendingJobExecution"
],
"Resource": "arn:aws:iot:eu-west-2:125960935295:thing/thingID"
}
以上权限不允许启动和更新作业
我解决了。必须将iot:Receive
之外的iot:Subscribe
添加到主题notify-next中。在设备上执行作业的所有权限:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "arn:aws:iot:<region>:<awsID>:topicfilter/$aws/things/<deviceID>/jobs/notify-next"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "arn:aws:iot:<region>:<awsID>:topic/$aws/things/<deviceID>/jobs/notify-next"
},
{
"Effect": "Allow",
"Action": "iot:Publish",
"Resource": "arn:aws:iot:<region>:<awsID>:topic/some"
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:<region>:<awsID>:client/<deviceID>"
},
{
"Effect": "Allow",
"Action": [
"iot:UpdateJobExecution",
"iot:StartNextPendingJobExecution"
],
"Resource": "arn:aws:iot:<region>:<awsID>:thing/<deviceID>"
}
]
}