# SnsPublishJsonPathProps

Properties for publishing a message to an SNS topic using JSONPath.

Extends: [TaskStateJsonPathBaseProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.TaskStateJsonPathBaseProps.html)
Used as argument in: [SnsPublish.jsonPath](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.SnsPublish.html#jsonpath)

- Source: [`aws-stepfunctions-tasks/lib/sns/publish.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/sns/publish.ts#L143)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_sns as sns } from 'aws-cdk-lib';
import { aws_stepfunctions as stepfunctions } from 'aws-cdk-lib';
import { aws_stepfunctions_tasks as stepfunctions_tasks } from 'aws-cdk-lib';

declare const assign: any;
declare const resultSelector: any;
declare const taskInput: stepfunctions.TaskInput;
declare const taskRole: stepfunctions.TaskRole;
declare const timeout: stepfunctions.Timeout;
declare const topic: sns.Topic;
declare const value: any;
const snsPublishJsonPathProps: stepfunctions_tasks.SnsPublishJsonPathProps = {
  message: taskInput,
  topic: topic,

  // the properties below are optional
  assign: {
    assignKey: assign,
  },
  comment: 'comment',
  credentials: {
    role: taskRole,
  },
  heartbeat: cdk.Duration.minutes(30),
  heartbeatTimeout: timeout,
  inputPath: 'inputPath',
  integrationPattern: stepfunctions.IntegrationPattern.REQUEST_RESPONSE,
  messageAttributes: {
    messageAttributesKey: {
      value: value,

      // the properties below are optional
      dataType: stepfunctions_tasks.MessageAttributeDataType.STRING,
    },
  },
  messageDeduplicationId: 'messageDeduplicationId',
  messageGroupId: 'messageGroupId',
  messagePerSubscriptionType: false,
  outputPath: 'outputPath',
  queryLanguage: stepfunctions.QueryLanguage.JSON_PATH,
  resultPath: 'resultPath',
  resultSelector: {
    resultSelectorKey: resultSelector,
  },
  stateName: 'stateName',
  subject: 'subject',
  taskTimeout: timeout,
  timeout: cdk.Duration.minutes(30),
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_sns as sns
from aws_cdk import aws_stepfunctions as stepfunctions
from aws_cdk import aws_stepfunctions_tasks as stepfunctions_tasks

# assign: Any
# result_selector: Any
# task_input: stepfunctions.TaskInput
# task_role: stepfunctions.TaskRole
# timeout: stepfunctions.Timeout
# topic: sns.Topic
# value: Any

sns_publish_json_path_props = stepfunctions_tasks.SnsPublishJsonPathProps(
    message=task_input,
    topic=topic,

    # the properties below are optional
    assign={
        "assign_key": assign
    },
    comment="comment",
    credentials=stepfunctions.Credentials(
        role=task_role
    ),
    heartbeat=cdk.Duration.minutes(30),
    heartbeat_timeout=timeout,
    input_path="inputPath",
    integration_pattern=stepfunctions.IntegrationPattern.REQUEST_RESPONSE,
    message_attributes={
        "message_attributes_key": stepfunctions_tasks.MessageAttribute(
            value=value,

            # the properties below are optional
            data_type=stepfunctions_tasks.MessageAttributeDataType.STRING
        )
    },
    message_deduplication_id="messageDeduplicationId",
    message_group_id="messageGroupId",
    message_per_subscription_type=False,
    output_path="outputPath",
    query_language=stepfunctions.QueryLanguage.JSON_PATH,
    result_path="resultPath",
    result_selector={
        "result_selector_key": result_selector
    },
    state_name="stateName",
    subject="subject",
    task_timeout=timeout,
    timeout=cdk.Duration.minutes(30)
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.sns.*;
import software.amazon.awscdk.services.stepfunctions.*;
import software.amazon.awscdk.services.stepfunctions.tasks.*;

Object assign;
Object resultSelector;
TaskInput taskInput;
TaskRole taskRole;
Timeout timeout;
Topic topic;
Object value;

SnsPublishJsonPathProps snsPublishJsonPathProps = SnsPublishJsonPathProps.builder()
        .message(taskInput)
        .topic(topic)

        // the properties below are optional
        .assign(Map.of(
                "assignKey", assign))
        .comment("comment")
        .credentials(Credentials.builder()
                .role(taskRole)
                .build())
        .heartbeat(Duration.minutes(30))
        .heartbeatTimeout(timeout)
        .inputPath("inputPath")
        .integrationPattern(IntegrationPattern.REQUEST_RESPONSE)
        .messageAttributes(Map.of(
                "messageAttributesKey", MessageAttribute.builder()
                        .value(value)

                        // the properties below are optional
                        .dataType(MessageAttributeDataType.STRING)
                        .build()))
        .messageDeduplicationId("messageDeduplicationId")
        .messageGroupId("messageGroupId")
        .messagePerSubscriptionType(false)
        .outputPath("outputPath")
        .queryLanguage(QueryLanguage.JSON_PATH)
        .resultPath("resultPath")
        .resultSelector(Map.of(
                "resultSelectorKey", resultSelector))
        .stateName("stateName")
        .subject("subject")
        .taskTimeout(timeout)
        .timeout(Duration.minutes(30))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.SNS;
using Amazon.CDK.AWS.StepFunctions;
using Amazon.CDK.AWS.StepFunctions.Tasks;

var assign;
var resultSelector;
TaskInput taskInput;
TaskRole taskRole;
Timeout timeout;
Topic topic;
var value;

var snsPublishJsonPathProps = new SnsPublishJsonPathProps {
    Message = taskInput,
    Topic = topic,

    // the properties below are optional
    Assign = new Dictionary<string, object> {
        { "assignKey", assign }
    },
    Comment = "comment",
    Credentials = new Credentials {
        Role = taskRole
    },
    Heartbeat = Duration.Minutes(30),
    HeartbeatTimeout = timeout,
    InputPath = "inputPath",
    IntegrationPattern = IntegrationPattern.REQUEST_RESPONSE,
    MessageAttributes = new Dictionary<string, MessageAttribute> {
        { "messageAttributesKey", new MessageAttribute {
            Value = value,

            // the properties below are optional
            DataType = MessageAttributeDataType.STRING
        } }
    },
    MessageDeduplicationId = "messageDeduplicationId",
    MessageGroupId = "messageGroupId",
    MessagePerSubscriptionType = false,
    OutputPath = "outputPath",
    QueryLanguage = QueryLanguage.JSON_PATH,
    ResultPath = "resultPath",
    ResultSelector = new Dictionary<string, object> {
        { "resultSelectorKey", resultSelector }
    },
    StateName = "stateName",
    Subject = "subject",
    TaskTimeout = timeout,
    Timeout = Duration.Minutes(30)
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var assign interface{}
var resultSelector interface{}
var taskInput TaskInput
var taskRole TaskRole
var timeout Timeout
var topic Topic
var value interface{}

snsPublishJsonPathProps := &SnsPublishJsonPathProps{
	Message: taskInput,
	Topic: topic,

	// the properties below are optional
	Assign: map[string]interface{}{
		"assignKey": assign,
	},
	Comment: jsii.String("comment"),
	Credentials: &Credentials{
		Role: taskRole,
	},
	Heartbeat: cdk.Duration_Minutes(jsii.Number(30)),
	HeartbeatTimeout: timeout,
	InputPath: jsii.String("inputPath"),
	IntegrationPattern: awscdk.Aws_stepfunctions.IntegrationPattern_REQUEST_RESPONSE,
	MessageAttributes: map[string]MessageAttribute{
		"messageAttributesKey": &MessageAttribute{
			"value": value,

			// the properties below are optional
			"dataType": awscdk.aws_stepfunctions_tasks.MessageAttributeDataType_STRING,
		},
	},
	MessageDeduplicationId: jsii.String("messageDeduplicationId"),
	MessageGroupId: jsii.String("messageGroupId"),
	MessagePerSubscriptionType: jsii.Boolean(false),
	OutputPath: jsii.String("outputPath"),
	QueryLanguage: awscdk.*Aws_stepfunctions.QueryLanguage_JSON_PATH,
	ResultPath: jsii.String("resultPath"),
	ResultSelector: map[string]interface{}{
		"resultSelectorKey": resultSelector,
	},
	StateName: jsii.String("stateName"),
	Subject: jsii.String("subject"),
	TaskTimeout: timeout,
	Timeout: cdk.Duration_*Minutes(jsii.Number(30)),
}
```

## Properties

- `assign`: { [key: string]: any } — Workflow variables to store in this step.

  **Default:** Not assign variables

  Using workflow variables, you can store data in a step and retrieve that data in future steps.

- `comment`: string — A comment describing this state.

  **Default:** No comment

- `credentials`: [Credentials](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Credentials.html) — Credentials for an IAM Role that the State Machine assumes for executing the task.

  **Default:** None (Task is executed using the State Machine's execution role)

  This enables cross-account resource invocations.

- `heartbeat`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — use `heartbeatTimeout`

- `heartbeatTimeout`: [Timeout](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Timeout.html) = None — Timeout for the heartbeat.

  [disable-awslint:duration-prop-type] is needed because all props interface in
  aws-stepfunctions-tasks extend this interface

- `inputPath`: string = $ — 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 {}.

- `integrationPattern`: [IntegrationPattern](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.IntegrationPattern.html) — AWS Step Functions integrates with services directly in the Amazon States Language.

  **Default:** `IntegrationPattern.REQUEST_RESPONSE` for most tasks. `IntegrationPattern.RUN_JOB` for the following exceptions: `BatchSubmitJob`, `EmrAddStep`, `EmrCreateCluster`, `EmrTerminationCluster`, and `EmrContainersStartJobRun`.

  You can control these AWS services using service integration patterns.

  Depending on the AWS Service, the Service Integration Pattern availability will vary.

- `message`: [TaskInput](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.TaskInput.html) (required) — 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.

- `messageAttributes`: { [key: string]: [MessageAttribute](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.MessageAttribute.html) } = {} — Add message attributes when publishing.

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

- `messageDeduplicationId`: string — This parameter applies only to FIFO topics.

  **Default:** Not used for standard topics, required for FIFO topics with ContentBasedDeduplication disabled.

  Every message must have a unique MessageDeduplicationId, which is a token used for deduplication of sent messages.
  If a message with a particular MessageDeduplicationId is sent successfully, any message sent with the same MessageDeduplicationId
  during the 5-minute deduplication interval is treated as a duplicate.

  If the topic has ContentBasedDeduplication set, the system generates a MessageDeduplicationId
  based on the contents of the message. Your MessageDeduplicationId overrides the generated one.

- `messageGroupId`: string — This parameter applies only to FIFO topics.

  **Default:** Not used for standard topics, required for FIFO topics.

  The MessageGroupId is a tag that specifies that a message belongs to a specific message group.
  Messages that belong to the same message group are processed in a FIFO manner
  (however, messages in different message groups might be processed out of order).
  Every message must include a MessageGroupId.

- `messagePerSubscriptionType`: boolean = false — 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)

- `outputPath`: string = $ — JSONPath expression to select part of the state to be the output to this state.

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

- `queryLanguage`: [QueryLanguage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.QueryLanguage.html) = JSONPath — The name of the query language used by the state.

  If the state does not contain a `queryLanguage` field,
  then it will use the query language specified in the top-level `queryLanguage` field.

- `resultPath`: string = $ — 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.

- `resultSelector`: { [key: string]: any } = None — 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.

- `stateName`: string — Optional name for this state.

  **Default:** The construct ID will be used as state name

- `subject`: string — Used as the "Subject" line when the message is delivered to email endpoints.

  **Default:** No subject

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

- `taskTimeout`: [Timeout](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Timeout.html) = None — Timeout for the task.

  [disable-awslint:duration-prop-type] is needed because all props interface in
  aws-stepfunctions-tasks extend this interface

- `timeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — use `taskTimeout`

- `topic`: [ITopic](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sns.ITopic.html) (required) — The SNS topic that the task will publish to.
