0

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"
         }
      }
   }
}
MaiKaY
  • 4,422
  • 20
  • 28
Balaji V
  • 918
  • 3
  • 10
  • 28
  • 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](https://en.wikipedia.org/wiki/Infrastructure_as_Code) – MaiKaY Jul 18 '18 at 07: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 – Balaji V Jul 18 '18 at 07: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... – MaiKaY Jul 18 '18 at 09: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 – Balaji V Jul 18 '18 at 14:01
  • @BalajiV If the only issue is escaping JSON then you can just use YAML CloudFormation template with string literals. Example: https://stackoverflow.com/questions/49373039/managing-error-flow-in-aws-step-functions/49438440#49438440 (look at State Machine definition) – Marcin Sucharski Aug 23 '18 at 18:29

0 Answers0