Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3: Sending notification to EventBridge LIFECYCLE_TRANSITION_EVENT #7448

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tsugumi-sys
Copy link
Contributor

@tsugumi-sys tsugumi-sys commented Mar 9, 2024

  • Sending an event to EventBridge when the object storage class is changed.
  • (Object storage class is also changed by bucket lifecycle, but I think we cannot detect it in the current moto implementation.)

from docs;

You can also change the storage class of an object that is already stored in Amazon S3 to any other storage class by making a copy of the object by using the PUT Object - Copy API operation.

(I thought we can change object's storage class with restore_object request, but we can't based on the document.)

Copy link

codecov bot commented Mar 9, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 95.80%. Comparing base (9aef694) to head (892ff9c).
Report is 98 commits behind head on master.

Files Patch % Lines
moto/s3/models.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7448      +/-   ##
==========================================
- Coverage   95.88%   95.80%   -0.08%     
==========================================
  Files         843      854      +11     
  Lines       82578    83957    +1379     
==========================================
+ Hits        79178    80437    +1259     
- Misses       3400     3520     +120     
Flag Coverage Δ
servertests 32.22% <40.00%> (-0.30%) ⬇️
unittests 95.77% <40.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like a good usecase to introduce a getter/setter method for the storage_class attribute.

If we send the event inside the setter method, we can be sure that this always happens - regardless of who/where/why the storage class was changed.
We'll just have to be careful to only send an event when there is a change, and not on initialization.

What do you think?

@tsugumi-sys
Copy link
Contributor Author

This sounds like a good usecase to introduce a getter/setter method for the storage_class attribute.

I totally agree with this :)
Thanks @bblommers ! I'll implement a setter and getter for storage class attribute in this PR.

@tsugumi-sys
Copy link
Contributor Author

tsugumi-sys commented Mar 10, 2024

we need the FakeKey.status property implementation in this PR #7455

@bblommers
Copy link
Collaborator

The status-attribute should already be there @tsugumi-sys - it's defined in the parent class.
My PR just overrides it and adds additional functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants