Skip to content

Commit

Permalink
Return 204 when Global Accelerator not found in stonith Lambda (#884)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Emerson <[email protected]>
  • Loading branch information
ryanemerson committed Jul 3, 2024
1 parent 7643132 commit 18d84ab
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
def handle_site_offline(labels):
a_client = boto3.client('globalaccelerator', region_name='us-west-2')

accelerator = jmespath.search("Accelerators[?DnsName=='%s']" % labels['accelerator'], a_client.list_accelerators())
acceleratorDNS = labels['accelerator']
accelerator = jmespath.search(f"Accelerators[?DnsName=='{acceleratorDNS}']", a_client.list_accelerators())
if not accelerator:
raise Exception("Unable to find Global Accelerator with DNS '%s'" % labels['accelerator'])
print(f"Ignoring SiteOffline alert as accelerator with DnsName '{acceleratorDNS}' not found")
return

accelerator_arn = accelerator[0]['AcceleratorArn']
listener_arn = a_client.list_listeners(AcceleratorArn=accelerator_arn)['Listeners'][0]['ListenerArn']
Expand Down

0 comments on commit 18d84ab

Please sign in to comment.