创建主题
Sam 运用新技能表现出色,刚刚获得了晋升。
她的新头衔是 Information Systems Analyst 3(从 2 升到 3)。她的薪水小幅上涨,但工作量大增。
市议会了解她的能力后,要求 Sam 试做一个告警系统:当任何部门有超过 100 个未处理的 Get It Done 请求时,向他们发出告警。
他们希望议员和各部门主管都能收到该告警。
请帮助 Sam 利用她对 Amazon SNS 的新知识,为市议会创建一个告警系统!
本练习是课程的一部分
Python 中的 AWS Boto 入门
练习说明
- 初始化 SNS 的
boto3客户端。 - 创建
'city_alerts'主题并提取其主题 ARN。 - 使用一行代码重新创建
'city_alerts'主题并提取其主题 ARN。 - 验证两个主题 ARN 是否一致。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Initialize boto3 client for SNS
sns = boto3.client('____',
region_name='us-east-1',
aws_access_key_id=AWS_KEY_ID,
aws_secret_access_key=AWS_SECRET)
# Create the city_alerts topic
response = sns.____(____="____")
c_alerts_arn = response['____']
# Re-create the city_alerts topic using a oneliner
c_alerts_arn_1 = sns.____(____='____')['____']
# Compare the two to make sure they match
print(c_alerts_arn == c_alerts_arn_1)