winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.02k stars 197 forks source link

AWS bucket notification events don't differ create and update one. #2724

Open tsuf239 opened 1 year ago

tsuf239 commented 1 year ago

I tried this:

let b = new cloud.Bucket();

b.onCreate(inflight () => {
    log ("CREATED");
});

b.onUpdate(inflight () => {
    log ("UPDATED");
});

test "test" {
    b.put("a", "1");
    b.put("a", "2");
}

This happened:

"CREATED" is logged twice.

We are using the "putObjectCommand" both for uploading and updating a key. This will always result in a PUT event (https://stackoverflow.com/questions/53421520/objectcreatedpost-on-s3-console-upload). it seems like the only way to get a POST event is to do it via the browser, there is no equivalent command in @aws-sdk/client-s3, unfortunately.

I also looked at the notification payload, there is nothing that differentiates one from the other.

We may be able to conclude what kind of event is sent by looking at the object versioning.

On the other hand, if it's a necessary feature- we could find a workaround and gain a lot of users 😊

I expected this:

"CREATED" to be logged once, and "UPDATED" to be logged once.is

Is there a workaround?

No response

Component

SDK

Wing Version

0.17.43

Wing Console Version

No response

Node.js Version

No response

Platform(s)

MacOS

Anything else?

No response

Community Notes

github-actions[bot] commented 1 year ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 1 year ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

garysassano commented 12 months ago

Closing this since I've just tested the code and it works as expected now.

tsuf239 commented 12 months ago

It may work on sim, but still doesn't work in AWS:

image

(To test this issue properly, please remove the condition here and run the test on aws) Thank you once again @garysassano, for making us write our issues in a clearer way, keep up your great work! 💪 🚀 🦸

github-actions[bot] commented 6 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 3 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!