UNPKG

8.5 kBTypeScriptView Raw
1import * as kms from '@aws-cdk/aws-kms';
2import { Duration, RemovalPolicy } from '@aws-cdk/core';
3import { Construct } from 'constructs';
4import { IQueue, QueueAttributes, QueueBase } from './queue-base';
5/**
6 * Properties for creating a new Queue
7 */
8export interface QueueProps {
9 /**
10 * A name for the queue.
11 *
12 * If specified and this is a FIFO queue, must end in the string '.fifo'.
13 *
14 * @default CloudFormation-generated name
15 */
16 readonly queueName?: string;
17 /**
18 * The number of seconds that Amazon SQS retains a message.
19 *
20 * You can specify an integer value from 60 seconds (1 minute) to 1209600
21 * seconds (14 days). The default value is 345600 seconds (4 days).
22 *
23 * @default Duration.days(4)
24 */
25 readonly retentionPeriod?: Duration;
26 /**
27 * The time in seconds that the delivery of all messages in the queue is delayed.
28 *
29 * You can specify an integer value of 0 to 900 (15 minutes). The default
30 * value is 0.
31 *
32 * @default 0
33 */
34 readonly deliveryDelay?: Duration;
35 /**
36 * The limit of how many bytes that a message can contain before Amazon SQS rejects it.
37 *
38 * You can specify an integer value from 1024 bytes (1 KiB) to 262144 bytes
39 * (256 KiB). The default value is 262144 (256 KiB).
40 *
41 * @default 256KiB
42 */
43 readonly maxMessageSizeBytes?: number;
44 /**
45 * Default wait time for ReceiveMessage calls.
46 *
47 * Does not wait if set to 0, otherwise waits this amount of seconds
48 * by default for messages to arrive.
49 *
50 * For more information, see Amazon SQS Long Poll.
51 *
52 * @default 0
53 */
54 readonly receiveMessageWaitTime?: Duration;
55 /**
56 * Timeout of processing a single message.
57 *
58 * After dequeuing, the processor has this much time to handle the message
59 * and delete it from the queue before it becomes visible again for dequeueing
60 * by another processor.
61 *
62 * Values must be from 0 to 43200 seconds (12 hours). If you don't specify
63 * a value, AWS CloudFormation uses the default value of 30 seconds.
64 *
65 * @default Duration.seconds(30)
66 */
67 readonly visibilityTimeout?: Duration;
68 /**
69 * Send messages to this queue if they were unsuccessfully dequeued a number of times.
70 *
71 * @default no dead-letter queue
72 */
73 readonly deadLetterQueue?: DeadLetterQueue;
74 /**
75 * Whether the contents of the queue are encrypted, and by what type of key.
76 *
77 * Be aware that encryption is not available in all regions, please see the docs
78 * for current availability details.
79 *
80 * @default Unencrypted
81 */
82 readonly encryption?: QueueEncryption;
83 /**
84 * External KMS master key to use for queue encryption.
85 *
86 * Individual messages will be encrypted using data keys. The data keys in
87 * turn will be encrypted using this key, and reused for a maximum of
88 * `dataKeyReuseSecs` seconds.
89 *
90 * If the 'encryptionMasterKey' property is set, 'encryption' type will be
91 * implicitly set to "KMS".
92 *
93 * @default If encryption is set to KMS and not specified, a key will be created.
94 */
95 readonly encryptionMasterKey?: kms.IKey;
96 /**
97 * The length of time that Amazon SQS reuses a data key before calling KMS again.
98 *
99 * The value must be an integer between 60 (1 minute) and 86,400 (24
100 * hours). The default is 300 (5 minutes).
101 *
102 * @default Duration.minutes(5)
103 */
104 readonly dataKeyReuse?: Duration;
105 /**
106 * Whether this a first-in-first-out (FIFO) queue.
107 *
108 * @default false, unless queueName ends in '.fifo' or 'contentBasedDeduplication' is true.
109 */
110 readonly fifo?: boolean;
111 /**
112 * Specifies whether to enable content-based deduplication.
113 *
114 * During the deduplication interval (5 minutes), Amazon SQS treats
115 * messages that are sent with identical content (excluding attributes) as
116 * duplicates and delivers only one copy of the message.
117 *
118 * If you don't enable content-based deduplication and you want to deduplicate
119 * messages, provide an explicit deduplication ID in your SendMessage() call.
120 *
121 * (Only applies to FIFO queues.)
122 *
123 * @default false
124 */
125 readonly contentBasedDeduplication?: boolean;
126 /**
127 * For high throughput for FIFO queues, specifies whether message deduplication
128 * occurs at the message group or queue level.
129 *
130 * (Only applies to FIFO queues.)
131 *
132 * @default DeduplicationScope.QUEUE
133 */
134 readonly deduplicationScope?: DeduplicationScope;
135 /**
136 * For high throughput for FIFO queues, specifies whether the FIFO queue
137 * throughput quota applies to the entire queue or per message group.
138 *
139 * (Only applies to FIFO queues.)
140 *
141 * @default FifoThroughputLimit.PER_QUEUE
142 */
143 readonly fifoThroughputLimit?: FifoThroughputLimit;
144 /**
145 * Policy to apply when the queue is removed from the stack
146 *
147 * Even though queues are technically stateful, their contents are transient and it
148 * is common to add and remove Queues while rearchitecting your application. The
149 * default is therefore `DESTROY`. Change it to `RETAIN` if the messages are so
150 * valuable that accidentally losing them would be unacceptable.
151 *
152 * @default RemovalPolicy.DESTROY
153 */
154 readonly removalPolicy?: RemovalPolicy;
155}
156/**
157 * Dead letter queue settings
158 */
159export interface DeadLetterQueue {
160 /**
161 * The dead-letter queue to which Amazon SQS moves messages after the value of maxReceiveCount is exceeded.
162 */
163 readonly queue: IQueue;
164 /**
165 * The number of times a message can be unsuccesfully dequeued before being moved to the dead-letter queue.
166 */
167 readonly maxReceiveCount: number;
168}
169/**
170 * What kind of encryption to apply to this queue
171 */
172export declare enum QueueEncryption {
173 /**
174 * Messages in the queue are not encrypted
175 */
176 UNENCRYPTED = "NONE",
177 /**
178 * Server-side KMS encryption with a master key managed by SQS.
179 */
180 KMS_MANAGED = "MANAGED",
181 /**
182 * Server-side encryption with a KMS key managed by the user.
183 *
184 * If `encryptionKey` is specified, this key will be used, otherwise, one will be defined.
185 */
186 KMS = "KMS"
187}
188/**
189 * What kind of deduplication scope to apply
190 */
191export declare enum DeduplicationScope {
192 /**
193 * Deduplication occurs at the message group level
194 */
195 MESSAGE_GROUP = "messageGroup",
196 /**
197 * Deduplication occurs at the message queue level
198 */
199 QUEUE = "queue"
200}
201/**
202 * Whether the FIFO queue throughput quota applies to the entire queue or per message group
203 */
204export declare enum FifoThroughputLimit {
205 /**
206 * Throughput quota applies per queue
207 */
208 PER_QUEUE = "perQueue",
209 /**
210 * Throughput quota applies per message group id
211 */
212 PER_MESSAGE_GROUP_ID = "perMessageGroupId"
213}
214/**
215 * A new Amazon SQS queue
216 */
217export declare class Queue extends QueueBase {
218 /**
219 * Import an existing SQS queue provided an ARN
220 *
221 * @param scope The parent creating construct
222 * @param id The construct's name
223 * @param queueArn queue ARN (i.e. arn:aws:sqs:us-east-2:444455556666:queue1)
224 */
225 static fromQueueArn(scope: Construct, id: string, queueArn: string): IQueue;
226 /**
227 * Import an existing queue
228 */
229 static fromQueueAttributes(scope: Construct, id: string, attrs: QueueAttributes): IQueue;
230 /**
231 * The ARN of this queue
232 */
233 readonly queueArn: string;
234 /**
235 * The name of this queue
236 */
237 readonly queueName: string;
238 /**
239 * The URL of this queue
240 */
241 readonly queueUrl: string;
242 /**
243 * If this queue is encrypted, this is the KMS key.
244 */
245 readonly encryptionMasterKey?: kms.IKey;
246 /**
247 * Whether this queue is an Amazon SQS FIFO queue. If false, this is a standard queue.
248 */
249 readonly fifo: boolean;
250 /**
251 * If this queue is configured with a dead-letter queue, this is the dead-letter queue settings.
252 */
253 readonly deadLetterQueue?: DeadLetterQueue;
254 protected readonly autoCreatePolicy = true;
255 constructor(scope: Construct, id: string, props?: QueueProps);
256 /**
257 * Look at the props, see if the FIFO props agree, and return the correct subset of props
258 */
259 private determineFifoProps;
260}