Search code examples
amazon-s3windows-7aws-clitagging

AWS S3api - put-bucket-tagging not placing tags on documents


I have an s3 bucket with about 30 documents. I am trying to write awscli to tag each document in the bucket.

I ran the following lines in cmd and both ran without error (and without response, but I think that's normal), however none of my documents have tags associated with them.

aws s3api put-bucket-tagging --bucket xxx.yyyy.staticforms --tagging file://tags.json
aws s3api put-bucket-tagging --bucket xxx.yyyy.staticforms --tagging TagSet=[{Key=riskType,Value=myValue}]

my json file looks like this:

{
  "TagSet": [
    {
      "Key": "riskType",
      "Value": "myValue"
    }
  ]
}

I have full admin rights on the account. Anyone know why the tags are not being placed on the documents?


Solution

  • You should use put-object-tagging to tag each individual object:

    aws s3api put-object-tagging --bucket xxx.yyyy.staticforms --key path/to/object --tagging TagSet=[{Key=riskType,Value=myValue}]
    

    See: https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object-tagging.html