Skip to content

Instantly share code, notes, and snippets.

@pwilken
Created July 1, 2019 13:23
Show Gist options
  • Save pwilken/97a7432c4ac4e1d9bc368f1c985b2fda to your computer and use it in GitHub Desktop.
Save pwilken/97a7432c4ac4e1d9bc368f1c985b2fda to your computer and use it in GitHub Desktop.
AWS Lambda function, checks if service is reachable and if not calls an other Lambda function. Don`t forget to give your function the rights to call other lambda functions.
import subprocess
import boto3
import json
lambda_client = boto3.client('lambda')
def lambda_handler(event, context):
result = subprocess.call("curl -I YOUR_URL", shell=True)
if result > 0:
invoke_response = lambda_client.invoke(FunctionName="LAMBDA_FUNCTION_NAME",
InvocationType='Event')
print (invoke_response)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment