aws-cdk-lib.aws_stepfunctions_tasks.MessageAttribute

interface MessageAttribute

LanguageType name
.NETAmazon.CDK.AWS.StepFunctions.Tasks.MessageAttribute
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctionstasks#MessageAttribute
Javasoftware.amazon.awscdk.services.stepfunctions.tasks.MessageAttribute
Pythonaws_cdk.aws_stepfunctions_tasks.MessageAttribute
TypeScript (source)aws-cdk-lib » aws_stepfunctions_tasks » MessageAttribute

A message attribute to add to the SNS message.

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

Example

const topic = new sns.Topic(this, 'Topic');

// Use a field from the execution data as message.
const task1 = new tasks.SnsPublish(this, 'Publish1', {
  topic,
  integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE,
  message: sfn.TaskInput.fromDataAt('$.state.message'),
  messageAttributes: {
    place: {
      value: sfn.JsonPath.stringAt('$.place'),
    },
    pic: {
      // BINARY must be explicitly set
      dataType: tasks.MessageAttributeDataType.BINARY,
      value: sfn.JsonPath.stringAt('$.pic'),
    },
    people: {
      value: 4,
    },
    handles: {
      value: ['@kslater', '@jjf', null, '@mfanning'],
    },
  },
});

// Combine a field from the execution data with
// a literal object.
const task2 = new tasks.SnsPublish(this, 'Publish2', {
  topic,
  message: sfn.TaskInput.fromObject({
    field1: 'somedata',
    field2: sfn.JsonPath.stringAt('$.field2'),
  }),
});

Properties

NameTypeDescription
valueanyThe value of the attribute.
dataType?MessageAttributeDataTypeThe data type for the attribute.

value

Type: any

The value of the attribute.


dataType?

Type: MessageAttributeDataType (optional, default: determined by type inspection if possible, fallback is String)

The data type for the attribute.

See also: https://docs.aws.amazon.com/sns/latest/dg/sns-message-attributes.html#SNSMessageAttributes.DataTypes