File size: 503 Bytes
e9d47d5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import requests
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext
ENDPOINT = "http://httpbin.org/status/500"
logger = Logger(log_uncaught_exceptions=True)
def lambda_handler(event: dict, context: LambdaContext) -> str:
ret = requests.get(ENDPOINT)
# HTTP 4xx/5xx status will lead to requests.HTTPError
# Logger will log this exception before this program exits non-successfully
ret.raise_for_status()
return "hello world"
|