-
Notifications
You must be signed in to change notification settings - Fork 102
/
app.py
34 lines (22 loc) · 863 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
import boto3
from aws_xray_sdk.core import patch_all
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
from aws_lambda_powertools.utilities.typing import LambdaContext
from aws_lambda_powertools.utilities.validation import validator
try:
from schemas import OUTPUT_SCHEMA
patch_all()
except:
from src.schemas import OUTPUT_SCHEMA
@validator(outbound_schema=OUTPUT_SCHEMA)
def lambda_handler(event: APIGatewayProxyEvent, context: LambdaContext) -> dict:
s3_client = boto3.client('s3')
s3_response = s3_client.list_buckets()
bucket_list = "|".join([x["Name"] for x in s3_response["Buckets"]])
print("Hello logfile!")
return {
"statusCode": 200,
"body": bucket_list
}