建立主題
Sam 憑著她的新技能表現出色,獲得了升遷。
她的新職稱是「資訊系統分析師 3」(而不是 2)。雖然加薪幅度不大,但工作量大增。
市議會知道她的能力後,請 Sam 打造一個警示系統:只要任何部門有超過 100 件尚未完成的 Get It Done 需求,就發出警示。
他們希望議員與各部門主管都能收到這些警示。
請協助 Sam 運用她對 Amazon SNS 的新知,替市議會建立一個警示系統!
本練習屬於課程
Python 中的 AWS Boto 入門
練習說明
- 初始化
boto3的 SNS 用戶端。 - 建立
'city_alerts'主題並擷取其 topic ARN。 - 以一行程式碼重新建立
'city_alerts'主題並擷取其 topic ARN。 - 驗證兩個 topic 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)