Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Created September 7, 2023 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuvalif/9bf24a6c2ccba7db62f8353156ab6a21 to your computer and use it in GitHub Desktop.
Save yuvalif/9bf24a6c2ccba7db62f8353156ab6a21 to your computer and use it in GitHub Desktop.

Setup

  • start the cluster
MON=1 OSD=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh -n -d
  • create an http topic:
aws --endpoint-url http://localhost:8000 sns create-topic --name=fishtopic \
  --attributes='{"push-endpoint": "http://localhost:10900"}'
  • creaet a versioned bucket:
aws --endpoint-url http://localhost:8000 s3 mb s3://fish
aws --endpoint-url http://localhost:8000 s3api put-bucket-versioning --bucket fish --versioning-configuration Status=Enabled
  • create a notification:
aws --endpoint-url http://localhost:8000 s3api put-bucket-notification-configuration --bucket fish \
  --notification-configuration='{"TopicConfigurations": [{"Id": "notif1", "TopicArn": "arn:aws:sns:default::fishtopic", "Events": []}]}'
  • download a python HTTP POST server:
wget https://gist.githubusercontent.com/yuvalif/a5d08a1eca0f3a24eefd6f647a5d9e69/raw/7bc50f8a9a8bc4fbb7762ad4629b89d585474a39/server.py
  • in a separate terminal run the above server:
python server.py 10900
  • upload an object to the bucket:
head -c 50M </dev/urandom > myfile
aws --endpoint-url http://localhost:8000 s3 cp myfile s3://fish
  • delete the object:
aws --endpoint-url http://localhost:8000 s3 rm s3://fish/myfile
  • make sure that the notification has a valid eventTime and the eventName is: ObjectRemoved:DeleteMarkerCreated
  • take the versionId field from the notification above and use it to delete the delete marker:
aws --endpoint-url http://localhost:8000 s3api delete-object --bucket fish --key myfile --version-id "<version-id>"
  • make sure that the new notification has valid eventTime and the eventName is: ObjectRemoved:Delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment