我正在尝试通过 CloudFormation 为 DynamoDB 更新添加 SNS 过滤器,但似乎后一个过滤器不支持 null,而我需要通过可空字段添加过滤器..
我的目标是仅获取 ParentId NOT NULL 的行的更新,我执行了以下操作:
SNSSubscription: Type: AWS::SNS::Subscription Properties: Protocol: sqs TopicArn: Fn::ImportValue: !Sub MyTopic Endpoint: !GetAtt MySQS.Arn RawMessageDelivery: true FilterPolicyScope: MessageBody FilterPolicy: { "Records": { "dynamodb": { "NewImage": { "parentId": { "S" : {"anything-but": [null]} } } } } }
虽然上面的语法绝对有效 CloudFormation 继续说
模板中不允许使用“null”值
有什么办法可以克服这个限制吗? 任何建议表示赞赏
你的语法没有意义,至少对于 DynamoDB 来说是这样。在 DynamoDB 中,不存在
null
字符串这样的东西,因为 null
是 DynamoDB 中的单独数据类型,不可能 null
任何其他数据类型。因此,如果您的模板可以工作,它的评估结果始终为 True
。
您可能会更好地利用
exists
匹配:
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html#eb-filtering-exists-matching