StateMachine L2 construct
Define a StepFunctions State Machine.
Example
import * as stepfunctions from 'aws-cdk-lib/aws-stepfunctions';
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const inputArtifact = new codepipeline.Artifact();
const startState = new stepfunctions.Pass(this, 'StartState');
const simpleStateMachine = new stepfunctions.StateMachine(this, 'SimpleStateMachine', {
definition: startState,
});
const stepFunctionAction = new codepipeline_actions.StepFunctionInvokeAction({
actionName: 'Invoke',
stateMachine: simpleStateMachine,
stateMachineInput: codepipeline_actions.StateMachineInput.filePath(inputArtifact.atPath('assets/input.json')),
});
pipeline.addStage({
stageName: 'StepFunctions',
actions: [stepFunctionAction],
});
import aws_cdk.aws_stepfunctions as stepfunctions
pipeline = codepipeline.Pipeline(self, "MyPipeline")
input_artifact = codepipeline.Artifact()
start_state = stepfunctions.Pass(self, "StartState")
simple_state_machine = stepfunctions.StateMachine(self, "SimpleStateMachine",
definition=start_state
)
step_function_action = codepipeline_actions.StepFunctionInvokeAction(
action_name="Invoke",
state_machine=simple_state_machine,
state_machine_input=codepipeline_actions.StateMachineInput.file_path(input_artifact.at_path("assets/input.json"))
)
pipeline.add_stage(
stage_name="StepFunctions",
actions=[step_function_action]
)
import software.amazon.awscdk.services.stepfunctions.*;
Pipeline pipeline = new Pipeline(this, "MyPipeline");
Artifact inputArtifact = new Artifact();
Pass startState = new Pass(this, "StartState");
StateMachine simpleStateMachine = StateMachine.Builder.create(this, "SimpleStateMachine")
.definition(startState)
.build();
StepFunctionInvokeAction stepFunctionAction = StepFunctionInvokeAction.Builder.create()
.actionName("Invoke")
.stateMachine(simpleStateMachine)
.stateMachineInput(StateMachineInput.filePath(inputArtifact.atPath("assets/input.json")))
.build();
pipeline.addStage(StageOptions.builder()
.stageName("StepFunctions")
.actions(List.of(stepFunctionAction))
.build());
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.StepFunctions;
var pipeline = new Pipeline(this, "MyPipeline");
var inputArtifact = new Artifact();
var startState = new Pass(this, "StartState");
var simpleStateMachine = new StateMachine(this, "SimpleStateMachine", new StateMachineProps {
Definition = startState
});
var stepFunctionAction = new StepFunctionInvokeAction(new StepFunctionsInvokeActionProps {
ActionName = "Invoke",
StateMachine = simpleStateMachine,
StateMachineInput = StateMachineInput.FilePath(inputArtifact.AtPath("assets/input.json"))
});
pipeline.AddStage(new StageOptions {
StageName = "StepFunctions",
Actions = new [] { stepFunctionAction }
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
pipeline := codepipeline.NewPipeline(this, jsii.String("MyPipeline"))
inputArtifact := codepipeline.NewArtifact()
startState := stepfunctions.NewPass(this, jsii.String("StartState"))
simpleStateMachine := stepfunctions.NewStateMachine(this, jsii.String("SimpleStateMachine"), &StateMachineProps{
Definition: startState,
})
stepFunctionAction := codepipeline_actions.NewStepFunctionInvokeAction(&StepFunctionsInvokeActionProps{
ActionName: jsii.String("Invoke"),
StateMachine: simpleStateMachine,
StateMachineInput: codepipeline_actions.StateMachineInput_FilePath(inputArtifact.AtPath(jsii.String("assets/input.json"))),
})
pipeline.AddStage(&StageOptions{
StageName: jsii.String("StepFunctions"),
Actions: []IAction{
stepFunctionAction,
},
})
Initializer
new StateMachine(scope: Construct, id: string, props: StateMachineProps)
StateMachine(scope: Construct, id: str, props: StateMachineProps)
new StateMachine(Construct scope, String id, StateMachineProps props)
new StateMachine(Construct scope, string id, StateMachineProps props)
NewStateMachine(Scope Construct, Id *string, Props StateMachineProps)
Construct Props
definitionIChainabledefinitionIChainabledefinitionIChainableDefinitionIChainableDefinitionIChainabledeprecated#definitionBodyDefinitionBodydefinition_bodyDefinitionBodydefinitionBodyDefinitionBodyDefinitionBodyDefinitionBodyDefinitionBodyDefinitionBody#definitionSubstitutions{ [key: string]: string }definition_substitutionstyping.Mapping[str, str]definitionSubstitutionsMap<String, String>DefinitionSubstitutionsIDictionary<string, string>DefinitionSubstitutions*map[string]*string#encryptionConfigurationEncryptionConfigurationencryption_configurationEncryptionConfigurationencryptionConfigurationEncryptionConfigurationEncryptionConfigurationEncryptionConfigurationEncryptionConfigurationEncryptionConfiguration= data is transparently encrypted …#default
Default: data is transparently encrypted using an AWS owned key
queryLanguageQueryLanguagequery_languageQueryLanguagequeryLanguageQueryLanguageQueryLanguageQueryLanguageQueryLanguageQueryLanguage= JSON_PATH#If the state does not contain a queryLanguage field, then it will use the query language specified in this queryLanguage field.
removalPolicyRemovalPolicyremoval_policyRemovalPolicyremovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicy= RemovalPolicy.DESTROY#stateMachineNamestringstate_machine_namestrstateMachineNameStringStateMachineNamestringStateMachineName*string= A name is automatically generate…#default
Default: A name is automatically generated
stateMachineTypeStateMachineTypestate_machine_typeStateMachineTypestateMachineTypeStateMachineTypeStateMachineTypeStateMachineTypeStateMachineTypeStateMachineType= StateMachineType.STANDARD#tracingEnabledbooleantracing_enabledbooltracingEnabledBooleanTracingEnabledboolTracingEnabled*bool= false#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipalrequired#grantsStateMachineGrantsgrantsStateMachineGrantsgrantsStateMachineGrantsGrantsStateMachineGrantsGrantsStateMachineGrantsrequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#stateMachineArnstringstate_machine_arnstrstateMachineArnStringStateMachineArnstringStateMachineArn*stringrequired#stateMachineNamestringstate_machine_namestrstateMachineNameStringStateMachineNamestringStateMachineName*stringrequired#stateMachineRefStateMachineReferencestate_machine_refStateMachineReferencestateMachineRefStateMachineReferenceStateMachineRefStateMachineReferenceStateMachineRefStateMachineReferencerequired#stateMachineRevisionIdstringstate_machine_revision_idstrstateMachineRevisionIdStringStateMachineRevisionIdstringStateMachineRevisionId*stringrequired#stateMachineTypeStateMachineTypestate_machine_typeStateMachineTypestateMachineTypeStateMachineTypeStateMachineTypeStateMachineTypeStateMachineTypeStateMachineTyperequired#Methods
addToRolePolicy(statement: PolicyStatement): voiddef add_to_role_policy(self, statement: PolicyStatement) -> Nonepublic void addToRolePolicy(PolicyStatement statement)public void AddToRolePolicy(PolicyStatement statement)func AddToRolePolicy(Statement PolicyStatement)#applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromStateMachineArn(scope: Construct, id: string, stateMachineArn: string): IStateMachine@staticmethod def from_state_machine_arn(scope: Construct, id: str, state_machine_arn: str) -> IStateMachinepublic static IStateMachine fromStateMachineArn(Construct scope, String id, String stateMachineArn)public static IStateMachine FromStateMachineArn(Construct scope, string id, string stateMachineArn)func FromStateMachineArn(Scope Construct, Id *string, StateMachineArn *string) IStateMachinestatic#fromStateMachineName(scope: Construct, id: string, stateMachineName: string): IStateMachine@staticmethod def from_state_machine_name(scope: Construct, id: str, state_machine_name: str) -> IStateMachinepublic static IStateMachine fromStateMachineName(Construct scope, String id, String stateMachineName)public static IStateMachine FromStateMachineName(Construct scope, string id, string stateMachineName)func FromStateMachineName(Scope Construct, Id *string, StateMachineName *string) IStateMachinestatic#grant(identity: IGrantable, ...actions: string[]): Grantdef grant(self, identity: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable identity, String actions)public Grant Grant(IGrantable identity, string actions)func Grant(Identity IGrantable, Actions *string) Grant#[disable-awslint:no-grants]
grantExecution(identity: IGrantable, ...actions: string[]): Grantdef grant_execution(self, identity: IGrantable, actions: str) -> Grantpublic Grant grantExecution(IGrantable identity, String actions)public Grant GrantExecution(IGrantable identity, string actions)func GrantExecution(Identity IGrantable, Actions *string) Grant#The use of this method is discouraged. Please use grants.execution() instead.
[disable-awslint:no-grants]
grantRead(identity: IGrantable): Grantdef grant_read(self, identity: IGrantable) -> Grantpublic Grant grantRead(IGrantable identity)public Grant GrantRead(IGrantable identity)func GrantRead(Identity IGrantable) Grant#The use of this method is discouraged. Please use grants.read() instead.
[disable-awslint:no-grants]
grantRedriveExecution(identity: IGrantable): Grantdef grant_redrive_execution(self, identity: IGrantable) -> Grantpublic Grant grantRedriveExecution(IGrantable identity)public Grant GrantRedriveExecution(IGrantable identity)func GrantRedriveExecution(Identity IGrantable) Grant#The use of this method is discouraged. Please use grants.redriveExecution() instead.
[disable-awslint:no-grants]
grantStartExecution(identity: IGrantable): Grantdef grant_start_execution(self, identity: IGrantable) -> Grantpublic Grant grantStartExecution(IGrantable identity)public Grant GrantStartExecution(IGrantable identity)func GrantStartExecution(Identity IGrantable) Grant#The use of this method is discouraged. Please use grants.startExecution() instead.
[disable-awslint:no-grants]
grantStartSyncExecution(identity: IGrantable): Grantdef grant_start_sync_execution(self, identity: IGrantable) -> Grantpublic Grant grantStartSyncExecution(IGrantable identity)public Grant GrantStartSyncExecution(IGrantable identity)func GrantStartSyncExecution(Identity IGrantable) Grant#The use of this method is discouraged. Please use grants.startSyncExecution() instead.
[disable-awslint:no-grants]
grantTaskResponse(identity: IGrantable): Grantdef grant_task_response(self, identity: IGrantable) -> Grantpublic Grant grantTaskResponse(IGrantable identity)public Grant GrantTaskResponse(IGrantable identity)func GrantTaskResponse(Identity IGrantable) Grant#The use of this method is discouraged. Please use grants.taskResponse() instead.
[disable-awslint:no-grants]
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#metricAborted(props?: MetricOptions): Metricdef metric_aborted(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricAborted(MetricOptions props)public Metric MetricAborted(MetricOptions? props = null)func MetricAborted(Props MetricOptions) Metric#metricFailed(props?: MetricOptions): Metricdef metric_failed(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricFailed(MetricOptions props)public Metric MetricFailed(MetricOptions? props = null)func MetricFailed(Props MetricOptions) Metric#metricStarted(props?: MetricOptions): Metricdef metric_started(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricStarted(MetricOptions props)public Metric MetricStarted(MetricOptions? props = null)func MetricStarted(Props MetricOptions) Metric#metricSucceeded(props?: MetricOptions): Metricdef metric_succeeded(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSucceeded(MetricOptions props)public Metric MetricSucceeded(MetricOptions? props = null)func MetricSucceeded(Props MetricOptions) Metric#metricThrottled(props?: MetricOptions): Metricdef metric_throttled(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricThrottled(MetricOptions props)public Metric MetricThrottled(MetricOptions? props = null)func MetricThrottled(Props MetricOptions) Metric#metricTime(props?: MetricOptions): Metricdef metric_time(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTime(MetricOptions props)public Metric MetricTime(MetricOptions? props = null)func MetricTime(Props MetricOptions) Metric#metricTimedOut(props?: MetricOptions): Metricdef metric_timed_out(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricTimedOut(MetricOptions props)public Metric MetricTimedOut(MetricOptions? props = null)func MetricTimedOut(Props MetricOptions) Metric#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.