That’s the moment you understand the real value of immutability. With the AWS CLI, immutability isn’t a theory. It’s a command you run, a property you lock, and a safeguard you don’t bypass. When configured right, even the root account can’t rewrite history.
Why AWS CLI Immutability Matters
Data lives on servers you don’t see. Threats come from accidents, bad scripts, rogue access, and malicious actors. The AWS CLI lets you enforce object lock configurations and retention policies directly from your terminal. You get speed, automation, and precision. Immutability ensures no one can delete or alter critical objects before their retention date expires.
Core AWS CLI Commands for Immutability
Start with Object Lock. You can enable it when creating a new S3 bucket:
aws s3api create-bucket \
--bucket my-immutable-bucket \
--object-lock-enabled-for-bucket
Set retention on an object so it can’t be changed:
aws s3api put-object-retention \
--bucket my-immutable-bucket \
--key data.json \
--retention "Mode=GOVERNANCE,RetainUntilDate=2025-01-01T00:00:00Z"
Use governance mode for controlled overrides with special permissions. Use compliance mode when nothing should override it, ever.