I'm creating a Cloudwatch Event Rule that is supposed to trigger a lambda if the Step Function enters a failure or time out state. The cloud watch event rule will pass parameters to the lambda which will send out a custom SNS email. I'm trying to pass the values for the input parameters into the Cloudwatch Event Rule from parameters I have setup in my Cloudformation template. I can't get Cloudformation to pull the parameter values out put them into the Cloudwatch Event Rule Input parameter. CF takes the literal values I'm giving it in JSON and putting that into the Cloudwatch Event rule. I'm using a YAML template with a JSON parameter file. Posting the code below.
FailureEvent:
Type: AWS::Events::Rule
DependsOn:
- StateMachine
Properties:
Description: !Ref FailureRuleDescription
Name: !Ref FailureRuleName
EventPattern:
detail-type:
- "Step Functions Execution Status Change"
detail:
status:
- "FAILED"
- "TIMED_OUT"
stateMachineArn: [!Ref StateMachine]
Targets:
- Arn:
'Fn::Join': ["", ['arn:aws:lambda:', !Ref 'AWS::Region', ':', !Ref 'AWS::AccountId', ':function:', !Ref FailureLambda]]
Id: !Ref FailureLambda
Input: '{"failed_service": "!Ref StateMachineName","sns_arn": {"Fn::Join":[":",["arn: aws: sns",{"Ref": "AWS: : Region"},{"Ref": "AWS::AccountId"},{"Ref": "SNSTopic"}]]}}'