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!
Este exercício faz parte do curso
Introduction to AWS Boto in Python
Instruções do exercício
- Get the topic name by using the
'Department'field in thecontactsDataFrame. - Use the topic name to create the
criticalandextremeTopicArns 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.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
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']))