Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a Scheduled Rule from CloudWatch for a Lambda State Function Set

I want to use CloudFormation to create a stack of preexisting Lambda Functions into a State Machine using Step Functions on a schedule (30 mins). I have successfully created the stack for my other methods.

In essence, I need help or guidance on how to create a scheduled event in CloudFormation for Step Functions. Here is what I have been trying:

"NOTDScheduler": {
        "Type": "AWS::Events::Rule",
        "Properties": {
            "Description": "Schedules a NOTD every 30 minutes",
            "ScheduleExpression": "rate(30 minutes)",
            "State": "ENABLED",
            "Targets": [
                {
                    "Arn": "${statemachineARN}",
                    "statemachineARN": {
                        "Fn::GetAtt": [
                            "NOTDStateMachine",
                            "Arn"
                        ]
                    },
                    "Id": "NOTDScheduleTarget"
                }
            ]
        },

But I keep getting errors such as

[Error] /Resources/NOTDScheduler/Properties/Targets/0/statemachineARN/Fn::GetAtt: Resource type AWS::StepFunctions::StateMachine does not support attribute {Arn}.

and have no clue how Arn isnt a supported attribute. Is there a workaround?

like image 508
J. Amdoe Avatar asked Jun 13 '17 15:06

J. Amdoe


Video Answer


1 Answers

To get the ARN of a AWS::StepFunctions::StateMachine resource you need to call !Ref NOTDStateMachine instead of !GetAtt NOTDStateMachine.Arn

Check Return Values here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html

like image 103
MaiKaY Avatar answered Sep 23 '22 19:09

MaiKaY