2

I am trying to create a CloudFormation for StepFunctions. I would like to pass the DefinitionString as a parameter. The json string is pretty big . The max cap is 4096 bytes. How do i handle to such cases where parameter is more than the upper cap . Sample template is given below

{
   "AWSTemplateFormatVersion" : "2010-09-09",
   "Description" : "An example template for a Step Functions state machine.",
   "Resources" : {
      "MyStateMachine" : {
         "Type" : "AWS::StepFunctions::StateMachine",
         "Properties" : {
            "StateMachineName" : "HelloWorld-StateMachine",
            "DefinitionString" : "{\"StartAt\": \"HelloWorld\", \"States\": {\"HelloWorld\": {\"Type\": \"Task\", \"Resource\": \"arn:aws:lambda:us-east-1:111122223333:function:HelloFunction\", \"End\": true}}}",
            "RoleArn" : "arn:aws:iam::111122223333:role/service-role/StatesExecutionRole-us-east-1"
         }
      }
   }
}
5
  • May I ask you why you want to pass the DefinitionString as a parameter? If you parametrize nearly everything it's indicator that you are doing/understand something wrong. The main benefit of AWS CloudFormation that you got your Infrastructure as Code Commented Jul 18, 2018 at 7:34
  • How do i version control the Definition string json . I would like to keep the definition json separately . If there is any change to definition , i would re run my CI set up and update the stack with the new json . Also keeping it separately gives me more readability . Pls let me know your thoughts . @MaiKaY Commented Jul 18, 2018 at 7:44
  • And what is about just putting the DefinitionString into your CloudFormation template? As soon as you want to change something, do it, commit/push it to your version control (e.g. git) and update your stack manually or automatically. I still don't see the reason putting it as a parameter... Commented Jul 18, 2018 at 9:34
  • Dont i have to stringify it and put it in the template . Wont it be easier to read the json format of it and make changes . Else ill have to take the string , un escape it and correct it . I still think it ll be too cluttered . let me know your thoughts Commented Jul 18, 2018 at 14:01
  • @BalajiV If the only issue is escaping JSON then you can just use YAML CloudFormation template with string literals. Example: stackoverflow.com/questions/49373039/… (look at State Machine definition) Commented Aug 23, 2018 at 18:29

1 Answer 1

1

If anyone else is struggling with the 4069 byte max, then you can upload the Step Function definition to a s3 bucket and use the DefinitionS3Location parameter instead.

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.