SubscriptionProtocol Enum
The type of subscription, controlling the type of the endpoint parameter.
| Source | aws-sns/lib/subscription.ts |
|---|
Example
ts
// producerStack defines an SNS topic
declare const topic: sns.Topic;
// consumerStack subscribes to it with a weak reference,
// so the producer can be torn down without blocking on this consumer
const consumerStack = new Stack(app, 'Consumer', {
env: { account: '123456789012', region: 'us-east-1' },
});
new sns.Subscription(consumerStack, 'Subscription', {
topic: sns.Topic.fromTopicArn(consumerStack, 'Topic', Stack.consumeReference(topic.topicArn)),
endpoint: 'https://example.com/webhook',
protocol: sns.SubscriptionProtocol.HTTPS,
});
python
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
)
java
// producerStack defines an SNS topic
Topic topic;
// consumerStack subscribes to it with a weak reference,
// so the producer can be torn down without blocking on this consumer
Stack consumerStack = Stack.Builder.create(app, "Consumer")
.env(Environment.builder().account("123456789012").region("us-east-1").build())
.build();
Subscription.Builder.create(consumerStack, "Subscription")
.topic(Topic.fromTopicArn(consumerStack, "Topic", Stack.consumeReference(topic.getTopicArn())))
.endpoint("https://example.com/webhook")
.protocol(SubscriptionProtocol.HTTPS)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// producerStack defines an SNS topic
Topic topic;
// consumerStack subscribes to it with a weak reference,
// so the producer can be torn down without blocking on this consumer
var consumerStack = new Stack(app, "Consumer", new StackProps {
Env = new Environment { Account = "123456789012", Region = "us-east-1" }
});
new Subscription(consumerStack, "Subscription", new SubscriptionProps {
Topic = Topic.FromTopicArn(consumerStack, "Topic", Stack.ConsumeReference(topic.TopicArn)),
Endpoint = "https://example.com/webhook",
Protocol = SubscriptionProtocol.HTTPS
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// producerStack defines an SNS topic
var topic Topic
// consumerStack subscribes to it with a weak reference,
// so the producer can be torn down without blocking on this consumer
consumerStack := awscdk.Newstack(app, jsii.String("Consumer"), &StackProps{
Env: &Environment{
Account: jsii.String("123456789012"),
Region: jsii.String("us-east-1"),
},
})
sns.NewSubscription(consumerStack, jsii.String("Subscription"), &SubscriptionProps{
Topic: sns.Topic_FromTopicArn(consumerStack, jsii.String("Topic"), awscdk.*stack_ConsumeReference(topic.topicArn)),
Endpoint: jsii.String("https://example.com/webhook"),
Protocol: sns.SubscriptionProtocol_HTTPS,
})
Members
| Member | Description |
|---|---|
HTTP | JSON-encoded message is POSTED to an HTTP url. |
HTTPS | JSON-encoded message is POSTed to an HTTPS url. |
EMAIL | Notifications are sent via email. |
EMAIL_JSON | Notifications are JSON-encoded and sent via mail. |
SMS | Notification is delivered by SMS. |
SQS | Notifications are enqueued into an SQS queue. |
APPLICATION | JSON-encoded notifications are sent to a mobile app endpoint. |
LAMBDA | Notifications trigger a Lambda function. |
FIREHOSE | Notifications put records into a firehose delivery stream. |
Referenced by
SubscriptionOptions.protocolprotocolprotocolProtocolProtocolUrlSubscriptionProps.protocolprotocolprotocolProtocolProtocol