← Playbooks

S3 - Enable Server Versioning

Learn how to enable S3 bucket versioning on Amazon S3 buckets to protect against accidental overwrites and deletions.

May 21, 2025
S3 - Enable Server Versioning

Description

This playbook provides a comprehensive guide on how to enable bucket versioning in Amazon S3 using Tamnoon’s S3 soft configuration automation. Versioning is a critical aspect of data protection in S3, allowing you to preserve, retrieve, and restore every version of every object stored in your bucket. This is crucial for accidental deletion recovery, data retention compliance, and maintaining historical versions of your files.

The automation leverages AWS credentials for authentication and execution. The playbook outlines a fallback mechanism to fetch these credentials:

  1. If AWS profile or aws access key and secret were given, use it as an AWS credentials source.
  2. If no profile, use as environment variable credentials for aws.
  3. If not environmental variables provided, use the current./~aws configuration

After authentication via AWS API, the script execution will run on the same AWS account of those credentials defined in fallbacks 1-3 (see above).

Severity Level

Medium: Recommended for data protection and compliance but not immediately critical unless handling sensitive or regulated data.

When to use?

Use this playbook when you want to enable versioning on critical S3 buckets to protect against accidental deletions or overwrites, enhance data recovery, and support audit-readiness. It’s especially useful for production environments and compliance-sensitive workloads.

Playbook steps:

1. Clone the folder AWS/Automation/S3SoftConfiguration

2. Execute the automation from the /AWS directory python3 -m Automations.EC2Actions.S3Helper --profile <aws_profile> --action versioning --bucketNames --revert <true/false if to revert this action> python3 -m Automations.EC2Actions.S3Helper --awsAccessKey <aws_access_key> --awsSecret <aws_secret> --action versioning --bucketNames --revert <true/false if to revert this action>

Prerequisites

1. AWS cretentials defined on the execution machine with permission to change SecurityGroups

2. Python v3.6 and above + boto3 package installed ( pip install boto3)

Key Points

Frequently Asked Questions

Why should I enable versioning on my S3 buckets?

Versioning is essential for protecting data against unintended overwrites or deletions. It allows every version of an object to be preserved, making recovery straightforward. When you enable S3 versioning, you add a layer of resilience and compliance to your storage practices.

What changes when S3 versioning is enabled?

Enabling versioning assigns a unique version ID to every object update. Deletions don’t remove data but add a delete marker, allowing you to retrieve older versions when needed.

How do I run this playbook with AWS credentials?

The playbook supports AWS profiles, access key pairs, and environment variables. If no credentials are supplied explicitly, the script defaults to the configuration found in your ~/.aws directory.

What kind of rollback capabilities does versioning provide?

It gives you the power to restore any previous object version in case of an error, making it valuable for both manual and automated rollback workflows across your organization.

Does enabling versioning increase my S3 storage costs?

Yes. Each new version of an object consumes additional storage. Over time, this can significantly increase costs if unmanaged. Implementing lifecycle policies can help minimize long-term storage expenses.

Can I automate access logging along with versioning?

This playbook is focused on versioning alone, but it’s a best practice to enable S3 server access logging as well. Logging complements versioning by providing visibility into who accessed which object and when, useful for audits and compliance.

Read the playbook. Then watch Tamnoon run it on your own findings.

Every repair Tamnoon executes is a named procedure you can read, clone and audit before anything touches your plane.