1 | # Amazon Simple Queue Service Construct Library
|
2 |
|
3 |
|
4 | ---
|
5 |
|
6 | ![End-of-Support](https://img.shields.io/badge/End--of--Support-critical.svg?style=for-the-badge)
|
7 |
|
8 | > AWS CDK v1 has reached End-of-Support on 2023-06-01.
|
9 | > This package is no longer being updated, and users should migrate to AWS CDK v2.
|
10 | >
|
11 | > For more information on how to migrate, see the [_Migrating to AWS CDK v2_ guide][doc].
|
12 | >
|
13 | > [doc]: https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html
|
14 |
|
15 | ---
|
16 |
|
17 |
|
18 |
|
19 | Amazon Simple Queue Service (SQS) is a fully managed message queuing service that
|
20 | enables you to decouple and scale microservices, distributed systems, and serverless
|
21 | applications. SQS eliminates the complexity and overhead associated with managing and
|
22 | operating message oriented middleware, and empowers developers to focus on differentiating work.
|
23 | Using SQS, you can send, store, and receive messages between software components at any volume,
|
24 | without losing messages or requiring other services to be available.
|
25 |
|
26 | ## Installation
|
27 |
|
28 | Import to your project:
|
29 |
|
30 | ```ts nofixture
|
31 | import * as sqs from '@aws-cdk/aws-sqs';
|
32 | ```
|
33 |
|
34 | ## Basic usage
|
35 |
|
36 |
|
37 | Here's how to add a basic queue to your application:
|
38 |
|
39 | ```ts
|
40 | new sqs.Queue(this, 'Queue');
|
41 | ```
|
42 |
|
43 | ## Encryption
|
44 |
|
45 | If you want to encrypt the queue contents, set the `encryption` property. You can have
|
46 | the messages encrypted with a key that SQS manages for you, or a key that you
|
47 | can manage yourself.
|
48 |
|
49 | ```ts
|
50 | // Use managed key
|
51 | new sqs.Queue(this, 'Queue', {
|
52 | encryption: sqs.QueueEncryption.KMS_MANAGED,
|
53 | });
|
54 |
|
55 | // Use custom key
|
56 | const myKey = new kms.Key(this, 'Key');
|
57 |
|
58 | new sqs.Queue(this, 'Queue', {
|
59 | encryption: sqs.QueueEncryption.KMS,
|
60 | encryptionMasterKey: myKey,
|
61 | });
|
62 | ```
|
63 |
|
64 | ## First-In-First-Out (FIFO) queues
|
65 |
|
66 | FIFO queues give guarantees on the order in which messages are dequeued, and have additional
|
67 | features in order to help guarantee exactly-once processing. For more information, see
|
68 | the SQS manual. Note that FIFO queues are not available in all AWS regions.
|
69 |
|
70 | A queue can be made a FIFO queue by either setting `fifo: true`, giving it a name which ends
|
71 | in `".fifo"`, or by enabling a FIFO specific feature such as: content-based deduplication,
|
72 | deduplication scope or fifo throughput limit.
|