Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tagging S3 bucket object Issue

I am trying to add tags to existing object in S3 bucket using Lambda. Lambda has IAM role permission to add tags to bucket object, however simple python code to get_object_tagging is working but put_object_tagging is not working.

client = boto3.client("s3")            
tagresponse = client.put_object_tagging(
    Bucket="mybucket,
    Key="folder1/Test.txt",
    Tagging={'TagSet':[{'key':':permission:allowdownload','Value':'no'},{'key':'service:feature','Value':'sftpfiletransfer'}]},
        )

API response is throwing this error:

Parameter validation failed:
Missing required parameter in Tagging.TagSet[0]: "Key"
Unknown parameter in Tagging.TagSet[0]: "key", must be one of: Key, Value
Missing required parameter in Tagging.TagSet[1]: "Key"
Unknown parameter in Tagging.TagSet[1]: "key", must be one of: Key, Value
END RequestId: a45456e8-05c1-4b64-XXXX-XXXXXXXXXX

Key and Value pairs are populated as documentation but still not working.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks in advance for your help.

>Solution :

You need the uppercase K when supplying the tag-key:

client = boto3.client("s3")            
tagresponse = client.put_object_tagging(
    Bucket="mybucket,
    Key="folder1/Test.txt",
    Tagging={'TagSet':[{'Key':':permission:allowdownload','Value':'no'},{'Key':'service:feature','Value':'sftpfiletransfer'}]},
)

See the documentation here: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Client.put_object_tagging

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading