TaskRole

class aws_cdk.aws_stepfunctions.TaskRole

Bases: object

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

See:

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

ExampleMetadata:

infused

Example:

import aws_cdk.aws_lambda as lambda_

# submit_lambda: lambda.Function
# iam_role: iam.Role


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

submit_job = tasks.LambdaInvoke(self, "Submit Job",
    lambda_function=submit_lambda,
    output_path="$.Payload",
    # use credentials
    credentials=sfn.Credentials(role=role)
)

Attributes

resource

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

role_arn

Retrieves the roleArn for this TaskRole.

Static Methods

classmethod from_role(role)

Construct a task role based on the provided IAM Role.

Parameters:

role (IRole) – IAM Role.

Return type:

TaskRole

classmethod from_role_arn_json_path(expression)

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

Parameters:

expression (str) – json expression to roleArn.

Return type:

TaskRole

Example:

sfn.TaskRole.from_role_arn_json_path("$.RoleArn")