SubscriptionProps

class aws_cdk.aws_sns.SubscriptionProps(*, endpoint, protocol, dead_letter_queue=None, delivery_policy=None, filter_policy=None, filter_policy_with_message_body=None, raw_message_delivery=None, region=None, subscription_role_arn=None, topic)

Bases: SubscriptionOptions

Properties for creating a new subscription.

Parameters:
  • endpoint (str) – The subscription endpoint. The meaning of this value depends on the value for ‘protocol’.

  • protocol (SubscriptionProtocol) – What type of subscription to add.

  • dead_letter_queue (Optional[IQueue]) – Queue to be used as dead letter queue. If not passed no dead letter queue is enabled. Default: - No dead letter queue enabled.

  • delivery_policy (Union[DeliveryPolicy, Dict[str, Any], None]) – The delivery policy. Default: - if the initial delivery of the message fails, three retries with a delay between failed attempts set at 20 seconds

  • filter_policy (Optional[Mapping[str, SubscriptionFilter]]) – The filter policy. Default: - all messages are delivered

  • filter_policy_with_message_body (Optional[Mapping[str, FilterOrPolicy]]) – The filter policy that is applied on the message body. To apply a filter policy to the message attributes, use filterPolicy. A maximum of one of filterPolicyWithMessageBody and filterPolicy may be used. Default: - all messages are delivered

  • raw_message_delivery (Optional[bool]) – true if raw message delivery is enabled for the subscription. Raw messages are free of JSON formatting and can be sent to HTTP/S and Amazon SQS endpoints. For more information, see GetSubscriptionAttributes in the Amazon Simple Notification Service API Reference. Default: false

  • region (Optional[str]) – The region where the topic resides, in the case of cross-region subscriptions. Default: - the region where the CloudFormation stack is being deployed.

  • subscription_role_arn (Optional[str]) – Arn of role allowing access to firehose delivery stream. Required for a firehose subscription protocol. Default: - No subscription role is provided

  • topic (ITopic) – The topic to subscribe to.

ExampleMetadata:

infused

Example:

from aws_cdk import Environment
# producerStack defines an SNS topic
# topic: sns.Topic


# consumerStack subscribes to it with a weak reference,
# so the producer can be torn down without blocking on this consumer
consumer_stack = Stack(app, "Consumer",
    env=Environment(account="123456789012", region="us-east-1")
)
sns.Subscription(consumer_stack, "Subscription",
    topic=sns.Topic.from_topic_arn(consumer_stack, "Topic", Stack.consume_reference(topic.topic_arn)),
    endpoint="https://example.com/webhook",
    protocol=sns.SubscriptionProtocol.HTTPS
)

Attributes

dead_letter_queue

Queue to be used as dead letter queue.

If not passed no dead letter queue is enabled.

Default:
  • No dead letter queue enabled.

delivery_policy

The delivery policy.

Default:
  • if the initial delivery of the message fails, three retries with a delay between failed attempts set at 20 seconds

endpoint

The subscription endpoint.

The meaning of this value depends on the value for ‘protocol’.

filter_policy

The filter policy.

Default:
  • all messages are delivered

filter_policy_with_message_body

The filter policy that is applied on the message body.

To apply a filter policy to the message attributes, use filterPolicy. A maximum of one of filterPolicyWithMessageBody and filterPolicy may be used.

Default:
  • all messages are delivered

protocol

What type of subscription to add.

raw_message_delivery

true if raw message delivery is enabled for the subscription.

Raw messages are free of JSON formatting and can be sent to HTTP/S and Amazon SQS endpoints. For more information, see GetSubscriptionAttributes in the Amazon Simple Notification Service API Reference.

Default:

false

region

The region where the topic resides, in the case of cross-region subscriptions.

Default:
  • the region where the CloudFormation stack is being deployed.

Link:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-region

subscription_role_arn

Arn of role allowing access to firehose delivery stream.

Required for a firehose subscription protocol.

Default:
  • No subscription role is provided

topic

The topic to subscribe to.