class JsonPath
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.StepFunctions.JsonPath |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#JsonPath |
Java | software.amazon.awscdk.services.stepfunctions.JsonPath |
Python | aws_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
/**
* JSON state input:
* {
* "bucketName": "my-bucket",
* "prefix": "item"
* }
*/
const distributedMap = new sfn.DistributedMap(this, 'DistributedMap', {
itemReader: new sfn.S3ObjectsItemReader({
bucketNamePath: sfn.JsonPath.stringAt('$.bucketName'),
prefix: sfn.JsonPath.stringAt('$.prefix'),
}),
});
distributedMap.itemProcessor(new sfn.Pass(this, 'Pass'));
Properties
Name | Type | Description |
---|---|---|
static DISCARD | string | Special string value to discard state input, output or result. |
static entire | string | Use the entire context data structure. |
static entire | string | Use the entire data structure. |
static execution | string | Return the Execution Id field from the context object. |
static execution | string | Return the Execution Input field from the context object. |
static execution | string | Return the Execution Name field from the context object. |
static execution | string | Return the Execution RoleArn field from the context object. |
static execution | string | Return the Execution StartTime field from the context object. |
static state | string | Return the State EnteredTime field from the context object. |
static state | string | Return the StateMachine Id field from the context object. |
static state | string | Return the StateMachine Name field from the context object. |
static state | string | Return the State Name field from the context object. |
static state | string | Return the State RetryCount field from the context object. |
static task | string | Return 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
Name | Description |
---|---|
static array(...values) | Make an intrinsic States.Array expression. |
static array | Make an intrinsic States.ArrayContains expression. |
static array | Make an intrinsic States.ArrayGetItem expression. |
static array | Make an intrinsic States.ArrayLength expression. |
static array | Make an intrinsic States.ArrayPartition expression. |
static array | Make an intrinsic States.ArrayRange expression. |
static array | Make an intrinsic States.ArrayUnique expression. |
static base64 | Make an intrinsic States.Base64Decode expression. |
static base64 | 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 is | Determines if the indicated string is an encoded JSON path. |
static json | Make an intrinsic States.JsonMerge expression. |
static json | Make an intrinsic States.JsonToString expression. |
static list | Instead of using a literal string list, get the value from a JSON path. |
static math | Make an intrinsic States.MathAdd expression. |
static math | Make an intrinsic States.MathRandom expression. |
static number | Instead of using a literal number, get the value from a JSON path. |
static object | Reference a complete (complex) object in a JSON path location. |
static string | Instead of using a literal string, get the value from a JSON path. |
static string | Make an intrinsic States.StringSplit expression. |
static string | 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
Contains(array, value)
static arraypublic 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
GetItem(array, index)
static arraypublic 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
Length(array)
static arraypublic 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
Partition(array, chunkSize)
static arraypublic 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
Range(start, end, step)
static arraypublic 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
Unique(array)
static arraypublic 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
Decode(base64)
static base64public 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
Encode(input)
static base64public 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
EncodedJsonPath(value)
static ispublic static isEncodedJsonPath(value: string): boolean
Parameters
- value
string
— string to be evaluated.
Returns
boolean
Determines if the indicated string is an encoded JSON path.
Merge(value1, value2)
static jsonpublic 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
ToString(value)
static jsonpublic 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
At(path)
static listpublic static listAt(path: string): string[]
Parameters
- path
string
Returns
string[]
Instead of using a literal string list, get the value from a JSON path.
Add(num1, num2)
static mathpublic 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
Random(start, end)
static mathpublic 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
At(path)
static numberpublic static numberAt(path: string): number
Parameters
- path
string
Returns
number
Instead of using a literal number, get the value from a JSON path.
At(path)
static objectpublic static objectAt(path: string): IResolvable
Parameters
- path
string
Returns
Reference a complete (complex) object in a JSON path location.
At(path)
static stringpublic static stringAt(path: string): string
Parameters
- path
string
Returns
string
Instead of using a literal string, get the value from a JSON path.
Split(inputString, splitter)
static stringpublic 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
ToJson(jsonString)
static stringpublic static stringToJson(jsonString: string): IResolvable
Parameters
- jsonString
string
Returns
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