Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
aws s3api --endpoint-url http://mydomain.example.com:8090 create-bucket --bucket locker --object-lock-enabled-for-bucket 
aws s3api --endpoint-url http://mydomain.example.com:8090 put-bucket-versioning --bucket locker --versioning-configuration Status=Enabled
aws --debug s3api --endpoint-url http://mydomain.example.com:8090 put-object-lock-configuration --bucket locker --object-lock-configuration '{ "ObjectLockEnabled": "Enabled", "Rule": { "DefaultRetention": { "Mode": "GOVERNANCE", "Days": 1, "Years": 0 } } }'
aws s3api --endpoint-url http://mydomain.example.com:8090 put-object  --bucket locker --key incriminating.log
VERSION_ID=$(aws s3api --endpoint-url http://mydomain.example.com:8090 list-object-versions --bucket locker  | jq -r '.Versions|map(select(.Key=="incriminating.log"))[0].VersionId')
aws s3api --endpoint-url http://mydomain.example.com:8090 put-object-legal-hold --bucket locker --key incriminating.log --version-id ${VERSION_ID}  --legal-hold  Status=ON
aws s3api --endpoint-url http://mydomain.example.com:8090 delete-object --bucket locker --key incriminating.log --version-id ${VERSION_ID} || echo "Good, expected failure"
aws s3api --endpoint-url http://mydomain.example.com:8090 put-object-legal-hold --bucket locker --key incriminating.log --version-id ${VERSION_ID}  --legal-hold  Status=OFF
aws s3api --endpoint-url http://mydomain.example.com:8090 delete-object --bucket locker --key incriminating.log --version-id ${VERSION_ID}
test $(aws s3api --endpoint-url http://mydomain.example.com:8090 list-object-versions --bucket locker | jq -r '.Versions|map(select(.Key=="incriminating.log"))|length') -eq 0 || echo "Expected zero objects"