AWS : S3 (Simple Storage Service) III - Bucket Versioning
Versioning allows us to preserve, retrieve, and restore every version of every file in an Amazon S3 bucket. Once we enable Versioning for a bucket, Amazon S3 preserves existing files anytime we overwrite or delete them.
This provides an additional level of protection by providing a means of recovery for accidental overwrites or expirations. Versioning-enabled buckets store all versions of our objects by default.
Versioning is a means of keeping multiple variants of an object in the same bucket. We can use Lifecycle rules to manage all versions of our objects as well as their associated costs. Lifecycle rules enable us to automatically archive our objects to the Glacier Storage Class and/or remove them after a specified time period.
Once enabled, Versioning cannot be disabled, only suspended.
Image source : Amazon Simple Storage Service
In one bucket, for example, we can have two objects with the same key, but different version IDs, such as photo.gif (version 111111) and photo.gif (version 121212).
Versioning-enabled buckets enable us to recover objects from accidental deletion or overwrite. For example:
- If we delete an object, instead of removing it permanently, Amazon S3 inserts a delete marker, which becomes the current object version. We can always restore the previous version.
- If we overwrite an object, it results in a new object version in the bucket. We can always restore the previous version.
Buckets can be in one of three states:
- unversioned (the default)
- versioning-enabled
- versioning-suspended
The versioning state applies to all of the objects in that bucket. The first time we enable a bucket for versioning, objects in it are thereafter always versioned and given a unique version ID:
- Objects stored in our bucket before we set the versioning state have a version ID of null. When we enable versioning, existing objects in our bucket do not change. What changes is how Amazon S3 handles the objects in future requests.
- The bucket owner (or any user with appropriate permissions) can suspend versioning to stop accruing object versions. When we suspend versioning, existing objects in our bucket do not change. What changes is how Amazon S3 handles objects in future requests.
We can configure bucket versioning using any of the following methods:
- Configure versioning using the Amazon S3 console
- Configure versioning programmatically using the AWS SDKs
Each bucket we create has a versioning subresource (see Bucket Configuration Options) associated with it. By default, our bucket is unversioned, and accordingly the versioning subresource stores empty versioning configuration.
<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2015-03-01/"> </VersioningConfiguration>To enable versioning, we send a request to Amazon S3 with a versioning configuration that includes a status.
<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2015-03-01/"> <Status>Enabled</Status> </VersioningConfiguration>To suspend versioning, we set the status value to Suspended.
To enable versioning on a bucket:
- Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
- In the Buckets list, click the details icon on the left of the bucket name and then click Properties to display bucket properties.
- In the Properties pane, click Versioning and then click Enable Versioning.
After we enable versioning on a bucket, it can be in only the enabled or suspended state; we cannot disable versioning on a bucket. If we suspend versioning, Amazon S3 suspends the creation of object versions for all operations, but preserves any existing object versions.
A versioning-enabled bucket can have multiple versions of objects in the bucket. Amazon S3 assigns each object a unique version ID.
When a bucket is versioning-enabled, we can show or hide all the object versions. The following example shows the list of objects in the bogotobogo-bucket bucket. Version information is hidden, so these objects represent the latest version.
If we click Show, the console lists all the versions, as shown in the following example.
For each object version, the console shows a unique version ID, the date and time the object version was created, and other properties. Note that the files have already been put into the bucket before we enabled versioning. That's why we have nulls in Version ID column.
If we add a new file, we can see the newly added file has Version ID unlike the files before we Enabled Versioning.
If we upload an object with a key name that already exists in the bucket, Amazon S3 creates another version of the object instead of replacing the existing object. bogo1.txt:
If we update any object properties after the initial object upload, such as changing the storage details or any other metadata changes, then Amazon S3 creates a new object version in the bucket. If we rename the object, Amazon S3 creates a new object version.
For example, if we update an object's storage class or change how the object is stored at rest by updating its server-side encryption property, Amazon S3 creates an object version for each property update we save.
When versions are hidden, we can update all the object properties; when versions are shown, we can update only the permissions for the specific object version.
In a versioning-enabled bucket, we can either delete an object from the object list (version information hidden).
With version information hidden, the console shows the object list as shown in the following example:
or delete a specific version of the object.
If we select and delete the bogo4.txt object, Amazon S3 adds a delete marker for the object and the object no longer appears in the object list:
To delete an object permanently, we must delete all the versions of the object, including the delete marker (if present). If we delete only a specific object version, Amazon S3 permanently deletes only that specific version. If we delete the delete marker, the object reappears in the object list.
- AWS S3 versioning operations are based on stack data structure.
- We can enable versioning by clicking 'Enable Version' button under 'Properties'.
- There are two ways of restoring previous versions: Restoring Previous Versions
- Deleting the more recent versions.
- Put the previous version on top (re-uploading after copy(download))
- Deleting the more recent versions.
- Testing Results - Restoring previous version works as expected.
- Performed in console mode.
- We can test the versioning using multiple text files with the same name but with different content, for example, version 1, version2, etc.
- We can simulate GET method by downloading the 'test1' with 'Hide' on.
- Method 1 (Deletion) Delete the top (v.4) => We get previous version (v.3)
- Method 2 (Copying) Copying the previous version (v.3) , and put it on top of v4 by uploading it. => We get v.3
AWS (Amazon Web Services)
- AWS : EKS (Elastic Container Service for Kubernetes)
- AWS : Creating a snapshot (cloning an image)
- AWS : Attaching Amazon EBS volume to an instance
- AWS : Adding swap space to an attached volume via mkswap and swapon
- AWS : Creating an EC2 instance and attaching Amazon EBS volume to the instance using Python boto module with User data
- AWS : Creating an instance to a new region by copying an AMI
- AWS : S3 (Simple Storage Service) 1
- AWS : S3 (Simple Storage Service) 2 - Creating and Deleting a Bucket
- AWS : S3 (Simple Storage Service) 3 - Bucket Versioning
- AWS : S3 (Simple Storage Service) 4 - Uploading a large file
- AWS : S3 (Simple Storage Service) 5 - Uploading folders/files recursively
- AWS : S3 (Simple Storage Service) 6 - Bucket Policy for File/Folder View/Download
- AWS : S3 (Simple Storage Service) 7 - How to Copy or Move Objects from one region to another
- AWS : S3 (Simple Storage Service) 8 - Archiving S3 Data to Glacier
- AWS : Creating a CloudFront distribution with an Amazon S3 origin
- AWS : Creating VPC with CloudFormation
- AWS : WAF (Web Application Firewall) with preconfigured CloudFormation template and Web ACL for CloudFront distribution
- AWS : CloudWatch & Logs with Lambda Function / S3
- AWS : Lambda Serverless Computing with EC2, CloudWatch Alarm, SNS
- AWS : Lambda and SNS - cross account
- AWS : CLI (Command Line Interface)
- AWS : CLI (ECS with ALB & autoscaling)
- AWS : ECS with cloudformation and json task definition
- AWS Application Load Balancer (ALB) and ECS with Flask app
- AWS : Load Balancing with HAProxy (High Availability Proxy)
- AWS : VirtualBox on EC2
- AWS : NTP setup on EC2
- AWS: jq with AWS
- AWS & OpenSSL : Creating / Installing a Server SSL Certificate
- AWS : OpenVPN Access Server 2 Install
- AWS : VPC (Virtual Private Cloud) 1 - netmask, subnets, default gateway, and CIDR
- AWS : VPC (Virtual Private Cloud) 2 - VPC Wizard
- AWS : VPC (Virtual Private Cloud) 3 - VPC Wizard with NAT
- DevOps / Sys Admin Q & A (VI) - AWS VPC setup (public/private subnets with NAT)
- AWS - OpenVPN Protocols : PPTP, L2TP/IPsec, and OpenVPN
- AWS : Autoscaling group (ASG)
- AWS : Setting up Autoscaling Alarms and Notifications via CLI and Cloudformation
- AWS : Adding a SSH User Account on Linux Instance
- AWS : Windows Servers - Remote Desktop Connections using RDP
- AWS : Scheduled stopping and starting an instance - python & cron
- AWS : Detecting stopped instance and sending an alert email using Mandrill smtp
- AWS : Elastic Beanstalk with NodeJS
- AWS : Elastic Beanstalk Inplace/Rolling Blue/Green Deploy
- AWS : Identity and Access Management (IAM) Roles for Amazon EC2
- AWS : Identity and Access Management (IAM) Policies, sts AssumeRole, and delegate access across AWS accounts
- AWS : Identity and Access Management (IAM) sts assume role via aws cli2
- AWS : Creating IAM Roles and associating them with EC2 Instances in CloudFormation
- AWS Identity and Access Management (IAM) Roles, SSO(Single Sign On), SAML(Security Assertion Markup Language), IdP(identity provider), STS(Security Token Service), and ADFS(Active Directory Federation Services)
- AWS : Amazon Route 53
- AWS : Amazon Route 53 - DNS (Domain Name Server) setup
- AWS : Amazon Route 53 - subdomain setup and virtual host on Nginx
- AWS Amazon Route 53 : Private Hosted Zone
- AWS : SNS (Simple Notification Service) example with ELB and CloudWatch
- AWS : Lambda with AWS CloudTrail
- AWS : SQS (Simple Queue Service) with NodeJS and AWS SDK
- AWS : Redshift data warehouse
- AWS : CloudFormation
- AWS : CloudFormation Bootstrap UserData/Metadata
- AWS : CloudFormation - Creating an ASG with rolling update
- AWS : Cloudformation Cross-stack reference
- AWS : OpsWorks
- AWS : Network Load Balancer (NLB) with Autoscaling group (ASG)
- AWS CodeDeploy : Deploy an Application from GitHub
- AWS EC2 Container Service (ECS)
- AWS EC2 Container Service (ECS) II
- AWS Hello World Lambda Function
- AWS Lambda Function Q & A
- AWS Node.js Lambda Function & API Gateway
- AWS API Gateway endpoint invoking Lambda function
- AWS API Gateway invoking Lambda function with Terraform
- AWS API Gateway invoking Lambda function with Terraform - Lambda Container
- Amazon Kinesis Streams
- AWS: Kinesis Data Firehose with Lambda and ElasticSearch
- Amazon DynamoDB
- Amazon DynamoDB with Lambda and CloudWatch
- Loading DynamoDB stream to AWS Elasticsearch service with Lambda
- Amazon ML (Machine Learning)
- Simple Systems Manager (SSM)
- AWS : RDS Connecting to a DB Instance Running the SQL Server Database Engine
- AWS : RDS Importing and Exporting SQL Server Data
- AWS : RDS PostgreSQL & pgAdmin III
- AWS : RDS PostgreSQL 2 - Creating/Deleting a Table
- AWS : MySQL Replication : Master-slave
- AWS : MySQL backup & restore
- AWS RDS : Cross-Region Read Replicas for MySQL and Snapshots for PostgreSQL
- AWS : Restoring Postgres on EC2 instance from S3 backup
- AWS : Q & A
- AWS : Security
- AWS : Security groups vs. network ACLs
- AWS : Scaling-Up
- AWS : Networking
- AWS : Single Sign-on (SSO) with Okta
- AWS : JIT (Just-in-Time) with Okta
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization