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

Terraform Template

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

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