Enable S3 versioning, upload multiple object versions, restore a previous version by ID, and configure a lifecycle rule to expire non-current versions ā all from the CLI.
Create a new S3 bucket for this lesson. The name uses your Account ID to guarantee global uniqueness.
BUCKET="devopspath-$(aws sts get-caller-identity \
--query Account \
--output text)-versioning-lab"echo "Bucket name: $BUCKET"aws s3 mb s3://$BUCKET --region us-east-1The BUCKET shell variable stores the unique bucket name for the rest of this lesson.
Using your 12-digit Account ID in the name guarantees global uniqueness without a random suffix.
The variable lives in your current shell session ā if you open a new terminal window you will need to re-run the first command to restore it.
The echo command prints a name like: devopspath-123456789012-versioning-lab
The mb command outputs: make_bucket: devopspath-123456789012-versioning-lab