# Security in Queues

Who may do what with a queue (IAM), which calls are audited, and how API and SQS clients authenticate.

## IAM actions

Every request, through the API, the CLI, the console or the SQS endpoint, is checked against your
IAM policies. A queue's resource name is `rn:ews:<region>:<organization id>:queue:queue/<queue name>`,
for example `rn:ews:de1:<organization id>:queue:queue/my-queue`.

(The table of IAM actions is generated on the web page.)
- The message actions (`queue:SendMessage`, `queue:ReceiveMessage`, `queue:DeleteMessage`,
  `queue:ChangeMessageVisibility`) are writes: a receive hides a message from your other consumers.
  The preset `QueueReadOnlyAccess` can see queues and their counts, but not send, receive or
  delete.
- A redrive needs `queue:StartMessageMoveTask` on the dead-letter queue and `queue:SendMessage` on
  every queue the messages go to.
- The batch operations need the action of their single form.

A worker that only consumes _my-queue_ through the API needs this policy (replace _org-id_ with
your organization id). A worker that uses an SQS client and looks the queue up with `GetQueueUrl`
also needs `queue:GetQueueAttributes`.

```json
{
  "Version": "2024-01-01",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["queue:ReceiveMessage", "queue:DeleteMessage", "queue:ChangeMessageVisibility"],
      "Resource": "rn:ews:de1:org-id:queue:queue/my-queue"
    }
  ]
}
```

## Audit

Creating, changing, purging and deleting queues, and redrives, are recorded in the audit log like
every other change. Sending, receiving, deleting and changing the visibility of messages are not
recorded when they are allowed, as they happen thousands of times a minute; a denied attempt is
recorded.

## Authentication

- **API and CLI:** an access key in the `Authorization: EWS-ACCESS-KEY <key id>:<secret>` header,
  or the CLI's sign-in. The console uses your session.
- **SQS endpoint:** requests signed with Signature Version 4 with an access key from
  **Identity**, **Access keys**, a legacy Object Storage key (`EWSS3…`), or temporary credentials
  with their session token. See [Use an SQS client](use-an-sqs-client.md).

Either way the key acts as its IAM user, and a key with a limit can do no more than its limit
allows. Both surfaces see only the queues of the key's organization.

## Related

- [Use an SQS client](use-an-sqs-client.md)
- [Quotas](quotas.md)
