Created
July 1, 2019 13:23
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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