files.tf 965 B

1234567891011121314151617181920212223
  1. # Copy files into the bucket
  2. locals {
  3. all_files = fileset("${path.module}/files/${var.name}/", "**")
  4. # ignore any files that include `.terragrunt` in their filename
  5. relevant_files = [for file in local.all_files : file if length(regexall("\\.terragrunt", file)) == 0]
  6. }
  7. output "Files_Copied_to_S3_by_this_Module" {
  8. value = local.relevant_files
  9. }
  10. resource "aws_s3_object" "populate" {
  11. for_each = toset(local.relevant_files)
  12. bucket = aws_s3_bucket.bucket.bucket
  13. key = each.value
  14. source = "${path.module}/files/${var.name}/${each.value}"
  15. # etag makes the file update when it changes; see https://stackoverflow.com/questions/56107258/terraform-upload-file-to-s3-on-every-apply
  16. # But this does not work with kms encryption...
  17. # TODO: When Source hash is merged, use that: https://github.com/hashicorp/terraform-provider-aws/pull/11522
  18. # Until then, leave it disabled.
  19. #etag = filemd5("${path.module}/files/${var.name}/${each.value}")
  20. }