find all S3 objects without tags

0

Hello,

Considering the following Windows 10 bash command from a .bat file (using AWS CLI), that finds all the S3 keys for specified (tagKey,tagValue), could you please specify the command to get all the S3 keys without any tag ?

for /f "tokens=*" %%a in ('aws s3api list-objects-v2 --bucket <bucket> --prefix <prefix> --no-cli-auto-prompt --query Contents[*].[Key] --output text') do (
	for /f "tokens=*" %%b in ('aws s3api get-object-tagging --bucket <bucket> --key %%a --no-cli-auto-prompt --query TagSet[?"Key=='<tagKey>'&&Value=='<tagValue>'"].Key --output text') do (
		@echo %%a >> <file>
	)
)

Thank you,
Mihai ADAM

2 Answers
0

Please see the more clear syntax

for /f "tokens=*" %%a in ('aws s3api list-objects-v2 --bucket <bucket> --prefix <prefix> --no-cli-auto-prompt --query Contents[*].[Key] --output text') do (
	for /f "tokens=*" %%b in ('aws s3api get-object-tagging --bucket <bucket> --key %%a --no-cli-auto-prompt --query "TagSet[0]==null" --output text') do (
		if %%b==True @echo %%a >> <file>
	)
)
answered 2 years ago
0

Hello,

At this moment AWS released a new feature to query tags. It is called Amazon S3 Metadata, and it works as described here

Have a good day,

answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions