What the best way I can catch get and Put Operation in and Out S3 bucket, in such a way as to be able to introduce processing logic?

0

Hi, i'm searchin for a solution to execute custom code on S3 putting and getting event objects, like custom encrypt/decrypt data, interact with DB/services (...). At this moment the solution I'm considering is

PUT

  1. Client: Asset => presignedUrl => S3
  2. Trigger : . generate AssetEncrypted from Asset . execute other custom logic . delete Asset

GET

  1. Client: GetObject Request => S3 Object Lambda
  2. S3ObjectLambda execute some logic and Process and Decrypt Asset Encrypt
  3. Return Asset

For Put i'm also considering S3 Transfer Family, maybe for his capacity of manage pre-processing assets, but i guess this is not a good choice. Can You give me a suggest?

demandé il y a 7 mois271 vues
2 réponses
0

If i understood correctly, you want to execute code when a customer does put /get. Right? You can do this with an EventBridge rule that triggers a lambda and the lambda executes the logic, performs XYZ . Check Using Eventbridge for S3 .

So, you create a rule for PUT Object with target a lambda that does <generate AssetEncrypted from Asset . execute other custom logic . delete Asset>. The rule pattern can look like this for a bucket called 'test1':

{
  "source": ["aws.s3"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["s3.amazonaws.com"],
    "eventName": ["PutObject"],
    "requestParameters": {
      "bucketName": ["test1"]
    }
  }
}

Then you create a rule for GET object, that has another lambda as a target and performs as above, the logic you need. The rule pattern would be:

{
  "source": ["aws.s3"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["s3.amazonaws.com"],
    "eventName": ["GetObject"],
    "requestParameters": {
      "bucketName": ["test1"]
    }
  }
}
Natassa
répondu il y a 7 mois
0

Hi, The way you suggest to catch event on S3 is perfect for post processing, i think,

https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html

i'm searching a method for inserting custom code on asset before requests are processed. E. G. before putting the item in the store I would like to process file (encrypt, update DB from metadata parsed, validation, etc...). ; before i get Object from store (decrypt, etc...), etc... In any case, thank you, I will try to search better also among the possibilities of EventBridge, since you recommend it

répondu il y a 7 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions