diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 683cdff..f936de9 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -3256,25 +3256,28 @@ def discover_emr_master(tags): def evaluate_event_action(event): - """ - This takes the EventBridge event and returns a DNS action to take (ADD|REMOVE) based on running or not-running (stopping, terminating). If not an ec2 event, it returns None. - - :param dict(str) event: Event dict from handler - :return str: DNS action, either ADD (to create records) or REMOVE (to delete records) - e_source = event['source'] - action=None - try: - if e_source=='aws.ec2': - e_instance_id = event['detail']['instance-id'] - e_state = event['detail']['state'] - action="ADD" if e_state == "running" else "DELETE" - LOGGER.info(f"event_action ** {action} ** instance_id {instance_id} instance_state {e_state}") - else: - LOGGER.info(f"event_action unrecognized source {e_source}") - except: - LOGGER.error(f"event_action event structure cannot be parsed {lineno()}") - return action - + """ + This takes the EventBridge event and returns a DNS action to take (ADD|REMOVE) based on running or not-running (stopping, terminating). If not an ec2 event, it returns None. + + :param dict(str) event: Event dict from handler + :return str: DNS action, either ADD (to create records) or REMOVE (to delete records) + """ + + e_source = event['source'] + action = None + try: + if e_source == 'aws.ec2': + e_instance_id = event['detail']['instance-id'] + e_state = event['detail']['state'] + action = "ADD" if e_state == "running" else "DELETE" + LOGGER.info( + f"event_action ** {action} ** instance_id {instance_id} instance_state {e_state}") + else: + LOGGER.info(f"event_action unrecognized source {e_source}") + except: + LOGGER.error(f"event_action event structure cannot be parsed {lineno()}") + return action + ## # aws: elasticmapreduce: job - flow - id        j - 8O514K6HPIYZ diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index 01c4ea4..5ecb58c 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ