Interface ICustomStateProps
Properties for defining a custom state definition.
Namespace: Amazon.CDK.AWS.StepFunctions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface ICustomStateProps
Syntax (vb)
Public Interface ICustomStateProps
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.DynamoDB;
// create a table
var table = new Table(this, "montable", new TableProps {
PartitionKey = new Attribute {
Name = "id",
Type = AttributeType.STRING
}
});
var finalStatus = new 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
IDictionary<string, object> stateJson = new Dictionary<string, object> {
{ "Type", "Task" },
{ "Resource", "arn:aws:states:::dynamodb:putItem" },
{ "Parameters", new Dictionary<string, object> {
{ "TableName", table.TableName },
{ "Item", new Dictionary<string, IDictionary<string, string>> {
{ "id", new Dictionary<string, string> {
{ "S", "MyEntry" }
} }
} }
} },
{ "ResultPath", null }
};
// custom state which represents a task to insert data into DynamoDB
var custom = new CustomState(this, "my custom task", new CustomStateProps {
StateJson = stateJson
});
// catch errors with addCatch
var errorHandler = new Pass(this, "handle failure");
custom.AddCatch(errorHandler);
// retry the task if something goes wrong
custom.AddRetry(new RetryProps {
Errors = new [] { Errors.ALL },
Interval = Duration.Seconds(10),
MaxAttempts = 5
});
var chain = Chain.Start(custom).Next(finalStatus);
var sm = new StateMachine(this, "StateMachine", new StateMachineProps {
DefinitionBody = DefinitionBody.FromChainable(chain),
Timeout = Duration.Seconds(30),
Comment = "a super cool state machine"
});
// don't forget permissions. You need to assign them
table.GrantWriteData(sm);
Synopsis
Properties
StateJson | Amazon States Language (JSON-based) definition of the state. |
Properties
StateJson
Amazon States Language (JSON-based) definition of the state.
IDictionary<string, object> StateJson { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>