diff --git a/aws/data_source_aws_s3_bucket_objects.go b/aws/data_source_aws_s3_bucket_objects.go index 351b7f5a37b..a3ef69ff050 100644 --- a/aws/data_source_aws_s3_bucket_objects.go +++ b/aws/data_source_aws_s3_bucket_objects.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform/helper/schema" ) -const maxS3ObjectListReqSize = 1000 +const keyRequestPageSize = 1000 func dataSourceAwsS3BucketObjects() *schema.Resource { return &schema.Resource{ @@ -36,6 +36,7 @@ func dataSourceAwsS3BucketObjects() *schema.Resource { "max_keys": { Type: schema.TypeInt, Optional: true, + Default: 1000, }, "start_after": { Type: schema.TypeString, @@ -110,14 +111,14 @@ func dataSourceAwsS3BucketObjectsRead(d *schema.ResourceData, meta interface{}) listInput.EncodingType = aws.String(s.(string)) } - // MaxKeys attribute refers to max keys returned in a single request + // "listInput.MaxKeys" refers to max keys returned in a single request // (i.e., page size), not the total number of keys returned if you page - // through the results. This reduces # requests to fewest possible. + // through the results. "maxKeys" does refer to total keys returned. maxKeys := -1 if max, ok := d.GetOk("max_keys"); ok { maxKeys = max.(int) - if maxKeys > maxS3ObjectListReqSize { - listInput.MaxKeys = aws.Int64(int64(maxS3ObjectListReqSize)) + if maxKeys > keyRequestPageSize { + listInput.MaxKeys = aws.Int64(int64(keyRequestPageSize)) } else { listInput.MaxKeys = aws.Int64(int64(maxKeys)) } diff --git a/website/docs/d/s3_bucket_objects.html.markdown b/website/docs/d/s3_bucket_objects.html.markdown index fa031e1c005..5699e876733 100644 --- a/website/docs/d/s3_bucket_objects.html.markdown +++ b/website/docs/d/s3_bucket_objects.html.markdown @@ -8,7 +8,7 @@ description: |- # Data Source: aws_s3_bucket_objects -The bucket-objects data source returns keys and other metadata about objects in an S3 bucket. +The bucket-objects data source returns keys (i.e., file names) and other metadata about objects in an S3 bucket. ## Example Usage @@ -34,7 +34,10 @@ The following arguments are supported: * `prefix` - (Optional) Limits results to object keys with this prefix (Default: none) * `delimiter` - (Optional) A character used to group keys (Default: none) * `encoding_type` - (Optional) Encodes keys using this method (Default: none; besides none, only "url" can be used) -* `max_objects` - (Optional) Maximum object keys to list (Default: all keys in the bucket) +* `max_keys` - (Optional) Maximum object keys to return or `-1` to retrieve all keys (Default: 1000) + +~> **NOTE on `max_keys`:** Retrieving very large numbers of keys can adversely affect Terraform's performance. + * `start_after` - (Optional) Returns key names lexicographically after a specific object key in your bucket (Default: none; S3 lists object keys in UTF-8 character encoding in lexicographical order) * `fetch_owner` - (Optional) Boolean specifying whether to populate the owner list (Default: false)