能否在IoT规则SQL中动态设置条件?需修改YAML配置中的SQL条件
修改IoT规则SQL条件
要将IoT规则SQL语句中的条件从value > 30更新为value > 20,只需修改配置里Events.PutImageEvent.Properties.Sql字段的内容即可。以下是修改后的完整YAML配置:
NotifyTemperatureAlarm: Type: 'AWS::Serverless::Function' DependsOn: AlertSNSTopic Properties: CodeUri: src/notify_temperature_alarm/ Handler: app.lambda_handler Runtime: python3.9 Architectures: - x86_64 Events: PutImageEvent: Type: IoTRule Properties: Sql: Select * FROM 'device/temperature/alarms' where value > 20 Policies: Version: "2012-10-17" Statement: - Effect: Allow Action: "sns:*" Resource: "*" Environment: Variables: alert_sns: !Ref AlertSNSTopic
关键修改说明
- 定位到配置中
Events模块下的PutImageEvent规则配置 - 将
Sql字段里的条件值从30替换为20即可。注:配置里的>是HTML转义的大于号,也可以直接写value > 20,YAML能正常解析
内容的提问来源于stack exchange,提问作者Ahmed_ atya
相关产品推荐
相关产品推荐

