-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPutObjectTagging.py
More file actions
37 lines (32 loc) · 977 Bytes
/
PutObjectTagging.py
File metadata and controls
37 lines (32 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import boto3
import urllib
from pprint import pprint
import logging
logging.basicConfig(filename="mylog.log", level=logging.DEBUG)
print('Loading function')
client = boto3.client('s3')
def lambda_handler(event, context):
print("Received event: " + json.dumps(event))
bucket = event['Records'][0]['s3']['bucket']['name']
objectname = event['Records'][0]['s3']['object']['key']
version = event['Records'][0]['s3']['object']['versionId']
listofresources = []
listofresources.append(bucket)
listofresources.append(objectname)
listofresources.append(version)
print (listofresources)
#print (version)
client.put_object_tagging(
Bucket=listofresources[0],
Key=listofresources[1],
VersionId=listofresources[2],
Tagging={
'TagSet': [
{
'Key': 'hell',
'Value': 'yeah'
},
]
}
)