AWS client not reused in a Lambda function
Recreating AWS clients from scratch in each Lambda function invocation is expensive and can lead to availability risks. Clients should be cached across invocations.
def lambda_handler_noncompliant(event, context):
    import boto3
    # Noncompliant: recreates AWS clients in each lambda invocation.
    client = boto3.client('s3')
    response = client.list_buckets()
import boto3
client = boto3.client('s3')


def lambda_handler_compliant(event, context):
    # Compliant: uses the cached client.
    response = client.list_buckets()