Abonnements SNS

Introduction à AWS Boto en Python

Maksim Pecherskiy

Data Engineer

Liste des abonnements

Liste des abonnements

Introduction à AWS Boto en Python

Liste des abonnements

Liste des abonnements

Introduction à AWS Boto en Python

Liste des abonnements

Liste des abonnements

Introduction à AWS Boto en Python

Liste des abonnements

Liste des abonnements

Introduction à AWS Boto en Python

Créer un abonnement SMS.

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')
Introduction à AWS Boto en Python

Créer un abonnement SMS.

Créer un abonnement SMS

Introduction à AWS Boto en Python

Créer un abonnement email

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

Créer un abonnement email

Créer un abonnement email

Introduction à AWS Boto en Python

Créer un abonnement email

Créer un abonnement email

Adresse email confirmée Confirmer l'email

Introduction à AWS Boto en Python

Lister les abonnements par sujet

sns.list_subscriptions_by_topic(
  TopicArn='arn:aws:sns:us-east-1:320333787981:city_alerts')
Introduction à AWS Boto en Python

Lister les abonnements

Lister les abonnements

Introduction à AWS Boto en Python

Lister les abonnements

sns.list_subscriptions()['Subscriptions']
Introduction à AWS Boto en Python

Supprimer des abonnements

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

Supprimer plusieurs abonnements

Obtenir la liste des abonnements

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

Se désabonner des abonnements SMS

for sub in subs:
  if sub['Protocol'] == 'sms':
    sns.unsubscribe(sub['SubscriptionArn'])
Introduction à AWS Boto en Python

Récapitulatif

SMS
  • Protocol='sms'
  • Endpoint='+13122334433'
  • Status: 'confirmed'
Email
Introduction à AWS Boto en Python

Récapitulatif

Créer un abonnement

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

Lister les abonnements par sujet

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

Récapitulatif

Lister les abonnements

sns.list_subscriptions()['Subscriptions']

Supprimer un abonnement

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

Passons à la pratique !

Introduction à AWS Boto en Python

Preparing Video For Download...