April 2018
Intermediate to advanced
280 pages
8h 37m
English
An SNS topic can be created by invoking the create_topic() function of the sns_client object. The result is the Python dictionary that represents the SNS topic. Once an SNS topic is created, AWS automatically assigns a unique ARN to the topic. This ARN can be fetched using the TopicARN key of the SNS topic.
The following Python program demonstrates the creation of an SNS topic:
import boto3# Create an SNS client objectsns_client = boto3.client( "sns", # You may have to set the AWS credentials of you haven't already set using AWS CLI # aws_access_key_id="YOUR ACCES KEY", # aws_secret_access_key="YOUR SECRET KEY", # region_name=us-east-1)# Create an SNS topicsns_topic = sns_client.create_topic(Name="packt-pub")topic_arn = ...