Skip to main content

This package is designed to validate the operational status of Amazon S3 buckets within an AWS account. It provides comprehensive diagnostics on the accessibility and functionality of an S3 bucket by performing key operations, including Bucket Accessibility, Object Operations and Bucket Policy Validation.

Project description

fastapi_cloud_healthcheck_aws_s3bucket

A FastAPI-based health check module for monitoring the health of AWS S3 buckets using the fastapi_cloud_healthcheck package.

Features

  • Bucket Accessibility: Verifies if the S3 bucket exists and is accessible within the given AWS region.
  • Object Operations: Performs test operations such as uploading, reading, and deleting objects within the bucket to ensure correct permissions.
  • Bucket Policy Validation: Checks for the presence of an S3 bucket policy and its retrieval status.
  • Automated Account Detection: Automatically retrieves the AWS Account ID for the health check metadata.
  • Timezone Support: Logs the last checked timestamp in Indian Standard Time (IST).

Adding Health Checks

Here is a sample FastAPI application that integrates the S3 bucket health check:

from fastapi import FastAPI
from fastapi_cloud_healthcheck import HealthCheckFactory, healthCheckRoute
from fastapi_cloud_healthcheck_aws_s3bucket import HealthCheckS3Bucket

app = FastAPI()

# Create Health Check Factory
health_check_factory = HealthCheckFactory()

# Add the S3 Bucket Health Check
health_check_factory.add(
    HealthCheckS3Bucket(
        bucket_name="my-sample-bucket",
        region="us-west-1"
    )
)

# Add the health check route to FastAPI
app.add_api_route('/health', endpoint=healthCheckRoute(factory=health_check_factory))

# Start the FastAPI server using Uvicorn
if __name__ == "__main__":
    import uvicorn
    uvicorn.run("main:app", port=5000)

In the above example:

  • We create a health check for the S3 bucket named my-sample-bucket in the region us-west-1.
  • The health check endpoint /health will expose detailed health information about the S3 bucket.

Health Check Process

The S3 Bucket Health Check performs the following operations:

  1. Bucket Accessibility: Uses the head_bucket boto3 API to check if the bucket exists and is accessible.

  2. Test Object Operations:

    • Upload: Uploads a temporary object to the bucket.
    • Read: Retrieves and validates the content of the test object.
    • Cleanup: Deletes the test object after validation.
  3. Bucket Policy Check: Ensures the bucket policy is accessible by attempting to retrieve it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file fastapi_cloud_healthcheck_aws_s3bucket-0.1.0.tar.gz.

File metadata

File hashes

Hashes for fastapi_cloud_healthcheck_aws_s3bucket-0.1.0.tar.gz
Algorithm Hash digest
SHA256 36071c259bb42ca30ff35ca99e0b59d078e790a95b973bcd3ea026f02c734ae3
MD5 9c3d5dbb56422e5a99616db2845c2d55
BLAKE2b-256 a8925605a6e5e866c3e51106a36246156524e312334c50727b0a6613850ac60f

See more details on using hashes here.

File details

Details for the file fastapi_cloud_healthcheck_aws_s3bucket-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_cloud_healthcheck_aws_s3bucket-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15ab6d5f67e4a53ec6558c366adbe9c6ede6c0b87e13027b6b3c6e4f8e39111e
MD5 2686f2244e9919ec7ba96534d6ebc895
BLAKE2b-256 8c56ac13c89653f642463edad32bec33c22534490049582545e8219b1b833381

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page