Data Source: aws_s3_bucket_objects#
~> Note The aws_s3_bucket_objects
data source is DEPRECATED and will be removed in a future version! Use aws_s3_objects
instead, where new features and fixes will be added.
~> Note on max_keys
: Retrieving very large numbers of keys can adversely affect Terraform's performance.
The objects data source returns keys (i.e., file names) and other metadata about objects in an S3 bucket.
Example Usage#
The following example retrieves a list of all object keys in an S3 bucket and creates corresponding Terraform object data sources:
data "aws_s3_objects" "example" {
bucket = "tf-example"
}
data "aws_s3_object" "example" {
count = length(data.aws_s3_objects.example.keys)
key = element(data.aws_s3_objects.example.keys, count.index)
bucket = data.aws_s3_objects.example.bucket
}
Argument Reference#
The following arguments are supported:
bucket
- (Required) Lists object keys in this S3 bucket.prefix
- (Optional) Limits results to object keys with this prefix.delimiter
- (Optional) A character used to group keys.encoding_type
- (Optional) Encodes keys using this method. Valid value isurl
.max_keys
- (Optional) Maximum object keys to return. Defaults to1000
.start_after
- (Optional) Returns key names lexicographically after a specific object key in your bucket. S3 lists object keys in UTF-8 character encoding in lexicographical order.fetch_owner
- (Optional) Boolean specifying whether to populate the owner list. Defaults tofalse
.
Attributes Reference#
In addition to all arguments above, the following attributes are exported:
keys
- List of strings representing object keys.common_prefixes
- List of any keys betweenprefix
and the next occurrence ofdelimiter
(i.e., similar to subdirectories of theprefix
"directory"); the list is only returned when you specifydelimiter
.id
- S3 Bucket.owners
- List of strings representing object owner IDs (seefetch_owner
above).