Creating multiple subscriptions
After the successful pilot with Councilwoman Elena Block, other City Council members have been asking to be signed up for alerts too.
Sam decides that she should manage subscribers in a CSV file, otherwise she would lose track of who needs to be subscribed to what.
She creates a CSV named contacts and decides to subscribe everyone in the CSV to the streets_critical topic.
She has created the boto3 SNS client in the sns variable, and the streets_critical topic ARN is in the str_critical_arn variable.
Sam is going from being a social pariah to being courted by multiple council offices.
Help her solidify her position as master of all information by adding all the users in her CSV to the streets_critical topic!
Este exercício faz parte do curso
Introduction to AWS Boto in Python
Instruções do exercício
- For each element in the
Emailcolumn ofcontacts, create a subscription to the'streets_critical'Topic. - List subscriptions for the
'streets_critical'Topic and convert them to a DataFrame. - Preview the DataFrame.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# For each email in contacts, create subscription to street_critical
for email in contacts['____']:
sns.____(____ = str_critical_arn,
# Set channel and recipient
____ = '____',
____ = ____)
# List subscriptions for streets_critical topic, convert to DataFrame
response = sns.____(
____ = str_critical_arn)
subs = pd.DataFrame(response['____'])
# Preview the DataFrame
subs.head()