EventBridge管道CloudFormation配置InputTemplate报错求助
解决EventBridge Pipe CloudFormation配置中InputTemplate变量报错问题
问题分析
在控制台使用<aws.pipes.event.json>预定义变量可正常解析SQS输入,但CloudFormation配置时触发Invalid json path reference or predefined variable for placeholder number 1错误,核心原因是YAML语法中<和>属于特殊标签字符,直接书写会被CloudFormation错误解析,无法识别为预定义变量。
解决方案
修改CloudFormation中InputTemplate的写法,用引号包裹预定义变量,避免YAML解析干扰:
Pipe: Type: AWS::Pipes::Pipe Properties: Name: some name RoleArn: a role Source: queue SourceParameters: SqsQueueParameters: BatchSize: 1 Target: state machine TargetParameters: InputTemplate: "<aws.pipes.event.json>" StepFunctionStateMachineParameters: InvocationType: FIRE_AND_FORGET
补充说明
- 若目标服务(如Step Functions)仅需使用SQS消息的
body内容(而非完整SQS事件结构),可将预定义变量替换为<aws.pipes.event.body>:InputTemplate: "<aws.pipes.event.body>" - 当
BatchSize > 1时,如需提取批量消息中的单条数据,可使用JSONPath语法,例如取第一条消息的完整结构:InputTemplate: "<aws.pipes.event[0].json>"
内容的提问来源于stack exchange,提问作者Josee
相关产品推荐
相关产品推荐

