Skip to content
v2.278.0

SnsTopicProps ​

Struct Stable

Customize the SNS Topic Event Target.

Example ​

ts
declare const onCommitRule: events.Rule;
declare const topic: sns.Topic;

onCommitRule.addTarget(new targets.SnsTopic(topic, {
  message: events.RuleTargetInput.fromObject(
    {
      DataType: `custom_${events.EventField.fromPath('$.detail-type')}`
    }
  )
}));
python
# on_commit_rule: events.Rule
# topic: sns.Topic


on_commit_rule.add_target(targets.SnsTopic(topic,
    message=events.RuleTargetInput.from_object({
        "DataType": f"custom_{events.EventField.fromPath('$.detail-type')}"
    })
))
java
Rule onCommitRule;
Topic topic;


onCommitRule.addTarget(SnsTopic.Builder.create(topic)
        .message(RuleTargetInput.fromObject(Map.of(
                "DataType", String.format("custom_%s", EventField.fromPath("$.detail-type")))))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Rule onCommitRule;
Topic topic;


onCommitRule.AddTarget(new SnsTopic(topic, new SnsTopicProps {
    Message = RuleTargetInput.FromObject(new Dictionary<string, string> {
        { "DataType", $"custom_{events.EventField.fromPath('$.detail-type')}" }
    })
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var onCommitRule Rule
var topic Topic


onCommitRule.AddTarget(targets.NewSnsTopic(topic, &SnsTopicProps{
	Message: events.RuleTargetInput_FromObject(map[string]*string{
		"DataType": fmt.Sprintf("custom_%v", events.EventField_fromPath(jsii.String("$.detail-type"))),
	}),
}))

Properties ​

authorizeUsingRoleoptionalbooleanauthorize_using_roleoptionalboolauthorizeUsingRoleoptionalBooleanAuthorizeUsingRoleoptionalboolAuthorizeUsingRoleoptional*bool #
Specifies whether an IAM role should be used to publish to the topic.

Default: true if role is provided, false otherwise

deadLetterQueueoptionalIQueuedead_letter_queueoptionalIQueuedeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueueDeadLetterQueueoptionalIQueue #
The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.

Default: no dead-letter queue

notes

The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.

maxEventAgeoptionalDurationmax_event_ageoptionalDurationmaxEventAgeoptionalDurationMaxEventAgeoptionalDurationMaxEventAgeoptionalDuration = Duration.hours(24) #
The maximum age of a request that Lambda sends to a function for processing.

Minimum value of 60. Maximum value of 86400.

messageoptionalRuleTargetInputmessageoptionalRuleTargetInputmessageoptionalRuleTargetInputMessageoptionalRuleTargetInputMessageoptionalRuleTargetInput #
The message to send to the topic.

Default: the entire EventBridge event

retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64 = 185 #
The maximum number of times to retry when the function returns an error.

Minimum value of 0. Maximum value of 185.

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
The IAM role to be used to publish to the topic.

Default: a new role will be created if authorizeUsingRole is true