发送警报
Elena Block 是 Sam 的老朋友,也是市议员成员,她正在竞选公职。坑洞问题在她的选区很严重,她想帮忙解决。

Elena 要求 Sam 调整 streets_critical topic,当未修复的坑洞积压数量超过 100 时发送警报。
Sam 已将 boto3 的 SNS 客户端创建在变量 sns 中。她把 streets_critical 的 topic ARN 存在变量 str_critical_arn 中。
请帮 Sam 继续下一步。
她需要检查当前积压数量,仅当其超过 100 时才发送消息。
第 12 选区的命运,以及 Elena 的选举结果,就取决于您和 Sam 了。
本练习是课程的一部分
Python 中的 AWS Boto 入门
练习说明
- 如果坑洞数量超过 100,发送包含当前积压数量的消息。
- 创建邮件主题时也包含当前积压数量。
- 将消息发布到
streets_critical的 Topic ARN。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# If there are over 100 potholes, create a message
if streets_v_count > 100:
# The message should contain the number of potholes.
message = "There are {} potholes!".____(streets_v_count)
# The email subject should also contain number of potholes
subject = "Latest pothole count is {}".____(streets_v_count)
# Publish the email to the streets_critical topic
sns.____(
____ = str_critical_arn,
# Set subject and message
____ = ____,
____ = ____
)