siva
siva

Reputation: 629

AWS S3 get object tag for a specific key

Basically i used this AWS_CLI command to set the S3 object key

aws s3api  put-object-tagging --bucket <bucket-name> --key <file-name> --tagging '{"TagSet":[{"Key" : "full_name","Value" : "SIVA"}]}'

Question

How can i get the value of the tag key ?

If i Provide key_name as full_name ==> i want output to be SIVA

I know, we need to do something with get-object-tagging

Can anyone tell me how?

Upvotes: 1

Views: 1641

Answers (1)

Marcin
Marcin

Reputation: 238209

As you've noticed you can use get-object-tagging. Also can use --query and --output:

aws s3api  get-object-tagging --bucket <bucket-name> --key <file-name> --query "TagSet[?Key=='full_name'].Value" --output text

The above will first find tag with Key == full_name in an object, and then it takes its Value.

Upvotes: 3

Related Questions