From 078e9d04772d76007d690f84e246c5c96b76df4b Mon Sep 17 00:00:00 2001 From: Pietro Pasotti Date: Fri, 24 Apr 2026 10:06:30 +0200 Subject: [PATCH] feat(terraform): add seaweedfs storage backend module --- terraform/seaweedfs/main.tf | 15 +++++++++ terraform/seaweedfs/outputs.tf | 16 ++++++++++ terraform/seaweedfs/variables.tf | 54 ++++++++++++++++++++++++++++++++ terraform/seaweedfs/versions.tf | 9 ++++++ 4 files changed, 94 insertions(+) create mode 100644 terraform/seaweedfs/main.tf create mode 100644 terraform/seaweedfs/outputs.tf create mode 100644 terraform/seaweedfs/variables.tf create mode 100644 terraform/seaweedfs/versions.tf diff --git a/terraform/seaweedfs/main.tf b/terraform/seaweedfs/main.tf new file mode 100644 index 00000000..d29015da --- /dev/null +++ b/terraform/seaweedfs/main.tf @@ -0,0 +1,15 @@ +resource "juju_application" "seaweedfs" { + config = var.config + constraints = var.constraints + model_uuid = var.model_uuid + name = var.app_name + storage_directives = var.storage_directives + trust = true + units = var.units + + charm { + name = "seaweedfs-k8s" + channel = var.channel + revision = var.revision + } +} diff --git a/terraform/seaweedfs/outputs.tf b/terraform/seaweedfs/outputs.tf new file mode 100644 index 00000000..75513e7d --- /dev/null +++ b/terraform/seaweedfs/outputs.tf @@ -0,0 +1,16 @@ +output "app_name" { + value = juju_application.seaweedfs.name + description = "The name of the deployed SeaweedFS application" +} + +output "provides" { + value = { + s3 = "s3" + } + description = "All Juju integration endpoints where the charm is the provider" +} + +output "requires" { + value = {} + description = "All Juju integration endpoints where the charm is the requirer" +} diff --git a/terraform/seaweedfs/variables.tf b/terraform/seaweedfs/variables.tf new file mode 100644 index 00000000..1a3a1d27 --- /dev/null +++ b/terraform/seaweedfs/variables.tf @@ -0,0 +1,54 @@ +variable "model_uuid" { + description = "Reference to an existing model resource or data source for the model to deploy to" + type = string +} + +variable "app_name" { + description = "Application name for the SeaweedFS deployment" + type = string + default = "seaweedfs" +} + +variable "channel" { + description = "Channel that SeaweedFS is deployed from" + type = string + default = "latest/edge" +} + +variable "revision" { + description = "Revision number of the SeaweedFS application" + type = number + default = null +} + +variable "config" { + description = "Map of SeaweedFS configuration options" + type = map(string) + default = {} +} + +# FIXME: Passing an empty constraints value to the Juju Terraform provider currently +# causes the operation to fail due to https://github.com/juju/terraform-provider-juju/issues/344 +# Therefore, we set a default value of "arch=amd64" for all applications. + +variable "constraints" { + description = "String listing constraints for the SeaweedFS application" + type = string + default = "arch=amd64" +} + +variable "storage_directives" { + description = "Map of storage used by SeaweedFS, which defaults to 1 GB, allocated by Juju" + type = map(string) + default = {} +} + +variable "units" { + description = "Number of SeaweedFS units" + type = number + default = 1 + validation { + condition = var.units >= 1 + error_message = "The number of units must be greater than or equal to 1." + } +} diff --git a/terraform/seaweedfs/versions.tf b/terraform/seaweedfs/versions.tf new file mode 100644 index 00000000..a77a6b92 --- /dev/null +++ b/terraform/seaweedfs/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.7" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.19" + } + } +}