0
# Queue Permissions
1
2
Queue permissions enable cross-account access and fine-grained authorization control for SQS queues through IAM-style policies and AWS account-based permission management.
3
4
## Add Permissions
5
6
### Add Queue Permission
7
8
Grant access to other AWS accounts or services for specific SQS operations.
9
10
```java { .api }
11
AddPermissionResult addPermission(AddPermissionRequest request);
12
13
// Convenience method
14
AddPermissionResult addPermission(String queueUrl, String label, List<String> aWSAccountIds, List<String> actions);
15
16
class AddPermissionRequest extends AmazonWebServiceRequest {
17
String getQueueUrl();
18
AddPermissionRequest withQueueUrl(String queueUrl);
19
20
String getLabel();
21
AddPermissionRequest withLabel(String label);
22
23
List<String> getAWSAccountIds();
24
AddPermissionRequest withAWSAccountIds(List<String> aWSAccountIds);
25
26
List<String> getActions();
27
AddPermissionRequest withActions(List<String> actions);
28
}
29
30
class AddPermissionResult {
31
// Empty result class - success indicated by no exception
32
}
33
```
34
35
**Usage Example:**
36
37
```java
38
// Grant cross-account access
39
List<String> accounts = Arrays.asList("123456789012", "123456789013");
40
List<String> actions = Arrays.asList("SendMessage", "ReceiveMessage");
41
42
AddPermissionRequest request = new AddPermissionRequest()
43
.withQueueUrl(queueUrl)
44
.withLabel("CrossAccountAccess")
45
.withAWSAccountIds(accounts)
46
.withActions(actions);
47
48
client.addPermission(request);
49
```
50
51
## Remove Permissions
52
53
### Remove Queue Permission
54
55
Remove previously granted permissions by label.
56
57
```java { .api }
58
RemovePermissionResult removePermission(RemovePermissionRequest request);
59
60
// Convenience method
61
RemovePermissionResult removePermission(String queueUrl, String label);
62
63
class RemovePermissionRequest extends AmazonWebServiceRequest {
64
String getQueueUrl();
65
RemovePermissionRequest withQueueUrl(String queueUrl);
66
67
String getLabel();
68
RemovePermissionRequest withLabel(String label);
69
}
70
71
class RemovePermissionResult {
72
// Empty result class - success indicated by no exception
73
}
74
```
75
76
**Usage Example:**
77
78
```java
79
// Remove previously granted permission
80
client.removePermission(new RemovePermissionRequest()
81
.withQueueUrl(queueUrl)
82
.withLabel("CrossAccountAccess"));
83
```