feat: first version
This commit is contained in:
3
modules/buckets/locals.tf
Normal file
3
modules/buckets/locals.tf
Normal file
@@ -0,0 +1,3 @@
|
||||
locals {
|
||||
aliases = concat([var.name], var.global_aliases)
|
||||
}
|
||||
22
modules/buckets/main.tf
Normal file
22
modules/buckets/main.tf
Normal file
@@ -0,0 +1,22 @@
|
||||
resource "garage_bucket" "bucket" {
|
||||
website_access_enabled = var.website_access_enabled
|
||||
website_config_index_document = var.website_access_enabled == true ? "index.html" : null
|
||||
}
|
||||
|
||||
resource "garage_bucket_global_alias" "bucket_alias" {
|
||||
bucket_id = garage_bucket.bucket.id
|
||||
|
||||
for_each = toset(local.aliases)
|
||||
|
||||
alias = each.key
|
||||
}
|
||||
|
||||
resource "garage_bucket_key" "authorized_keys" {
|
||||
bucket_id = garage_bucket.bucket.id
|
||||
|
||||
for_each = var.allowed_keys
|
||||
access_key_id = var.global_keys[each.key].access_key_id
|
||||
read = each.value.read
|
||||
write = each.value.write
|
||||
owner = each.value.owner
|
||||
}
|
||||
8
modules/buckets/providers.tf
Normal file
8
modules/buckets/providers.tf
Normal file
@@ -0,0 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
garage = {
|
||||
source = "ceski23/garage2"
|
||||
version = "0.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
32
modules/buckets/variables.tf
Normal file
32
modules/buckets/variables.tf
Normal file
@@ -0,0 +1,32 @@
|
||||
variable "name" {
|
||||
description = "Global alias of the bucket"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "website_access_enabled" {
|
||||
description = "Is direct HTTP access enabled?"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "global_aliases" {
|
||||
description = "Optional list of aliases for the bucket"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "global_keys" {
|
||||
description = "List of all keys of the Garage instance"
|
||||
type = map(object({
|
||||
access_key_id = string
|
||||
}))
|
||||
}
|
||||
|
||||
variable "allowed_keys" {
|
||||
description = "Keys authorized for that specific bucket, with their authorization"
|
||||
type = map(object({
|
||||
read = optional(bool, false)
|
||||
write = optional(bool, false)
|
||||
owner = optional(bool, false)
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user