3 réponses
- Le plus récent
- Le plus de votes
- La plupart des commentaires
1
The only thing different in my CLI was this
{
"republish": {
"roleArn": "arn:aws:iam::795806302730:role/service-role/IoTRule_20220508_repost",
"topic": "datashow",
how do you create service roles?
répondu il y a 2 ans
0
This method worked fine. It appears that the JSON structure needs to be converted when republishing.(I don't know why.)
- Create republish rule
Entry | Value |
---|---|
ruleName | Republish |
sql | SELECT output.DeviceID as Device_ID, output.PayloadData.Battery as Battery, output.PayloadData.Sensor as Sensor, output.PayloadData.alt as Altitude, output.PayloadData.lat as Latitude, output.PayloadData.lon as Longitude, output.PayloadData.time as Time FROM 'lorawan/+/uplink' |
action | republish |
- Create insert to DynamoDB rule
Entry | Value |
---|---|
ruleName | SensorDB_rule |
sql | SELECT * FROM 'datashow' |
action | dynamoDB |
DynamoDB tableName | SensorDB |
DynamoDB operation | INSERT |
DynamoDB hashKeyField | DeviceID |
DynamoDB hashKeyValue | ${Device_ID} |
DynamoDB hashKeyType | STRING |
DynamoDB rangeKeyField | time |
DynamoDB rangeKeyValue | ${Time} |
DynamoDB rangeKeyType | STRING |
DynamoDB payloadField | payload |
The results of the AWS CLI output are left as evidence.
[cloudshell-user@ip-10-0-77-70 ~]$ aws iot list-topic-rules
{
"rules": [
{
"ruleArn": "arn:aws:iot:ap-northeast-1:795806302730:rule/SensorDB_rule",
"ruleName": "SensorDB_rule",
"topicPattern": "datashow",
"createdAt": "2022-05-08T09:15:52+00:00",
"ruleDisabled": false
},
{
"ruleArn": "arn:aws:iot:ap-northeast-1:795806302730:rule/Republish",
"ruleName": "Republish",
"topicPattern": "lorawan/+/uplink",
"createdAt": "2022-05-08T09:14:50+00:00",
"ruleDisabled": false
}
]
}
[cloudshell-user@ip-10-0-77-70 ~]$ aws iot get-topic-rule --rule-name SensorDB_rule
{
"ruleArn": "arn:aws:iot:ap-northeast-1:795806302730:rule/SensorDB_rule",
"rule": {
"ruleName": "SensorDB_rule",
"sql": "SELECT * FROM 'datashow'",
"description": "",
"createdAt": "2022-05-08T09:15:52+00:00",
"actions": [
{
"dynamoDB": {
"tableName": "SensorDB",
"roleArn": "arn:aws:iam::795806302730:role/service-role/IoTRule_20220508_repost",
"operation": "INSERT",
"hashKeyField": "DeviceID",
"hashKeyValue": "${Device_ID}",
"hashKeyType": "STRING",
"rangeKeyField": "time",
"rangeKeyValue": "${Time}",
"rangeKeyType": "STRING",
"payloadField": "payload"
}
}
],
"ruleDisabled": false,
"awsIotSqlVersion": "2016-03-23"
}
}
[cloudshell-user@ip-10-0-77-70 ~]$ aws iot get-topic-rule --rule-name Republish
{
"ruleArn": "arn:aws:iot:ap-northeast-1:795806302730:rule/Republish",
"rule": {
"ruleName": "Republish",
"sql": "SELECT output.DeviceID as Device_ID, output.PayloadData.Battery as Battery, output.PayloadData.Sensor as Sensor, output.PayloadData.alt as Altitude, output.PayloadData.lat as Latitude, output.PayloadData.lon as Longitude, output.PayloadData.time as Time FROM 'lorawan/+/uplink'",
"description": "",
"createdAt": "2022-05-08T09:14:50+00:00",
"actions": [
{
"republish": {
"roleArn": "arn:aws:iam::795806302730:role/service-role/IoTRule_20220508_repost",
"topic": "datashow",
"qos": 0
}
}
],
"ruleDisabled": false,
"awsIotSqlVersion": "2016-03-23"
}
}
[cloudshell-user@ip-10-0-77-70 ~]$
Thanks.
répondu il y a 2 ans
0
Sorry for the delay in confirmation. The service role was created in the management console.
[cloudshell-user@ip-10-1-1-158 ~]$ aws iam get-role --role-name IoTRule_20220508_repost
{
"Role": {
"Path": "/service-role/",
"RoleName": "IoTRule_20220508_repost",
"RoleId": "AROA3SSOAQIFJZM7UGIHM",
"Arn": "arn:aws:iam::795806302730:role/service-role/IoTRule_20220508_repost",
"CreateDate": "2022-05-08T08:55:10+00:00",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "iot.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"MaxSessionDuration": 3600,
"RoleLastUsed": {
"LastUsedDate": "2022-05-08T09:44:01+00:00",
"Region": "ap-northeast-1"
}
}
}
[cloudshell-user@ip-10-1-1-158 ~]$ aws iam list-attached-role-policies --role-name IoTRule_20220508_repost
{
"AttachedPolicies": [
{
"PolicyName": "AmazonDynamoDBFullAccess",
"PolicyArn": "arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
},
{
"PolicyName": "AWSIoTRuleActions",
"PolicyArn": "arn:aws:iam::aws:policy/service-role/AWSIoTRuleActions"
},
{
"PolicyName": "AWSIoTFullAccess",
"PolicyArn": "arn:aws:iam::aws:polic
répondu il y a 2 ans
Contenus pertinents
- demandé il y a un an
- demandé il y a 7 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 4 ans
I followed what you said and I am still not getting any data populating inside my table. I even checked my CLI to verify what you suggested. What do you mean by " JSON structure needs to be converted when republishing"