Bruno
Bruno

Reputation: 695

is this How to tag two object in s3 using boto3 python

This is my code to add tags to object during object creation.

s3 = boto3.resource(
    's3',
    aws_access_key_id=ACCESS_KEY_ID,
    aws_secret_access_key=ACCESS_SECRET_KEY,
    config=Config(signature_version='s3v4')
)

s3.Bucket(pco_BUCKET_NAME).put_object(Key=f'{unique_id}/{username}.png', Body=pco_cropped_image, Tagging=f'unique_id={unique_id}')
s3.Bucket(pco_BUCKET_NAME).put_object(Key=f'{unique_id}/{username}.json', Body=pco_details, Tagging=f'unique_id={unique_id}')

This code gives me access denied error, but when I remove the tagging parameter it works fine.

Upvotes: 1

Views: 128

Answers (1)

Marcin
Marcin

Reputation: 238051

This happens probably because you have no s3:PutObjectTagging permissions. So you either have to add it to your bucket policy or to your IAM user/role.

Upvotes: 1

Related Questions