diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index 8ac0262..f3cdce8 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -73,7 +73,7 @@ LOGGER = logging.getLogger() account_id = None region = None -VERSION = '1.2.0b60' +VERSION = '1.2.0b61' # Read Env variables DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO') @@ -1028,7 +1028,7 @@ def lambda_handler( # update ddb entry to include dns entries written to be able to delete them properly if state == 'running': try: - instance['_DnsEntries'] = [dict(d._asdict()) for d in dns] + instance['_DnsEntries'] = [dict(d._asdict()) for d in dns_data] instance = remove_empty_from_dict(instance) instance_dump = json.dumps(instance, default=json_serial) instance_attributes = instance_dump @@ -3142,6 +3142,26 @@ def create_fqdn(host, zone): fqdn += '.' if fqdn[-1] != '.' else '' return fqdn + +def discover_emr_master(tags): + """ + This tags a dict of tags and determines if the appropriate EMR tags are set. + + If set, this is a member of an EMR cluster with the cluster_id as the value: + - emr:elasticmapreduce:job-flow-id = j-xxxxxxx + + If set, this is a master node of the cluster: + - emr:elasticmapreduce:instance-group-role == MASTER + + :param dict tags: dict of tag + :return (bool,str): Tuple containing is_master (is an EMR node and is the master), and the cluster_id if it's a cluster + """ + + cluster_id = tags.get('aws:elasticmapreduce:job-flow-id', '') + is_master = tags.get('aws:elasticmapreduce:instance-group-role', '') == 'MASTER' + + return (is_master and cluster_id != '', cluster_id) + ## # aws: elasticmapreduce: job - flow - id        j - 8O514K6HPIYZ # A2      GenerateCertificate     FALSE @@ -3159,6 +3179,3 @@ def create_fqdn(host, zone): # A2      LightsOut       true # A2      POC     Ryan Kane # A2      aws: elasticmapreduce: instance - group - role        MASTER - -# aws: elasticmapreduce: job - flow - id        j - 8O514K6HPIYZ -# A2      aws: elasticmapreduce: instance - group - role        MASTER diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index 76c92c2..e9d4d11 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ