aws-cdk-lib.aws_stepfunctions.Activity

class Activity (construct)

LanguageType name
.NETAmazon.CDK.AWS.StepFunctions.Activity
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#Activity
Javasoftware.amazon.awscdk.services.stepfunctions.Activity
Pythonaws_cdk.aws_stepfunctions.Activity
TypeScript (source)aws-cdk-lib » aws_stepfunctions » Activity

Implements IConstruct, IDependable, IResource, IActivity

Define a new Step Functions Activity.

Example

const activity = new sfn.Activity(this, 'Activity');

const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});

activity.grant(role, 'states:SendTaskSuccess');

Initializer

new Activity(scope: Construct, id: string, props?: ActivityProps)

Parameters

  • scope Construct
  • id string
  • props ActivityProps

Construct Props

NameTypeDescription
activityName?stringThe name for this activity.

activityName?

Type: string (optional, default: If not supplied, a name is generated)

The name for this activity.

Properties

NameTypeDescription
activityArnstringThe ARN of the activity.
activityNamestringThe name of the activity.
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

activityArn

Type: string

The ARN of the activity.


activityName

Type: string

The name of the activity.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
grant(identity, ...actions)Grant the given identity permissions on this Activity.
metric(metricName, props?)Return the given named metric for this Activity.
metricFailed(props?)Metric for the number of times this activity fails.
metricHeartbeatTimedOut(props?)Metric for the number of times the heartbeat times out for this activity.
metricRunTime(props?)The interval, in milliseconds, between the time the activity starts and the time it closes.
metricScheduleTime(props?)The interval, in milliseconds, for which the activity stays in the schedule state.
metricScheduled(props?)Metric for the number of times this activity is scheduled.
metricStarted(props?)Metric for the number of times this activity is started.
metricSucceeded(props?)Metric for the number of times this activity succeeds.
metricTime(props?)The interval, in milliseconds, between the time the activity is scheduled and the time it closes.
metricTimedOut(props?)Metric for the number of times this activity times out.
toString()Returns a string representation of this construct.
static fromActivityArn(scope, id, activityArn)Construct an Activity from an existing Activity ARN.
static fromActivityName(scope, id, activityName)Construct an Activity from an existing Activity Name.

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

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, ...actions)

public grant(identity: IGrantable, ...actions: string[]): Grant

Parameters

  • identity IGrantable — The principal.
  • actions string — The list of desired actions.

Returns

  • Grant

Grant the given identity permissions on this Activity.


metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for this Activity.


metricFailed(props?)

public metricFailed(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of times this activity fails.


metricHeartbeatTimedOut(props?)

public metricHeartbeatTimedOut(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of times the heartbeat times out for this activity.


metricRunTime(props?)

public metricRunTime(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The interval, in milliseconds, between the time the activity starts and the time it closes.


metricScheduleTime(props?)

public metricScheduleTime(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The interval, in milliseconds, for which the activity stays in the schedule state.


metricScheduled(props?)

public metricScheduled(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of times this activity is scheduled.


metricStarted(props?)

public metricStarted(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of times this activity is started.


metricSucceeded(props?)

public metricSucceeded(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of times this activity succeeds.


metricTime(props?)

public metricTime(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The interval, in milliseconds, between the time the activity is scheduled and the time it closes.


metricTimedOut(props?)

public metricTimedOut(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

Metric for the number of times this activity times out.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromActivityArn(scope, id, activityArn)

public static fromActivityArn(scope: Construct, id: string, activityArn: string): IActivity

Parameters

  • scope Construct
  • id string
  • activityArn string

Returns

  • IActivity

Construct an Activity from an existing Activity ARN.


static fromActivityName(scope, id, activityName)

public static fromActivityName(scope: Construct, id: string, activityName: string): IActivity

Parameters

  • scope Construct
  • id string
  • activityName string

Returns

  • IActivity

Construct an Activity from an existing Activity Name.