如何将输入传递给CloudFormation中的StepFunction目标的EventRule?

时间:2020-02-07 06:06:56

标签: amazon-web-services amazon-cloudformation pipeline aws-glue aws-step-functions

Parameters:
Bucket:
  Default: bucket_1
  Type: String
  AllowedValues:
   - bucket_1
   - bucket_2

Resources:
StepFunction:
  Type: 'AWS::StepFunctions::StateMachine'
  Properties:
   DefinitionString: |-
    {
        ...
    }
   RoleArn: ...
   StateMachineName: ...

EventRule:
  Type: 'AWS::Events::Rule'
  Properties:
      ScheduleExpression: cron(...)
      Targets:
        - RoleArn: ...
          Arn: !Ref StepFunction
          Id: "ScheduleStepFunction"
          InputTransformer:
            InputPathsMap:
              Bucket: !Ref Bucket
            InputTemplate: "{\"Bucket\": <Bucket>}"

我试图将名为Bucket的输入参数(在CloudFormation模板本身中定义为参数)传递给事件规则的StepFunction目标。

I get this error: InputPath for target ScheduleStepFunction is invalid.

Note: The optional parameter 'InputPath' has not been provided also.

1 个答案:

答案 0 :(得分:0)

Targets:
        - RoleArn: ...
          Arn: !Ref StepFunction
          Id: "ScheduleStepFunction"
          InputTransformer:
            InputPathsMap:
              Bucket: !Ref Bucket
            InputTemplate: "{\"Bucket\": <Bucket>}"

您的 Targets 似乎有问题,因为根据Amazon eventRule文档的建议,您的目标中没有提及 Input 。转到提供的链接以按照AWS UserGuide的建议在目标中使用Input。

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html