- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
SetQueueAttributesCommand
Sets the value of one or more queue attributes, like a policy. When you change a queue's attributes, the change can take up to 60 seconds for most of the attributes to propagate throughout the Amazon SQS system. Changes made to the MessageRetentionPeriod
attribute can take up to 15 minutes and will impact existing messages in the queue potentially causing them to be expired and deleted if the MessageRetentionPeriod
is reduced below the age of existing messages.
-
In the future, new attributes might be added. If you write code that calls this action, we recommend that you structure your code so that it can handle new attributes gracefully.
-
Cross-account permissions don't apply to this action. For more information, see Grant cross-account permissions to a role and a username in the Amazon SQS Developer Guide.
-
To remove the ability to change queue permissions, you must deny permission to the
AddPermission
,RemovePermission
, andSetQueueAttributes
actions in your IAM policy.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { SQSClient, SetQueueAttributesCommand } from "@aws-sdk/client-sqs"; // ES Modules import
// const { SQSClient, SetQueueAttributesCommand } = require("@aws-sdk/client-sqs"); // CommonJS import
const client = new SQSClient(config);
const input = { // SetQueueAttributesRequest
QueueUrl: "STRING_VALUE", // required
Attributes: { // QueueAttributeMap // required
"<keys>": "STRING_VALUE",
},
};
const command = new SetQueueAttributesCommand(input);
const response = await client.send(command);
// {};
SetQueueAttributesCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
Attributes Required | Partial<Record<QueueAttributeName, string> | undefined | A map of attributes to set. The following lists the names, descriptions, and values of the special request parameters that the
The following attributes apply only to dead-letter queues:
The dead-letter queue of a FIFO queue must also be a FIFO queue. Similarly, the dead-letter queue of a standard queue must also be a standard queue. The following attributes apply only to server-side-encryption :
The following attribute applies only to FIFO (first-in-first-out) queues :
The following attributes apply only to high throughput for FIFO queues :
To enable high throughput for FIFO queues, do the following:
If you set these attributes to anything other than the values shown for enabling high throughput, normal throughput is in effect and deduplication occurs as specified. For information on throughput quotas, see Quotas related to messages in the Amazon SQS Developer Guide. |
QueueUrl Required | string | undefined | The URL of the Amazon SQS queue whose attributes are set. Queue URLs and names are case-sensitive. |
SetQueueAttributesCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InvalidAddress | client | The specified ID is invalid. |
InvalidAttributeName | client | The specified attribute doesn't exist. |
InvalidAttributeValue | client | A queue attribute value is invalid. |
InvalidSecurity | client | The request was not made over HTTPS or did not use SigV4 for signing. |
OverLimit | client | The specified action violates a limit. For example, |
QueueDoesNotExist | client | Ensure that the |
RequestThrottled | client | The request was denied due to request throttling.
|
UnsupportedOperation | client | Error code 400. Unsupported operation. |
SQSServiceException | Base exception class for all service exceptions from SQS service. |