Aan de slagGa gratis aan de slag

Sending multi-level alerts

Sam is going to prototype her alerting system with the water data and the water department.

According to the Director, when there are over 100 alerts outstanding, that's considered critical. If there are over 300, that's extreme.

She has done some calculations and came up with a vcounts dictionary, that contains current requests for 'water', 'streets' and 'trash'.

She has also already created the boto3 SNS client and stored it in the sns variable.

In this exercise, you will help Sam publish a critical and an extreme alert based on the thresholds!

Deze oefening maakt deel uit van de cursus

Introduction to AWS Boto in Python

Cursus bekijken

Oefeninstructies

  • If there are over 100 water violations, publish to 'water_critical' topic.
  • If there are over 300 water violations, publish to 'water_extreme' topic.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

if vcounts['water'] > 100:
  # If over 100 water violations, publish to water_critical
  sns.____(
    ____ = dept_arns['water_critical'],
    ____ = "{} water issues".format(vcounts['water']),
    ____ = "Help fix water violations NOW!")

if vcounts['water'] > 300:
  # If over 300 violations, publish to water_extreme
  sns.____(
    TopicArn = dept_arns['water_extreme'],
    ____ = "{} violations! RUN!".format(vcounts['water']),
    Subject = "THIS IS BAD.  WE ARE FLOODING!")
Code bewerken en uitvoeren