This template retrieves all object keys and their metadata from a specified S3 bucket and creates Terraform data sources for each object.

Terraform Template

data "aws_s3_bucket_objects" "my_objects" {
  bucket = "ourcorp"
}

data "aws_s3_object" "object_info" {
  bucket = data.aws_s3_bucket_objects.my_objects.id
  count = length(data.aws_s3_bucket_objects.my_objects.keys)
  key = element(data.aws_s3_bucket_objects.my_objects.keys, count.index)
}