Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding s3 object tags using a lambda function?

The documentation describes how to tag an s3 object via the console. How do we do it programmatically with a lambda function?

like image 955
Ole Avatar asked Nov 14 '25 20:11

Ole


1 Answers

If you are using JavaScript in your Lambda you are good to use: s3.putObjectTagging

Documentation Snippet

/* The following example adds tags to an existing object. */

 var params = {
  Bucket: "examplebucket", 
  Key: "HappyFace.jpg", 
  Tagging: {
   TagSet: [
      {
     Key: "Key3", 
     Value: "Value3"
    }, 
      {
     Key: "Key4", 
     Value: "Value4"
    }
   ]
  }
 };
 s3.putObjectTagging(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log(data);           // successful response
   /*
   data = {
    VersionId: "null"
   }
   */
 });
like image 94
MaiKaY Avatar answered Nov 17 '25 11:11

MaiKaY



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!