Skip to main content
selectAWSlast verified 2026-07-29
Servicess3
CredentialsAWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
Permissionss3:ListAllMyBuckets
Contributed byJeffrey Aven, StackQL Studios

S3 buckets cheap enumeration

Enumerates every S3 bucket in the account in a single call. Bucket listing is account-global, so the region only routes the request - the bucket's own region comes back in bucket_region. This is the cheap inventory path and the enumeration step before any per-bucket configuration read.

Query

SELECT name, bucket_region, bucket_arn, creation_date
FROM aws.s3.buckets
WHERE region = '{{region}}'
AND "max-buckets" = 1000;

Variation: buckets matching a name prefix

SELECT name, bucket_region, creation_date
FROM aws.s3.buckets
WHERE region = '{{region}}'
AND prefix = 'my-app-';

Notes

The "max-buckets" predicate is load-bearing and not just a page size: AWS only populates BucketRegion when the list request carries at least one optional query parameter, so without it every bucket returns a null region while still listing correctly. Quote the column name - the hyphen makes it an invalid bare identifier. 1000 is the API maximum; supplying prefix instead has the same region-populating effect. There is no aws.s3.buckets_list_only resource - the awscc provider exposes awscc.s3.buckets_list_only, but this native call already returns names, ARNs, regions and creation dates in one request, so it is the better enumeration. Pair with aws/s3/bucket-detail for per-bucket configuration, one request per bucket.

Related queries

  • S3 bucket security detail - Full security configuration for one bucket: public access block, encryption, versioning, ownership controls and logging.
  • S3 bucket public access block audit - Reports the four block-public-access settings plus object ownership for a bucket; any flag returning 0 leaves a public exposure path open.