Fix: Cloudwatch delete Alarm status code handling on invalid alarm name (#3028)

* CloudWwatch delete Alarm status code handling on invalid alarm Name

* Handled cases where a mix of existent and non existent alarms are tried to delete

* Linting

Co-authored-by: usmankb <usman@krazybee.com>
Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
usmangani1 2020-05-28 20:22:56 +05:30 committed by GitHub
commit 7a6d78afde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View file

@ -304,6 +304,13 @@ class CloudWatchBackend(BaseBackend):
)
def delete_alarms(self, alarm_names):
for alarm_name in alarm_names:
if alarm_name not in self.alarms:
raise RESTError(
"ResourceNotFound",
"Alarm {0} not found".format(alarm_name),
status=404,
)
for alarm_name in alarm_names:
self.alarms.pop(alarm_name, None)