# QueueGrants

Facade · Stable

Collection of grant methods for a IQueueRef.

Obtainable from: QueueGrants.fromQueue

- Source: Generated at build time
- Type last changed: v2.244.0 · 19 Mar 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_sqs as sqs } from 'aws-cdk-lib';
import { aws_sqs as interfaces_sqs } from 'aws-cdk-lib/interfaces';

declare const queueRef: interfaces_sqs.IQueueRef;
const queueGrants = sqs.QueueGrants.fromQueue(queueRef);
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_sqs as sqs
from aws_cdk.interfaces import aws_sqs as interfaces_sqs

# queue_ref: interfaces_sqs.IQueueRef

queue_grants = sqs.QueueGrants.from_queue(queue_ref)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.sqs.*;
import software.amazon.awscdk.interfaces.sqs.*;

IQueueRef queueRef;

QueueGrants queueGrants = QueueGrants.fromQueue(queueRef);
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.SQS;
using Amazon.CDK.Interfaces.SQS;

IQueueRef queueRef;

var queueGrants = QueueGrants.FromQueue(queueRef);
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var queueRef IQueueRef

queueGrants := awscdk.Aws_sqs.QueueGrants_FromQueue(queueRef)
```

## Methods

- `actions(grantee: IGrantable, actions: string[], options?: EncryptedPermissionsOptions): Grant` — Grant the given identity custom permissions.

- `consumeMessages(grantee: IGrantable): 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

  If encryption is used, permission to use the key to decrypt the contents of the queue will also be granted to the same principal.

  This will grant the following KMS permissions:

    - kms:Decrypt

- `fromQueue(resource: IQueueRef): QueueGrants // chainable` (static) — Creates grants for QueueGrants.

- `purge(grantee: IGrantable): Grant` — Grants purge permissions.

- `sendMessages(grantee: IGrantable): 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

  If encryption is used, permission to use the key to encrypt/decrypt the contents of the queue will also be granted to the same principal.

  This will grant the following KMS permissions:

   - kms:Decrypt
   - kms:Encrypt
   - kms:ReEncrypt*
   - kms:GenerateDataKey*
