Search code examples
amazon-web-servicesaws-step-functionsserverless-framework-step-functions

AWS Step Functions: Input Parameter


I have a very simple workflow using Fargate containers. The containers simply return inputs. Workflow Input is:

    {
      "value": "FALSE"
    }
  1. Choice operates as expected. $.value is processed as FALSE and choice runs the ECS RunTask-FALSE container.
  2. The container should receive and return the string "FALSE", however it returns the string "*.value". For some reason the Input value is not being parsed. When I look at the Task run in ECS portal I see:

enter image description here

How can I pass the starting parameter to this Task ?

{
    "Comment": "A description of my state machine",
    "StartAt": "Choice",
    "States": {
        "Choice": {
            "Type": "Choice",
            "Choices": [
                {
                    "Variable": "$.value",
                    "StringEquals": "FALSE",
                    "Next": "ECS RunTask-FALSE"
                }
            ],
            "Default": "ECS RunTask-TRUE"
        },
        "ECS RunTask-FALSE": {
            "Type": "Task",
            "Resource": "arn:aws:states:::ecs:runTask.sync",
            "Parameters": {
                "LaunchType": "FARGATE",
                "Cluster": "arn:aws:ecs:us-east-2:xxxxxxxxxxx:cluster/portal",
                "TaskDefinition": "arn:aws:ecs:us-east-2:xxxxxxxxxxx:task-definition/simple:4",
                "Overrides": {
                    "ContainerOverrides": [
                        {
                            "Name": "simple",
                            "Command": ["$.value"]
                        }
                    ]
                },
                "NetworkConfiguration": {
                    "AwsvpcConfiguration": {
                        "Subnets": [
                            "subnet-001f85595e8af43cf",
                            "subnet-05e742358ac59ae04"
                        ],
                        "SecurityGroups": [
                            "sg-0948e5328861ae667"
                        ],
                        "AssignPublicIp": "ENABLED"
                    }
                }
            },
            "End": true
        },
        "ECS RunTask-TRUE": {
            "Type": "Task",
            "Resource": "arn:aws:states:::ecs:runTask.sync",
            "Parameters": {
                "LaunchType": "FARGATE",
                "Cluster": "arn:aws:ecs:us-east-2:xxxxxxxxxxx:cluster/portal",
                "TaskDefinition": "arn:aws:ecs:us-east-2:xxxxxxxxxxx:task-definition/simple:4",
                "NetworkConfiguration": {
                    "AwsvpcConfiguration": {
                        "Subnets": [
                            "subnet-001f85595e8af43cf",
                            "subnet-05e742358ac59ae04"
                        ],
                        "SecurityGroups": [
                            "sg-0948e5328861ae667"
                        ],
                        "AssignPublicIp": "ENABLED"
                    }
                }
            },
            "End": true
        }
    }
}

Solution

  • "Command.$": "States.Array($.value)"
    

    Parameters: For key-value pairs where the value is selected using a path, the key name must end in .$.

    States.Array Intrinsic Function: The interpreter returns a JSON array containing the values of the arguments in the order provided.