SNS Subscriptions

Introducción a AWS Boto en Python

Maksim Pecherskiy

Data Engineer

Subscription Listing

Subscription Listing

Introducción a AWS Boto en Python

Subscription Listing

Subscription Listing

Introducción a AWS Boto en Python

Subscription Listing

Subscription Listing

Introducción a AWS Boto en Python

Subscription Listing

Subscription Listing

Introducción a AWS Boto en Python

Creating an SMS subscription.

sns = boto3.client('sns', 
                   region_name='us-east-1', 
                   aws_access_key_id=AWS_KEY_ID,                   
                   aws_secret_access_key=AWS_SECRET)
response = sns.subscribe(
  TopicArn = 'arn:aws:sns:us-east-1:320333787981:city_alerts',
  Protocol = 'SMS',
  Endpoint = '+13125551123')
Introducción a AWS Boto en Python

Create an SMS subscription.

Create SMS subscription

Introducción a AWS Boto en Python

Creating an email subscription

response = sns.subscribe(
  TopicArn = 'arn:aws:sns:us-east-1:320333787981:city_alerts', 
  Protocol='email', 
  Endpoint='[email protected]')
Introducción a AWS Boto en Python

Creating an email subscription

Create an email subscription

Introducción a AWS Boto en Python

Creating an email subscription

Create an email subscription

Confirmed email address Confirm email

Introducción a AWS Boto en Python

Listing subscriptions by Topic

sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
Introducción a AWS Boto en Python

Listing subscriptions

Listing subscription

Introducción a AWS Boto en Python

Listing subscriptions

sns.list_subscriptions()['Subscriptions']
Introducción a AWS Boto en Python

Deleting subscriptions

sns.unsubscribe(
  SubscriptionArn='arn:aws:sns:us-east-1:320333787981:city_alerts:9f2dad1d-8844-4fe8-86f7-3f627ae8420f'
)
Introducción a AWS Boto en Python

Deleting multiple subscriptions

Get list of subscriptions

response = sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
subs = response['Subscriptions']

Unsubscribe SMS subscriptions

for sub in subs:
  if sub['Protocol'] == 'sms':
    sns.unsubscribe(sub['SubscriptionArn'])
Introducción a AWS Boto en Python

Review

SMS
  • Protocol='sms'
  • Endpoint='+13122334433'
  • Status: 'confirmed'
Email
Introducción a AWS Boto en Python

Review

Create a subscription

response = sns.subscribe(
  TopicArn = 'arn:aws:sns:us-east-1:320333787981:city_alerts',
  Protocol = 'sms',
  Endpoint = '+13125551123')

List subscriptions by topic

response = sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
subs = response['Subscriptions']
Introducción a AWS Boto en Python

Review

List subscriptions

sns.list_subscriptions()['Subscriptions']

Delete a subscription

sns.unsubscribe(
  SubscriptionArn='arn:aws:sns:us-east-1:320333787981:city_alerts:9f2dad1d-8844-4fe8-86f7-3f627ae8420f'
)
Introducción a AWS Boto en Python

Let's practice!

Introducción a AWS Boto en Python

Preparing Video For Download...