aws-cdk-lib.aws_stepfunctions.JsonPath

class JsonPath

LanguageType name
.NETAmazon.CDK.AWS.StepFunctions.JsonPath
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#JsonPath
Javasoftware.amazon.awscdk.services.stepfunctions.JsonPath
Pythonaws_cdk.aws_stepfunctions.JsonPath
TypeScript (source)aws-cdk-lib » aws_stepfunctions » JsonPath

Extract a field from the State Machine data or context that gets passed around between states.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-paths.html

Example

const submitJobActivity = new sfn.Activity(this, 'SubmitJob');

new tasks.StepFunctionsInvokeActivity(this, 'Submit Job', {
  activity: submitJobActivity,
  parameters: {
    comment: 'Selecting what I care about.',
    MyDetails: {
      size: sfn.JsonPath.stringAt('$.product.details.size'),
      exists: sfn.JsonPath.stringAt('$.product.availability'),
      StaticValue: 'foo'
    },
  },
});

Properties

NameTypeDescription
static DISCARDstringSpecial string value to discard state input, output or result.
static entireContextstringUse the entire context data structure.
static entirePayloadstringUse the entire data structure.
static executionIdstringReturn the Execution Id field from the context object.
static executionInputstringReturn the Execution Input field from the context object.
static executionNamestringReturn the Execution Name field from the context object.
static executionRoleArnstringReturn the Execution RoleArn field from the context object.
static executionStartTimestringReturn the Execution StartTime field from the context object.
static stateEnteredTimestringReturn the State EnteredTime field from the context object.
static stateMachineIdstringReturn the StateMachine Id field from the context object.
static stateMachineNamestringReturn the StateMachine Name field from the context object.
static stateNamestringReturn the State Name field from the context object.
static stateRetryCountstringReturn the State RetryCount field from the context object.
static taskTokenstringReturn the Task Token field from the context object.

static DISCARD

Type: string

Special string value to discard state input, output or result.


static entireContext

Type: string

Use the entire context data structure.

Will be an object at invocation time, but is represented in the CDK application as a string.


static entirePayload

Type: string

Use the entire data structure.

Will be an object at invocation time, but is represented in the CDK application as a string.


static executionId

Type: string

Return the Execution Id field from the context object.


static executionInput

Type: string

Return the Execution Input field from the context object.

  • Will be an object at invocation time, but is represented in the CDK application as a string.

static executionName

Type: string

Return the Execution Name field from the context object.


static executionRoleArn

Type: string

Return the Execution RoleArn field from the context object.


static executionStartTime

Type: string

Return the Execution StartTime field from the context object.


static stateEnteredTime

Type: string

Return the State EnteredTime field from the context object.


static stateMachineId

Type: string

Return the StateMachine Id field from the context object.


static stateMachineName

Type: string

Return the StateMachine Name field from the context object.


static stateName

Type: string

Return the State Name field from the context object.


static stateRetryCount

Type: string

Return the State RetryCount field from the context object.


static taskToken

Type: string

Return the Task Token field from the context object.

External actions will need this token to report step completion back to StepFunctions using the SendTaskSuccess or SendTaskFailure calls.

Methods

NameDescription
static array(...values)Make an intrinsic States.Array expression.
static arrayContains(array, value)Make an intrinsic States.ArrayContains expression.
static arrayGetItem(array, index)Make an intrinsic States.ArrayGetItem expression.
static arrayLength(array)Make an intrinsic States.ArrayLength expression.
static arrayPartition(array, chunkSize)Make an intrinsic States.ArrayPartition expression.
static arrayRange(start, end, step)Make an intrinsic States.ArrayRange expression.
static arrayUnique(array)Make an intrinsic States.ArrayUnique expression.
static base64Decode(base64)Make an intrinsic States.Base64Decode expression.
static base64Encode(input)Make an intrinsic States.Base64Encode expression.
static format(formatString, ...values)Make an intrinsic States.Format expression.
static hash(data, algorithm)Make an intrinsic States.Hash expression.
static isEncodedJsonPath(value)Determines if the indicated string is an encoded JSON path.
static jsonMerge(value1, value2)Make an intrinsic States.JsonMerge expression.
static jsonToString(value)Make an intrinsic States.JsonToString expression.
static listAt(path)Instead of using a literal string list, get the value from a JSON path.
static mathAdd(num1, num2)Make an intrinsic States.MathAdd expression.
static mathRandom(start, end)Make an intrinsic States.MathRandom expression.
static numberAt(path)Instead of using a literal number, get the value from a JSON path.
static objectAt(path)Reference a complete (complex) object in a JSON path location.
static stringAt(path)Instead of using a literal string, get the value from a JSON path.
static stringSplit(inputString, splitter)Make an intrinsic States.StringSplit expression.
static stringToJson(jsonString)Make an intrinsic States.StringToJson expression.
static uuid()Make an intrinsic States.UUID expression.

static array(...values)

public static array(...values: string[]): string

Parameters

  • values string

Returns

  • string

Make an intrinsic States.Array expression.

Combine any number of string literals or JsonPath expressions into an array.

Use this function if the value of an array element directly has to come from a JSON Path expression (either the State object or the Context object).

If the array contains object literals whose values come from a JSON path expression, you do not need to use this function.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static arrayContains(array, value)

public static arrayContains(array: any, value: any): string

Parameters

  • array any
  • value any

Returns

  • string

Make an intrinsic States.ArrayContains expression.

Use this function to determine if a specific value is present in an array. For example, you can use this function to detect if there was an error in a Map state iteration.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static arrayGetItem(array, index)

public static arrayGetItem(array: any, index: number): string

Parameters

  • array any
  • index number

Returns

  • string

Make an intrinsic States.ArrayGetItem expression.

Use this function to get a specified index's value in an array.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static arrayLength(array)

public static arrayLength(array: any): string

Parameters

  • array any

Returns

  • string

Make an intrinsic States.ArrayLength expression.

Use this function to get the length of an array.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static arrayPartition(array, chunkSize)

public static arrayPartition(array: any, chunkSize: number): string

Parameters

  • array any
  • chunkSize number

Returns

  • string

Make an intrinsic States.ArrayPartition expression.

Use this function to partition a large array. You can also use this intrinsic to slice the data and then send the payload in smaller chunks.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static arrayRange(start, end, step)

public static arrayRange(start: number, end: number, step: number): string

Parameters

  • start number
  • end number
  • step number

Returns

  • string

Make an intrinsic States.ArrayRange expression.

Use this function to create a new array containing a specific range of elements. The new array can contain up to 1000 elements.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static arrayUnique(array)

public static arrayUnique(array: any): string

Parameters

  • array any

Returns

  • string

Make an intrinsic States.ArrayUnique expression.

Use this function to get the length of an array. Use this function to remove duplicate values from an array and returns an array containing only unique elements. This function takes an array, which can be unsorted, as its sole argument.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static base64Decode(base64)

public static base64Decode(base64: string): string

Parameters

  • base64 string

Returns

  • string

Make an intrinsic States.Base64Decode expression.

Use this function to decode data based on MIME Base64 decoding scheme. You can use this function to pass data to other AWS services without using a Lambda function.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static base64Encode(input)

public static base64Encode(input: string): string

Parameters

  • input string

Returns

  • string

Make an intrinsic States.Base64Encode expression.

Use this function to encode data based on MIME Base64 encoding scheme. You can use this function to pass data to other AWS services without using an AWS Lambda function.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static format(formatString, ...values)

public static format(formatString: string, ...values: string[]): string

Parameters

  • formatString string
  • values string

Returns

  • string

Make an intrinsic States.Format expression.

This can be used to embed JSON Path variables inside a format string.

For example:

sfn.JsonPath.format('Hello, my name is {}.', sfn.JsonPath.stringAt('$.name'))

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static hash(data, algorithm)

public static hash(data: any, algorithm: string): string

Parameters

  • data any
  • algorithm string

Returns

  • string

Make an intrinsic States.Hash expression.

Use this function to calculate the hash value of a given input. You can use this function to pass data to other AWS services without using a Lambda function.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static isEncodedJsonPath(value)

public static isEncodedJsonPath(value: string): boolean

Parameters

  • value string — string to be evaluated.

Returns

  • boolean

Determines if the indicated string is an encoded JSON path.


static jsonMerge(value1, value2)

public static jsonMerge(value1: any, value2: any): string

Parameters

  • value1 any
  • value2 any

Returns

  • string

Make an intrinsic States.JsonMerge expression.

Use this function to merge two JSON objects into a single object.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static jsonToString(value)

public static jsonToString(value: any): string

Parameters

  • value any

Returns

  • string

Make an intrinsic States.JsonToString expression.

During the execution of the Step Functions state machine, encode the given object into a JSON string.

For example:

sfn.JsonPath.jsonToString(sfn.JsonPath.objectAt('$.someObject'))

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static listAt(path)

public static listAt(path: string): string[]

Parameters

  • path string

Returns

  • string[]

Instead of using a literal string list, get the value from a JSON path.


static mathAdd(num1, num2)

public static mathAdd(num1: number, num2: number): string

Parameters

  • num1 number
  • num2 number

Returns

  • string

Make an intrinsic States.MathAdd expression.

Use this function to return the sum of two numbers. For example, you can use this function to increment values inside a loop without invoking a Lambda function.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static mathRandom(start, end)

public static mathRandom(start: number, end: number): string

Parameters

  • start number
  • end number

Returns

  • string

Make an intrinsic States.MathRandom expression.

Use this function to return a random number between the specified start and end number. For example, you can use this function to distribute a specific task between two or more resources.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static numberAt(path)

public static numberAt(path: string): number

Parameters

  • path string

Returns

  • number

Instead of using a literal number, get the value from a JSON path.


static objectAt(path)

public static objectAt(path: string): IResolvable

Parameters

  • path string

Returns

  • IResolvable

Reference a complete (complex) object in a JSON path location.


static stringAt(path)

public static stringAt(path: string): string

Parameters

  • path string

Returns

  • string

Instead of using a literal string, get the value from a JSON path.


static stringSplit(inputString, splitter)

public static stringSplit(inputString: string, splitter: string): string

Parameters

  • inputString string
  • splitter string

Returns

  • string

Make an intrinsic States.StringSplit expression.

Use this function to split a string into an array of values. This function takes two arguments.The first argument is a string and the second argument is the delimiting character that the function will use to divide the string.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static stringToJson(jsonString)

public static stringToJson(jsonString: string): IResolvable

Parameters

  • jsonString string

Returns

  • IResolvable

Make an intrinsic States.StringToJson expression.

During the execution of the Step Functions state machine, parse the given argument as JSON into its object form.

For example:

sfn.JsonPath.stringToJson(sfn.JsonPath.stringAt('$.someJsonBody'))

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html


static uuid()

public static uuid(): string

Returns

  • string

Make an intrinsic States.UUID expression.

Use this function to return a version 4 universally unique identifier (v4 UUID) generated using random numbers. For example, you can use this function to call other AWS services or resources that need a UUID parameter or insert items in a DynamoDB table.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html