I have access to some indexed BAM files in S3. Using the [AWS CLI][1], it is fairly easy to download the entire BAM file. That was fine for our initial analysis, but for validation, we are interested in looking a small region of ~10kb in thousands of individuals.

The BAM files are indexed and S3 supports GET requests with [range headers][2] so this should be possible. Does anyone know of a tool that does this?

EDIT: [htslib 1.3][3] was recently released and supports random access to BAM files in s3.

 [1]: http://docs.aws.amazon.com/cli/latest/reference/s3/cp.html
 [2]: https://docs.aws.amazon.com/AmazonS3/latest/dev/GettingObjectsUsingAPIs.html
 [3]: https://github.com/samtools/htslib/releases/tag/1.3
The upcoming samtools 1.3 release will support this. As well as the current way of accessing public buckets in donfreed's comment on another answer, samtools 1.3 will understand s3: pseudo-URLs like

    s3://1000genomes/phase1/data/NA12878/exome_alignment/NA12878.blah.bam

For accessing private buckets, samtools will look for your AWS credentials in the usual configuration files and environment variables, or you can specify them on the command line as *s3://id:secret@bucket/*... though that's not particularly recommended.

This release will be fairly soon. In the meantime, you can try this out by building samtools with GitHub htslib's **libcurl** branch. The code in that branch only looks for credentials in `$AWS_ACCESS_KEY_ID` / `$AWS_SECRET_ACCESS_KEY` and as *id:secret* in the URL.