SnsPublishProps

class aws_cdk.aws_stepfunctions_tasks.SnsPublishProps(*, comment=None, heartbeat=None, input_path=None, integration_pattern=None, output_path=None, result_path=None, result_selector=None, timeout=None, message, topic, message_attributes=None, message_per_subscription_type=None, subject=None)

Bases: TaskStateBaseProps

Properties for publishing a message to an SNS topic.

Parameters:
  • comment (Optional[str]) – An optional description for this state. Default: - No comment

  • heartbeat (Optional[Duration]) – Timeout for the heartbeat. Default: - None

  • input_path (Optional[str]) – JSONPath expression to select part of the state to be the input to this state. May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}. Default: - The entire task input (JSON path ‘$’)

  • integration_pattern (Optional[IntegrationPattern]) – AWS Step Functions integrates with services directly in the Amazon States Language. You can control these AWS services using service integration patterns Default: - IntegrationPattern.REQUEST_RESPONSE for most tasks. IntegrationPattern.RUN_JOB for the following exceptions: BatchSubmitJob, EmrAddStep, EmrCreateCluster, EmrTerminationCluster, and EmrContainersStartJobRun.

  • output_path (Optional[str]) – JSONPath expression to select select a portion of the state output to pass to the next state. May also be the special value JsonPath.DISCARD, which will cause the effective output to be the empty object {}. Default: - The entire JSON node determined by the state input, the task result, and resultPath is passed to the next state (JSON path ‘$’)

  • result_path (Optional[str]) – JSONPath expression to indicate where to inject the state’s output. May also be the special value JsonPath.DISCARD, which will cause the state’s input to become its output. Default: - Replaces the entire input with the result (JSON path ‘$’)

  • result_selector (Optional[Mapping[str, Any]]) – The JSON that will replace the state’s raw result and become the effective result before ResultPath is applied. You can use ResultSelector to create a payload with values that are static or selected from the state’s raw result. Default: - None

  • timeout (Optional[Duration]) – Timeout for the state machine. Default: - None

  • message (TaskInput) – The message you want to send. With the exception of SMS, messages must be UTF-8 encoded strings and at most 256 KB in size. For SMS, each message can contain up to 140 characters.

  • topic (ITopic) – The SNS topic that the task will publish to.

  • message_attributes (Optional[Mapping[str, Union[MessageAttribute, Dict[str, Any]]]]) – Add message attributes when publishing. These attributes carry additional metadata about the message and may be used for subscription filters. Default: {}

  • message_per_subscription_type (Optional[bool]) – Send different messages for each transport protocol. For example, you might want to send a shorter message to SMS subscribers and a more verbose message to email and SQS subscribers. Your message must be a JSON object with a top-level JSON key of “default” with a value that is a string You can define other top-level keys that define the message you want to send to a specific transport protocol (i.e. “sqs”, “email”, “http”, etc) Default: false

  • subject (Optional[str]) – Used as the “Subject” line when the message is delivered to email endpoints. This field will also be included, if present, in the standard JSON messages delivered to other endpoints. Default: - No subject

ExampleMetadata:

infused

Example:

convert_to_seconds = tasks.EvaluateExpression(self, "Convert to seconds",
    expression="$.waitMilliseconds / 1000",
    result_path="$.waitSeconds"
)

create_message = tasks.EvaluateExpression(self, "Create message",
    # Note: this is a string inside a string.
    expression="`Now waiting ${$.waitSeconds} seconds...`",
    runtime=lambda_.Runtime.NODEJS_14_X,
    result_path="$.message"
)

publish_message = tasks.SnsPublish(self, "Publish message",
    topic=sns.Topic(self, "cool-topic"),
    message=sfn.TaskInput.from_json_path_at("$.message"),
    result_path="$.sns"
)

wait = sfn.Wait(self, "Wait",
    time=sfn.WaitTime.seconds_path("$.waitSeconds")
)

sfn.StateMachine(self, "StateMachine",
    definition=convert_to_seconds.next(create_message).next(publish_message).next(wait)
)

Attributes

comment

An optional description for this state.

Default:
  • No comment

heartbeat

Timeout for the heartbeat.

Default:
  • None

input_path

JSONPath expression to select part of the state to be the input to this state.

May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}.

Default:
  • The entire task input (JSON path ‘$’)

integration_pattern

AWS Step Functions integrates with services directly in the Amazon States Language.

You can control these AWS services using service integration patterns

Default:

  • IntegrationPattern.REQUEST_RESPONSE for most tasks.

IntegrationPattern.RUN_JOB for the following exceptions: BatchSubmitJob, EmrAddStep, EmrCreateCluster, EmrTerminationCluster, and EmrContainersStartJobRun.

See:

https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html#connect-wait-token

message

The message you want to send.

With the exception of SMS, messages must be UTF-8 encoded strings and at most 256 KB in size. For SMS, each message can contain up to 140 characters.

message_attributes

Add message attributes when publishing.

These attributes carry additional metadata about the message and may be used for subscription filters.

Default:

{}

See:

https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html

message_per_subscription_type

Send different messages for each transport protocol.

For example, you might want to send a shorter message to SMS subscribers and a more verbose message to email and SQS subscribers.

Your message must be a JSON object with a top-level JSON key of “default” with a value that is a string You can define other top-level keys that define the message you want to send to a specific transport protocol (i.e. “sqs”, “email”, “http”, etc)

Default:

false

See:

https://docs.aws.amazon.com/sns/latest/api/API_Publish.html#API_Publish_RequestParameters

output_path

JSONPath expression to select select a portion of the state output to pass to the next state.

May also be the special value JsonPath.DISCARD, which will cause the effective output to be the empty object {}.

Default:

  • The entire JSON node determined by the state input, the task result,

and resultPath is passed to the next state (JSON path ‘$’)

result_path

JSONPath expression to indicate where to inject the state’s output.

May also be the special value JsonPath.DISCARD, which will cause the state’s input to become its output.

Default:
  • Replaces the entire input with the result (JSON path ‘$’)

result_selector

The JSON that will replace the state’s raw result and become the effective result before ResultPath is applied.

You can use ResultSelector to create a payload with values that are static or selected from the state’s raw result.

Default:
  • None

See:

https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector

subject

Used as the “Subject” line when the message is delivered to email endpoints.

This field will also be included, if present, in the standard JSON messages delivered to other endpoints.

Default:
  • No subject

timeout

Timeout for the state machine.

Default:
  • None

topic

The SNS topic that the task will publish to.