deploy aws s3 bucket and create some default folders in it

#546
Raw
Author
Anonymous
Created
Sept. 7, 2022, 7:35 p.m.
Expires
Never
Size
754 bytes
Hits
29
Syntax
Terraform
Private
No
resource "aws_s3_bucket" "input" {
  bucket = "project-${var.envir}-fileinput"

  tags = {
    Name        = "Where we upload files"
    Environment = var.envir
  }
}

resource "aws_s3_object" "input_basic_folders" {
  for_each     = var.default_s3_directories
  bucket       = aws_s3_bucket.input.id
  key          = "${each.value}/"
  content_type = "application/x-directory"
}

variable "envir" {
  type        = string
  description = "Environment's name - fed by tfvars"
  default     = "dev"
}

variable "default_s3_directories" {
  type        = set(string)
  description = "Names of directories we want in every bucket"
  default     = ["ClientData", "Reports", "TempData", "Templates"]
}