aws-cdk-lib.aws_sqs.IQueue

interface IQueue

LanguageType name
.NETAmazon.CDK.AWS.SQS.IQueue
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awssqs#IQueue
Javasoftware.amazon.awscdk.services.sqs.IQueue
Pythonaws_cdk.aws_sqs.IQueue
TypeScript (source)aws-cdk-lib » aws_sqs » IQueue

Implemented by Queue

Obtainable from Queue.fromQueueArn(), Queue.fromQueueAttributes()

Represents an SQS queue.

Properties

NameTypeDescription
envResourceEnvironmentThe environment this resource belongs to.
fifobooleanWhether this queue is an Amazon SQS FIFO queue.
nodeNodeThe tree node.
queueArnstringThe ARN of this queue.
queueNamestringThe name of this queue.
queueUrlstringThe URL of this queue.
stackStackThe stack in which this resource is defined.
encryptionMasterKey?IKeyIf this queue is server-side encrypted, this is the KMS encryption key.

env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


fifo

Type: boolean

Whether this queue is an Amazon SQS FIFO queue.

If false, this is a standard queue.


node

Type: Node

The tree node.


queueArn

Type: string

The ARN of this queue.


queueName

Type: string

The name of this queue.


queueUrl

Type: string

The URL of this queue.


stack

Type: Stack

The stack in which this resource is defined.


encryptionMasterKey?

Type: IKey (optional)

If this queue is server-side encrypted, this is the KMS encryption key.

Methods

NameDescription
addToResourcePolicy(statement)Adds a statement to the IAM resource policy associated with this queue.
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
grant(grantee, ...queueActions)Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource.
grantConsumeMessages(grantee)Grant permissions to consume messages from a queue.
grantPurge(grantee)Grant an IAM principal permissions to purge all messages from the queue.
grantSendMessages(grantee)Grant access to send messages to a queue to the given identity.
metric(metricName, props?)Return the given named metric for this Queue.
metricApproximateAgeOfOldestMessage(props?)The approximate age of the oldest non-deleted message in the queue.
metricApproximateNumberOfMessagesDelayed(props?)The number of messages in the queue that are delayed and not available for reading immediately.
metricApproximateNumberOfMessagesNotVisible(props?)The number of messages that are in flight.
metricApproximateNumberOfMessagesVisible(props?)The number of messages available for retrieval from the queue.
metricNumberOfEmptyReceives(props?)The number of ReceiveMessage API calls that did not return a message.
metricNumberOfMessagesDeleted(props?)The number of messages deleted from the queue.
metricNumberOfMessagesReceived(props?)The number of messages returned by calls to the ReceiveMessage action.
metricNumberOfMessagesSent(props?)The number of messages added to a queue.
metricSentMessageSize(props?)The size of messages added to a queue.

addToResourcePolicy(statement)

public addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResult

Parameters

  • statement PolicyStatement

Returns

  • AddToResourcePolicyResult

Adds a statement to the IAM resource policy associated with this queue.

If this queue was created in this stack (new Queue), a queue policy will be automatically created upon the first call to addToPolicy. If the queue is imported (Queue.import), then this is a no-op.


applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


grant(grantee, ...queueActions)

public grant(grantee: IGrantable, ...queueActions: string[]): Grant

Parameters

  • grantee IGrantable — Principal to grant right to.
  • queueActions string — The actions to grant.

Returns

  • Grant

Grant the actions defined in queueActions to the identity Principal given on this SQS queue resource.


grantConsumeMessages(grantee)

public grantConsumeMessages(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable — Principal to grant consume rights to.

Returns

  • Grant

Grant permissions to consume messages from a queue.

This will grant the following permissions:

  • sqs:ChangeMessageVisibility
  • sqs:DeleteMessage
  • sqs:ReceiveMessage
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl

grantPurge(grantee)

public grantPurge(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable — Principal to grant send rights to.

Returns

  • Grant

Grant an IAM principal permissions to purge all messages from the queue.

This will grant the following permissions:

  • sqs:PurgeQueue
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl

grantSendMessages(grantee)

public grantSendMessages(grantee: IGrantable): Grant

Parameters

  • grantee IGrantable — Principal to grant send rights to.

Returns

  • Grant

Grant access to send messages to a queue to the given identity.

This will grant the following permissions:

  • sqs:SendMessage
  • sqs:GetQueueAttributes
  • sqs:GetQueueUrl

metric(metricName, props?)

public metric(metricName: string, props?: MetricOptions): Metric

Parameters

  • metricName string
  • props MetricOptions

Returns

  • Metric

Return the given named metric for this Queue.


metricApproximateAgeOfOldestMessage(props?)

public metricApproximateAgeOfOldestMessage(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The approximate age of the oldest non-deleted message in the queue.

Maximum over 5 minutes


metricApproximateNumberOfMessagesDelayed(props?)

public metricApproximateNumberOfMessagesDelayed(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages in the queue that are delayed and not available for reading immediately.

Maximum over 5 minutes


metricApproximateNumberOfMessagesNotVisible(props?)

public metricApproximateNumberOfMessagesNotVisible(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages that are in flight.

Maximum over 5 minutes


metricApproximateNumberOfMessagesVisible(props?)

public metricApproximateNumberOfMessagesVisible(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages available for retrieval from the queue.

Maximum over 5 minutes


metricNumberOfEmptyReceives(props?)

public metricNumberOfEmptyReceives(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of ReceiveMessage API calls that did not return a message.

Sum over 5 minutes


metricNumberOfMessagesDeleted(props?)

public metricNumberOfMessagesDeleted(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages deleted from the queue.

Sum over 5 minutes


metricNumberOfMessagesReceived(props?)

public metricNumberOfMessagesReceived(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages returned by calls to the ReceiveMessage action.

Sum over 5 minutes


metricNumberOfMessagesSent(props?)

public metricNumberOfMessagesSent(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The number of messages added to a queue.

Sum over 5 minutes


metricSentMessageSize(props?)

public metricSentMessageSize(props?: MetricOptions): Metric

Parameters

  • props MetricOptions

Returns

  • Metric

The size of messages added to a queue.

Average over 5 minutes