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

如何在EventBridge规则CloudFormation模板中指定AWS Batch作业的shareIdentifier

解决EventBridge触发Batch作业时shareIdentifier的配置问题

要在CloudFormation模板中为EventBridge触发的Batch作业指定shareIdentifier,你需要遵循以下配置方式:

  • 不要在BatchParameters中直接添加shareIdentifier/ShareIdentifier,该字段不在EventBridge Batch目标的官方属性定义中,会被判定为无效键。
  • 正确的方式是通过Input字段传递该参数,但必须保证JSON格式正确(禁止使用HTML转义字符),因为EventBridge会将Input中的顶层参数映射到Batch的SubmitJob API请求中。

正确配置示例

在你的EventBridge规则Target中,按如下方式配置:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyEventBridgeRule:
    Type: AWS::Events::Rule
    Properties:
      Description: 触发带shareIdentifier的Batch作业
      ScheduleExpression: "rate(1 minute)" # 替换为你的实际触发条件
      State: ENABLED
      Targets:
        - Arn: !Ref MyBatchJobQueue
          Id: "BatchJobTarget"
          BatchParameters:
            JobDefinition: !Ref MyBatchJobDefinition
            JobName: "MyScheduledJob"
            JobQueue: !Ref MyBatchJobQueue
          Input: |
            {
              "shareIdentifier": "mid",
              "parameters": {
                "your-job-param-1": "value1",
                "your-job-param-2": "value2"
              }
            }

关键说明

  1. JSON格式正确性:不要用"代替双引号,直接使用标准JSON语法,否则EventBridge无法正确解析参数。
  2. 参数层级:shareIdentifier需要作为Input的顶层键,和parameters(作业容器参数)同级,这样EventBridge会将其作为SubmitJob API的请求参数传递。
  3. 配合BatchParameters:BatchParameters中仍需指定JobDefinition、JobName和JobQueue,这些基础参数会和Input中的内容合并生成最终的SubmitJob请求。

如果上述配置仍不生效,可以尝试使用InputTransformer构造请求:

Targets:
  - Arn: !Ref MyBatchJobQueue
    Id: "BatchJobTarget"
    BatchParameters:
      JobDefinition: !Ref MyBatchJobDefinition
      JobName: "MyScheduledJob"
      JobQueue: !Ref MyBatchJobQueue
    InputTransformer:
      InputPathsMap: {}
      InputTemplate: |
        {
          "shareIdentifier": "mid",
          "parameters": <$>
        }

内容的提问来源于stack exchange,提问作者Jacob Kearney

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 00:01:20