Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (18 sloc) 690 Bytes
from botocore.vendored import requests
import boto3
This function checks is a given website is alive. If not it triggers a SNS notification. You need to have created your SNS topic first.
websiteURL = ''
topicArnCode = 'arn:aws:sns:eu-central-1:212124416081:website-offline'
def lambda_handler(event, context):
r = requests.head(websiteURL)
if r.status_code == 200:
print "Website Is Alive!"
sns = boto3.client('sns')
TopicArn = topicArnCode,
Subject = 'Website Offline' ,
Message = 'Status code 200 was expected but returned was '+ str(r.status_code)