You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 08:25:32