• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy
Effortless S3 Bucket Access Log Activation Across Your AWS Account with Python Automation

Effortless S3 Bucket Access Log Activation Across Your AWS Account with Python Automation

Admin

  • 3 min read
Effortless S3 Bucket Access Log Activation Across Your AWS Account with Python Automation

Generating audio, please wait...

S3 server access logging is a feature AWS introduced for providing detailed records on what requests are made to an Amazon S3 bucket. This will be really helpful in many scenarios for all of us including security monitoring, troubleshooting, etc.

Recently to meet regulatory compliance standards for one of our clients, we came to a point where we need to enable S3 server access logging for all the accounts that are not enabled currently.

Upon checking the AWS account almost 100 S3 buckets where found and we don’t know which one has S3 server access logging enabled or which one doesn’t have this.

Checking this manually and enabling them one by one is a time-consuming and very boring process. So we came up with a Python script to check if the bucket has this enabled or not and if it is not enabled the script will automatically enable this for us.

Key points of the script

  1. The script will list the S3 Buckets in the AWS account.
  2. The script will check for S3 server access logging status.
  3. If this is not enabled the script will enable this for us.
  4. The script will print a message like Enabled for the newly enabled ones and Already Enabled for the already enabled buckets along with its name.

The script is attached below.

import boto3

client = boto3.client('s3')

list = client.list_buckets()

for buckets in list['Buckets']:
bucket_name = buckets['Name']

try:
log = client.get_bucket_logging(
Bucket = bucket_name
)
if 'LoggingEnabled' not in log:
client.put_bucket_logging(
Bucket=bucket_name,
BucketLoggingStatus={
'LoggingEnabled': {
'TargetBucket': '<Name of the bucket where you need to store this logs>',
'TargetPrefix': f'access-logs/{bucket_name}/'
}
}
)
logging_status = "Enabled"
else:
logging_status = "Already enabled"
except Exception as e:
logging_status = "Error"
print(f"Bucket Name: {bucket_name}, Access Logging: {logging_status}")

Testing the script

Now we are going to test this script.

1_ZkZvJZw4WyEQL-1-vv3hPg.webp

Here I have 3 S3 buckets accesslog-test-1, accesslog-test-2, and accesslog-test-log. First bucket accesslog-test-1 has server access logging enabled and the bucket accesslogs-test-logs is used to store these access logs for the bucket.

Lets run the script. I have configured an AWS profile named accesslog-test.

Let's export the profile first and then run our script.

1_ADiwOKD24Rykki1YmSUwiA.webp

Now the script has updated the server access logging for the rest of the buckets and one which already had is shown as Already enabled.

You can either check them via console or you can run the script again to check if it is enabled or not.

1_gxMd0wP5YNKVsPGKk5nLMg.webp

That’s all thank you ❤

Effortlessly manage S3 bucket logging! Use our Python script to check and enable S3 server access logging across multiple AWS accounts. Simplify compliance and security monitoring. Learn more at SupportSages

  • AWS
  • DevOps

Continue Your Journey With…

DevOps as a Service

DevOps as a Service

Let us do the heavy lifting for you

Promotional banner
Promotional banner

5 Things You Should Know About AWS Well-Architected Framework Review

5 Things You Should Know About AWS Well-Architected Framework Review
  • AWS
logo

Automating IAM user Audit Using Python.

Automating IAM user Audit Using Python.
  • AWS
  • DevOps
logo

Automating SSM Parameter store backup using Python.

Automating SSM Parameter store backup using Python.
  • AWS
  • DevOps
logo

Create new user account in Argo CD with Read Only Access

Create new user account in Argo CD with Read Only Access
  • AWS
  • DevOps
logo

Posts by Admin