Amazon web services boto3物联网数据发布消息未接收
我试图通过python Lambda函数将消息发布到AWS IoT 我已在IoT控制台上订阅了一个主题(“测试”),并触发了该功能,消息无法传递 Python代码段:Amazon web services boto3物联网数据发布消息未接收,amazon-web-services,aws-lambda,boto3,aws-iot,Amazon Web Services,Aws Lambda,Boto3,Aws Iot,我试图通过python Lambda函数将消息发布到AWS IoT 我已在IoT控制台上订阅了一个主题(“测试”),并触发了该功能,消息无法传递 Python代码段: iot = boto3.client('iot-data','eu-west-1') res = { "message" : "Hello!" } iot.publish( topic='test', //do we need to pass the thing name here?
iot = boto3.client('iot-data','eu-west-1') res = {
"message" : "Hello!"
}
iot.publish(
topic='test', //do we need to pass the thing name here?
qos=0,
payload=json.dumps(res))
物联网政策:
{ "Version": "2012-10-17", "Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
} ] }
此外,我已为lambda函数分配了正确的IAM权限,以发布到IoT
非常感谢您能帮我找到正确的方向 我发现,我的lambda功能部署在VPC子网中,没有互联网连接。创建了一个NAT网关,现在子网可以通过它访问internet 注意:要将消息发布到IoT(MQTT),需要互联网连接