This section covers enabling versioning on an S3 bucket using AWS CLI
Step 1: Login to AWS through CLI
After installing AWS in our Command line interface, type the command
aws configure
This command will request you for your AWS login information as well as the default output format and region name.
In the management console, we will find our credentials info.
• If you already have an access key, grab the access key ID and secret access key by going to your account details in the top-right corner of the console and clicking on your account name under Security Credentials > Access keys. If not, make a new key and securely save those details.
• Later, we logon to the AWS account by entering the credentials, region name, and output format.
Step 2: Selecting the bucket
you can type below command to see your list of buckets.
aws s3 ls
Now we can select on which bucket we want to perform versioning.
Step 3: Enable Versioning
Use this command to see if it’s already enabled or not.
aws s3api get-bucket-versioning --bucket bucket_name
Here it is not enabled we have to enable it by using the command
aws s3api put-bucket-versioning --bucket bucket_name --versioning-configuration Status=Enabled
When we check again after enabling, we will see Status=Enabled as shown below.