interface CustomStateProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.StepFunctions.CustomStateProps |
Java | software.amazon.awscdk.services.stepfunctions.CustomStateProps |
Python | aws_cdk.aws_stepfunctions.CustomStateProps |
TypeScript (source) | @aws-cdk/aws-stepfunctions » CustomStateProps |
Properties for defining a custom state definition.
Example
import * as dynamodb from '@aws-cdk/aws-dynamodb';
// create a table
const table = new dynamodb.Table(this, 'montable', {
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},
});
const finalStatus = new sfn.Pass(this, 'final step');
// States language JSON to put an item into DynamoDB
// snippet generated from https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-code-snippet.html#tutorial-code-snippet-1
const stateJson = {
Type: 'Task',
Resource: 'arn:aws:states:::dynamodb:putItem',
Parameters: {
TableName: table.tableName,
Item: {
id: {
S: 'MyEntry',
},
},
},
ResultPath: null,
};
// custom state which represents a task to insert data into DynamoDB
const custom = new sfn.CustomState(this, 'my custom task', {
stateJson,
});
const chain = sfn.Chain.start(custom)
.next(finalStatus);
const sm = new sfn.StateMachine(this, 'StateMachine', {
definition: chain,
timeout: Duration.seconds(30),
});
// don't forget permissions. You need to assign them
table.grantWriteData(sm);
Properties
Name | Type | Description |
---|---|---|
state | { [string]: any } | Amazon States Language (JSON-based) definition of the state. |
stateJson
Type:
{ [string]: any }
Amazon States Language (JSON-based) definition of the state.