# IStateMachine

A State Machine.

Extends: IStateMachine
Extends: IResource, IGrantable, IStateMachineRef
Implemented by: StateMachine

- Source: [`aws-stepfunctions/lib/state-machine.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts#L669)
- Type last changed: v2.227.0 · 21 Nov 2025

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  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.

- `grantPrincipal`: [IPrincipal](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IPrincipal.html) (required) — The principal to grant permissions to.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

- `stateMachineArn`: string (required) — The ARN of the state machine.

- `stateMachineRef`: [StateMachineReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_stepfunctions.StateMachineReference.html) (required) — A reference to a StateMachine resource.

## Methods

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  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`).

- `grant(identity: IGrantable, ...actions: string[]): Grant` — Grant the given identity custom permissions.

  **Parameters**

  - `identity` — The principal.
  - `actions` — The list of desired actions.

- `grantExecution(identity: IGrantable, ...actions: string[]): Grant` — Grant the given identity permissions for all executions of a state machine.

  **Parameters**

  - `identity` — The principal.
  - `actions` — The list of desired actions.

- `grantRead(identity: IGrantable): Grant` — Grant the given identity read permissions for this state machine.

  **Parameters**

  - `identity` — The principal.

- `grantRedriveExecution(identity: IGrantable): Grant` — Grant the given identity permission to redrive the execution of the state machine.

  **Parameters**

  - `identity` — The principal.

- `grantStartExecution(identity: IGrantable): Grant` — Grant the given identity permissions to start an execution of this state machine.

  **Parameters**

  - `identity` — The principal.

- `grantStartSyncExecution(identity: IGrantable): Grant` — Grant the given identity permissions to start a synchronous execution of this state machine.

  **Parameters**

  - `identity` — The principal.

- `grantTaskResponse(identity: IGrantable): Grant` — Grant the given identity read permissions for this state machine.

  **Parameters**

  - `identity` — The principal.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric for this State Machine's executions.

- `metricAborted(props?: MetricOptions): Metric` — Metric for the number of executions that were aborted.

- `metricFailed(props?: MetricOptions): Metric` — Metric for the number of executions that failed.

- `metricStarted(props?: MetricOptions): Metric` — Metric for the number of executions that were started.

- `metricSucceeded(props?: MetricOptions): Metric` — Metric for the number of executions that succeeded.

- `metricThrottled(props?: MetricOptions): Metric` — Metric for the number of executions that were throttled.

- `metricTime(props?: MetricOptions): Metric` — Metric for the interval, in milliseconds, between the time the execution starts and the time it closes.

- `metricTimedOut(props?: MetricOptions): Metric` — Metric for the number of executions that timed out.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  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.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
