1515log_level = logging .INFO if not env_level else env_level
1616logger .setLevel (log_level )
1717
18- version = "2022040303 "
18+ version = "2024112205 "
1919
2020# dont set this too low or the entry could be invalid before being used at all ...
2121ttl = 300
@@ -121,7 +121,8 @@ def get_asg_private_ips(asg_client,ec2_client,asg_name):
121121 for reservation in ec2_client .describe_instances (InstanceIds = instance_ids )['Reservations' ]:
122122 for instance in reservation ['Instances' ]:
123123 if instance ['State' ]['Name' ] == 'running' :
124- servers .append ({'Value' : instance ['PrivateIpAddress' ]})
124+ if 'PrivateIpAddress' in instance :
125+ servers .append ({'Value' : instance ['PrivateIpAddress' ]})
125126 return servers
126127
127128def get_asg_public_ips (asg_client ,ec2_client ,asg_name ):
@@ -135,14 +136,17 @@ def get_asg_public_ips(asg_client,ec2_client,asg_name):
135136 for reservation in ec2_client .describe_instances (InstanceIds = instance_ids )['Reservations' ]:
136137 for instance in reservation ['Instances' ]:
137138 if instance ['State' ]['Name' ] == 'running' :
138- servers .append ({'Value' : instance ['PublicIpAddress' ]})
139+ if 'PublicIpAddress' in instance :
140+ servers .append ({'Value' : instance ['PublicIpAddress' ]})
139141 return servers
140142
141143def get_asg_dns_tags (asg_client ,asg_name ,region ):
142144 r = asg_client .describe_tags (Filters = [{'Name' :'auto-scaling-group' ,'Values' :[asg_name ]},{'Name' :'key' ,'Values' :['splunkdnszone' ,'splunkdnsnames' ,'splunkdnsprefix' ]}])
143145 for tag in r ['Tags' ]:
144146 k = tag ['Key' ]
145147 v = tag ['Value' ]
148+ # strip to remove extra spaces around values
149+ v = v .strip ()
146150 print (f"key={ k } ,Value={ v } " )
147151 if k == 'splunkdnszone' :
148152 zone = v
0 commit comments