UNPKG

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