UNPKG

3.56 kBTypeScriptView Raw
1import { IQueue } from '@aws-cdk/aws-sqs';
2import { Resource } from '@aws-cdk/core';
3import { Construct } from 'constructs';
4import { SubscriptionFilter } from './subscription-filter';
5import { ITopic } from './topic-base';
6/**
7 * Options for creating a new subscription
8 */
9export interface SubscriptionOptions {
10 /**
11 * What type of subscription to add.
12 */
13 readonly protocol: SubscriptionProtocol;
14 /**
15 * The subscription endpoint.
16 *
17 * The meaning of this value depends on the value for 'protocol'.
18 */
19 readonly endpoint: string;
20 /**
21 * true if raw message delivery is enabled for the subscription. Raw messages are free of JSON formatting and can be
22 * sent to HTTP/S and Amazon SQS endpoints. For more information, see GetSubscriptionAttributes in the Amazon Simple
23 * Notification Service API Reference.
24 *
25 * @default false
26 */
27 readonly rawMessageDelivery?: boolean;
28 /**
29 * The filter policy.
30 *
31 * @default - all messages are delivered
32 */
33 readonly filterPolicy?: {
34 [attribute: string]: SubscriptionFilter;
35 };
36 /**
37 * The region where the topic resides, in the case of cross-region subscriptions
38 * @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-region
39 * @default - the region where the CloudFormation stack is being deployed.
40 */
41 readonly region?: string;
42 /**
43 * Queue to be used as dead letter queue.
44 * If not passed no dead letter queue is enabled.
45 *
46 * @default - No dead letter queue enabled.
47 */
48 readonly deadLetterQueue?: IQueue;
49 /**
50 * Arn of role allowing access to firehose delivery stream.
51 * Required for a firehose subscription protocol.
52 * @default - No subscription role is provided
53 */
54 readonly subscriptionRoleArn?: string;
55}
56/**
57 * Properties for creating a new subscription
58 */
59export interface SubscriptionProps extends SubscriptionOptions {
60 /**
61 * The topic to subscribe to.
62 */
63 readonly topic: ITopic;
64}
65/**
66 * A new subscription.
67 *
68 * Prefer to use the `ITopic.addSubscription()` methods to create instances of
69 * this class.
70 */
71export declare class Subscription extends Resource {
72 /**
73 * The DLQ associated with this subscription if present.
74 */
75 readonly deadLetterQueue?: IQueue;
76 private readonly filterPolicy?;
77 constructor(scope: Construct, id: string, props: SubscriptionProps);
78 private buildDeadLetterQueue;
79 private buildDeadLetterConfig;
80}
81/**
82 * The type of subscription, controlling the type of the endpoint parameter.
83 */
84export declare enum SubscriptionProtocol {
85 /**
86 * JSON-encoded message is POSTED to an HTTP url.
87 */
88 HTTP = "http",
89 /**
90 * JSON-encoded message is POSTed to an HTTPS url.
91 */
92 HTTPS = "https",
93 /**
94 * Notifications are sent via email.
95 */
96 EMAIL = "email",
97 /**
98 * Notifications are JSON-encoded and sent via mail.
99 */
100 EMAIL_JSON = "email-json",
101 /**
102 * Notification is delivered by SMS
103 */
104 SMS = "sms",
105 /**
106 * Notifications are enqueued into an SQS queue.
107 */
108 SQS = "sqs",
109 /**
110 * JSON-encoded notifications are sent to a mobile app endpoint.
111 */
112 APPLICATION = "application",
113 /**
114 * Notifications trigger a Lambda function.
115 */
116 LAMBDA = "lambda",
117 /**
118 * Notifications put records into a firehose delivery stream.
119 */
120 FIREHOSE = "firehose"
121}