Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 26, 2023
1 parent 48a6614 commit 027d3dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions code/ddns-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Binary file modified code/ddns-lambda.zip
Binary file not shown.

0 comments on commit 027d3dc

Please sign in to comment.