Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created March 21, 2023 17:00
Show Gist options
  • Save hendrixroa/347f61e79ec16dfd39468e17aea5649e to your computer and use it in GitHub Desktop.
Save hendrixroa/347f61e79ec16dfd39468e17aea5649e to your computer and use it in GitHub Desktop.
S3 object loop to iterate over a folder to upload all files from a folder directory
resource "aws_s3_object" "storage" {
for_each = fileset("${var.path_files}/", "*")
bucket = aws_s3_bucket.storage_bucket.id
key = each.value
source = "${var.path_files}/${each.value}"
etag = filemd5("${var.path_files}/${each.value}")
acl = "public-read"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment