Skip to content

Commit

Permalink
Fix for event payload parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
rjulian committed Sep 21, 2020
1 parent 624a643 commit 2ebe0b1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions source/reflex_aws_rds_deletion_protection_disabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def __init__(self, event):

def extract_event_data(self, event):
""" Extract required event data """
self.db_instance_id = event["detail"]["requestParameters"]["dBInstanceIdentifier"]
self.deletion_protection = event["detail"]["requestParameters"]["deletionProtection"]
self.db_instance_id = event["detail"]["requestParameters"][
"dBInstanceIdentifier"
]
self.deletion_protection = event["detail"]["requestParameters"][
"deletionProtection"
]

def resource_compliant(self):
"""
Expand All @@ -34,8 +38,9 @@ def get_remediation_message(self):
def lambda_handler(event, _):
""" Handles the incoming event """
print(event)
if subscription_confirmation.is_subscription_confirmation(event):
subscription_confirmation.confirm_subscription(event)
event_payload = json.loads(event["Records"][0]["body"])
if subscription_confirmation.is_subscription_confirmation(event_payload):
subscription_confirmation.confirm_subscription(event_payload)
return
rule = RDSDeletionProtectionDisabled(json.loads(event["Records"][0]["body"]))
rule = RDSDeletionProtectionDisabled(event_payload)
rule.run_compliance_rule()

0 comments on commit 2ebe0b1

Please sign in to comment.