AddPermissionCommand

Adds a statement to a topic's access control policy, granting access for the specified Amazon Web Services accounts to the specified actions.

To remove the ability to change topic permissions, you must deny permissions to the AddPermission, RemovePermission, and SetTopicAttributes actions in your IAM policy.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { SNSClient, AddPermissionCommand } from "@aws-sdk/client-sns"; // ES Modules import
// const { SNSClient, AddPermissionCommand } = require("@aws-sdk/client-sns"); // CommonJS import
const client = new SNSClient(config);
const input = { // AddPermissionInput
  TopicArn: "STRING_VALUE", // required
  Label: "STRING_VALUE", // required
  AWSAccountId: [ // DelegatesList // required
    "STRING_VALUE",
  ],
  ActionName: [ // ActionsList // required
    "STRING_VALUE",
  ],
};
const command = new AddPermissionCommand(input);
const response = await client.send(command);
// {};

AddPermissionCommand Input

See AddPermissionCommandInput for more details

Parameter
Type
Description
AWSAccountId
Required
string[] | undefined

The Amazon Web Services account IDs of the users (principals) who will be given access to the specified actions. The users must have Amazon Web Services account, but do not need to be signed up for this service.

ActionName
Required
string[] | undefined

The action you want to allow for the specified principal(s).

Valid values: Any Amazon SNS action name, for example Publish.

Label
Required
string | undefined

A unique identifier for the new policy statement.

TopicArn
Required
string | undefined

The ARN of the topic whose access control policy you wish to modify.

AddPermissionCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
AuthorizationErrorException
client

Indicates that the user has been denied access to the requested resource.

InternalErrorException
server

Indicates an internal service error.

InvalidParameterException
client

Indicates that a request parameter does not comply with the associated constraints.

NotFoundException
client

Indicates that the requested resource does not exist.

SNSServiceException
Base exception class for all service exceptions from SNS service.