Namespace Amazon.CDK.AWS.SQS
Amazon Simple Queue Service Construct Library
Amazon Simple Queue Service (SQS) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. SQS eliminates the complexity and overhead associated with managing and operating message oriented middleware, and empowers developers to focus on differentiating work. Using SQS, you can send, store, and receive messages between software components at any volume, without losing messages or requiring other services to be available.
Installation
Import to your project:
using Amazon.CDK.AWS.SQS;
Basic usage
Here's how to add a basic queue to your application:
new Queue(this, "Queue");
Encryption
By default queues are encrypted using SSE-SQS. If you want to change the encryption mode, set the encryption
property.
The following encryption modes are supported:
To learn more about SSE-SQS on Amazon SQS, please visit the Amazon SQS documentation.
// Use managed key
// Use managed key
new Queue(this, "Queue", new QueueProps {
Encryption = QueueEncryption.KMS_MANAGED
});
// Use custom key
var myKey = new Key(this, "Key");
new Queue(this, "Queue", new QueueProps {
Encryption = QueueEncryption.KMS,
EncryptionMasterKey = myKey
});
// Use SQS managed server side encryption (SSE-SQS)
// Use SQS managed server side encryption (SSE-SQS)
new Queue(this, "Queue", new QueueProps {
Encryption = QueueEncryption.SQS_MANAGED
});
// Unencrypted queue
// Unencrypted queue
new Queue(this, "Queue", new QueueProps {
Encryption = QueueEncryption.UNENCRYPTED
});
Encryption in transit
If you want to enforce encryption of data in transit, set the enforceSSL
property to true
.
A resource policy statement that allows only encrypted connections over HTTPS (TLS)
will be added to the queue.
new Queue(this, "Queue", new QueueProps {
EnforceSSL = true
});
First-In-First-Out (FIFO) queues
FIFO queues give guarantees on the order in which messages are dequeued, and have additional features in order to help guarantee exactly-once processing. For more information, see the SQS manual. Note that FIFO queues are not available in all AWS regions.
A queue can be made a FIFO queue by either setting fifo: true
, giving it a name which ends
in ".fifo"
, or by enabling a FIFO specific feature such as: content-based deduplication,
deduplication scope or fifo throughput limit.
Dead letter source queues permission
You can configure the permission settings for queues that can designate the created queue as their dead-letter queue using the redriveAllowPolicy
attribute.
By default, all queues within the same account and region are permitted as source queues.
IQueue sourceQueue;
// Only the sourceQueue can specify this queue as the dead-letter queue.
var queue1 = new Queue(this, "Queue2", new QueueProps {
RedriveAllowPolicy = new RedriveAllowPolicy {
SourceQueues = new [] { sourceQueue }
}
});
// No source queues can specify this queue as the dead-letter queue.
var queue2 = new Queue(this, "Queue", new QueueProps {
RedriveAllowPolicy = new RedriveAllowPolicy {
RedrivePermission = RedrivePermission.DENY_ALL
}
});
Classes
CfnQueue | The |
CfnQueueInlinePolicy | The |
CfnQueueInlinePolicyProps | Properties for defining a |
CfnQueuePolicy | The |
CfnQueuePolicyProps | Properties for defining a |
CfnQueueProps | Properties for defining a |
DeadLetterQueue | Dead letter queue settings. |
DeduplicationScope | What kind of deduplication scope to apply. |
FifoThroughputLimit | Whether the FIFO queue throughput quota applies to the entire queue or per message group. |
Queue | A new Amazon SQS queue. |
QueueAttributes | Reference to a queue. |
QueueBase | Reference to a new or existing Amazon SQS queue. |
QueueEncryption | What kind of encryption to apply to this queue. |
QueuePolicy | The policy for an SQS Queue. |
QueuePolicyProps | Properties to associate SQS queues with a policy. |
QueueProps | Properties for creating a new Queue. |
RedriveAllowPolicy | Permission settings for the dead letter source queue. |
RedrivePermission | The permission type that defines which source queues can specify the current queue as the dead-letter queue. |
Interfaces
ICfnQueueInlinePolicyProps | Properties for defining a |
ICfnQueuePolicyProps | Properties for defining a |
ICfnQueueProps | Properties for defining a |
IDeadLetterQueue | Dead letter queue settings. |
IQueue | Represents an SQS queue. |
IQueueAttributes | Reference to a queue. |
IQueuePolicyProps | Properties to associate SQS queues with a policy. |
IQueueProps | Properties for creating a new Queue. |
IRedriveAllowPolicy | Permission settings for the dead letter source queue. |