S3API Jmespath Query and Python Script

Viewed 15

I have a query like this so far:

aws s3api list-objects-v2 
--profile my_profile 
--bucket my_bucket 
--prefix my_prefix
--query 'sort_by(Contents, &Date)[*].ETag'
--output=text

Without the --query 'sort_by(Contents, &Date)[*].ETag' flag, it returns:

{
    "Contents": [
        {
            "Key": "my_key",
            "LastModified": "2022-09-20T21:08:06+00:00",
            "ETag": "\"myEtag-1\"",
            "Size": 885,
            "StorageClass": "STANDARD"
        }
    ]
}

I'm looking for a way to recursively list all ETags before an operation with the query, maybe in a table like this:

File_before ETag_before
First row
Second row

Then after the operation, I'd want use the query again and the CSV to look like:

File. ETag_before ETag_after
First row row
Second row row

as well as a Python function that will say "PASS" if every single one of the ETags in the CSV is the same as before. Would I need to use Pandas for this? Or something simpler?

0 Answers
Related