LoslegenKostenlos loslegen

Deleting multiple subscriptions

Now that Sam has a maturing notification system, she is learning that the types of alerts she sends do not bode well for text messaging.

SMS alerts are great if the user can react that minute, but "We are 500 potholes behind" is not something that a Council Member can jump up and fix.

She decides to remove all SMS subscribers from the streets_critical topic, but keep all email subscriptions.

She created the boto3 SNS client in the sns variable, and the streets_critical topic ARN is in the str_critical_arn variable.

In this exercise, you will help Sam remove all SMS subscribers and make this an email only alerting system.

Diese Übung ist Teil des Kurses

Introduction to AWS Boto in Python

Kurs anzeigen

Anleitung zur Übung

  • List subscriptions for 'streets_critical' topic.
  • For each subscription, if the protocol is 'sms', unsubscribe.
  • List subscriptions for 'streets_critical' topic in one line.
  • Print the subscriptions

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# List subscriptions for streets_critical topic.
response = sns.____(
  ____ = str_critical_arn)

# For each subscription, if the protocol is SMS, unsubscribe
for sub in response['____']:
  if sub['Protocol'] == 'sms':
	  sns.____(____=sub['SubscriptionArn'])

# List subscriptions for streets_critical topic in one line
subs = sns.list_subscriptions_by_topic(
  ____=str_critical_arn)['____']

# Print the subscriptions
print(subs)
Code bearbeiten und ausführen