Home > database >  How To Query S3 Objects with CLI instead of S3 Select?
How To Query S3 Objects with CLI instead of S3 Select?

Time:03-24

I need a CLI alternative similar to the example here in enter image description here

CodePudding user response:

Use single quotes ' to enclose the entire JSON string, if you are using linux/macOS terminal. In powershell, use \ to escape the double quotes.

like this -

aws s3api select-object-content --bucket "my-bucket" --key jobs/test.json --expression "SELECT * FROM s3object s LIMIT 5" --expression-type 'SQL' --input-serialization '"{"JSON":{"Type": "DOCUMENT"},"CompressionType": "None"}"' --output-serialization '"{"JSON": {Type: "DOCUMENT"}}"' /dev/stdout

Note: If you have any single quotes inside your JSON string, needs to be escaped with backslash \.

  • Related