aws-cdk-lib.aws_stepfunctions.TaskRole

class TaskRole

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

Role to be assumed by the State Machine's execution role for invoking a task's resource.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html#task-state-fields

Example

import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const submitLambda: lambda.Function;
declare const iamRole: iam.Role;

// use a fixed role for all task invocations
const role = sfn.TaskRole.fromRole(iamRole);
// or use a json expression to resolve the role at runtime based on task inputs
//const role = sfn.TaskRole.fromRoleArnJsonPath('$.RoleArn');

const submitJob = new tasks.LambdaInvoke(this, 'Submit Job', {
  lambdaFunction: submitLambda,
  outputPath: '$.Payload',
  // use credentials
  credentials: { role },
});

Initializer

new TaskRole()

Properties

NameTypeDescription
resourcestringRetrieves the resource for use in IAM Policies for this TaskRole.
roleArnstringRetrieves the roleArn for this TaskRole.

resource

Type: string

Retrieves the resource for use in IAM Policies for this TaskRole.


roleArn

Type: string

Retrieves the roleArn for this TaskRole.

Methods

NameDescription
static fromRole(role)Construct a task role based on the provided IAM Role.
static fromRoleArnJsonPath(expression)Construct a task role retrieved from task inputs using a json expression.

static fromRole(role)

public static fromRole(role: IRole): TaskRole

Parameters

  • role IRole — IAM Role.

Returns

  • TaskRole

Construct a task role based on the provided IAM Role.


static fromRoleArnJsonPath(expression)

public static fromRoleArnJsonPath(expression: string): TaskRole

Parameters

  • expression string — json expression to roleArn.

Returns

  • TaskRole

Construct a task role retrieved from task inputs using a json expression. Example

sfn.TaskRole.fromRoleArnJsonPath('$.RoleArn');