Different protocols per topic level
Now that Sam has created the critical and extreme topics, she needs to subscribe the staff from her contact list into these topics.
Sam decided that the people subscribed to 'critical'
topics will only receive emails. On the other hand, people subscribed to 'extreme'
topics will receive SMS - because those are pretty urgent.
She has already created the boto3
SNS client in the sns
variable.
Help Sam subscribe the users in the contacts
DataFrame to email or SMS notifications based on their department.
This will help get the right alerts to the right people, making the City of San Diego run better and faster!
This exercise is part of the course
Introduction to AWS Boto in Python
Exercise instructions
- Get the topic name by using the
'Department'
field in thecontacts
DataFrame. - Use the topic name to create the
critical
andextreme
TopicArns for a user's department. - Subscribe the user's email address to the critical topic.
- Subscribe the user's phone number to the extreme topic.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
for index, user_row in contacts.iterrows():
# Get topic names for the users's dept
critical_tname = '{}_critical'.____(user_row['Department'])
extreme_tname = '{}_extreme'.format(user_row['Department'])
# Get or create the TopicArns for a user's department.
critical_arn = sns.create_topic(____=critical_tname)['TopicArn']
extreme_arn = sns.____(Name=extreme_tname)['____']
# Subscribe each users email to the critical Topic
sns.____(____ = critical_arn,
____='email', ____=user_row['Email'])
# Subscribe each users phone number for the extreme Topic
sns.____(____ = extreme_arn,
____='sms', ____=str(user_row['Phone']))