Creating a topic
-
In the management console
, select the folder. -
Navigate
to Cloud Notification Service. -
Select Topics on the left.
-
Click Create topic.
-
Enter a name for the topic. The name must be unique within Cloud Notification Service.
-
Optionally, set up logging:
- Under Logging, enable the Write logs option.
- In the Folder list, select a folder to house the log group.
- In the Log group field, select an existing log group or create a new one.
-
Optionally, enable Yandex Message Queue to send messages to Message Queue queues subscribed to the topic. Specify a service account assigned the
ymq.writerrole:- For the folder with the queues subscribed to the topic.
- For the folder with the service account itself.
-
Click Create topic.
-
If you do not have the AWS CLI yet, install and configure it.
-
Run this command:
aws sns create-topic \ --name <topic_name> \ --attributes "{\"SQSServiceAccountId\":\"<service_account_ID>\"}"Where:
name: Topic name, which can be any name unique within Cloud Notification Service.
-
SQSServiceAccountId: ID of the service account you are going to use to send messages from the topic to a Message Queue. This is an optional parameter. The service account must have theymq.writerrole:- For the folder with the queues subscribed to the topic.
- For the folder with the service account itself.
Note
To specify a service account in the
SQSServiceAccountIdattribute, the user must have theiam.serviceAccounts.userrole for the folder with the service account. Otherwise, the command will fail with an authorization error.
Learn more about the
aws sns create-topiccommand in this AWS guide .
-
If you do not have the AWS SDK for Python (boto3) yet, install and configure it.
-
Use the following code to create a topic:
response = client.create_topic( Name="<topic_name>", Attributes={ "SQSServiceAccountId": "<service_account_ID>", }, ) print(f"Topic ARN:", response['TopicArn'])Where:
Name: Topic name, which can be any name unique within Cloud Notification Service.
-
SQSServiceAccountId: ID of the service account you are going to use to send messages from the topic to a Message Queue. This is an optional parameter. The service account must have theymq.writerrole:- For the folder with the queues subscribed to the topic.
- For the folder with the service account itself.
Note
To specify a service account in the
SQSServiceAccountIdattribute, the user must have theiam.serviceAccounts.userrole for the folder with the service account. Otherwise, the command will fail with an authorization error.
Once you create a topic, you cannot change its name. To add endpoints to a topic, create subscriptions.