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