Skip to content

Commit

Permalink
Handle precreated ENIs in service discovery lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePletch committed Dec 24, 2023
1 parent a666908 commit e50eefc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions infrastructure/lambda/service-discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def get_eni_ip(event):
attachment
for attachment
in event['detail']['attachments']
if attachment['type'] == 'eni'
if attachment['type'] == 'eni' and attachment['status'] != 'PRECREATED'
)
except StopIteration:
print("No ENI attached to this task. Nothing to do.")
print("No non-precreated ENI attached to this task. Nothing to do.")
return False

try:
Expand All @@ -37,7 +37,7 @@ def get_eni_ip(event):
if detail['name'] == 'networkInterfaceId'
)['value']
except StopIteration:
print(eni_attachment['details'])
print(event)
raise RuntimeError("No network interface ID listed for this ENI somehow.")

enis = client_ec2.describe_network_interfaces(NetworkInterfaceIds=[eni_id])['NetworkInterfaces']
Expand Down

0 comments on commit e50eefc

Please sign in to comment.