Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

resource "juju_application" "__charm_name__" {
name = var.app_name
model = var.model
resource "juju_application" "mattermost_k8s" {
name = var.app_name
model_uuid = var.model_uuid

charm {
name = "__charm_name__"
name = "mattermost-k8s"
channel = var.channel
revision = var.revision
base = var.base
Expand Down
9 changes: 6 additions & 3 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

output "app_name" {
description = "Name of the deployed application."
value = juju_application.__charm_name__.name
value = juju_application.mattermost_k8s.name
}

output "endpoints" {
output "requires" {
value = {
ingress = "ingress"
postgresql = "postgresql"
s3 = "s3"
smtp = "smtp"
ingress = "ingress"
}
}
161 changes: 161 additions & 0 deletions terraform/product/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

module "mattermost" {
source = "../"
model_uuid = var.model_uuid
app_name = var.mattermost.app_name
channel = var.mattermost.channel
revision = var.mattermost.revision
base = var.mattermost.base
config = var.mattermost.config
units = var.mattermost.units
}

resource "juju_application" "postgresql" {
name = "postgresql-k8s"
model_uuid = var.model_uuid

charm {
name = "postgresql-k8s"
channel = var.postgresql.channel
revision = var.postgresql.revision
}

config = var.postgresql.config
trust = true
units = var.postgresql.units
}

resource "juju_application" "s3_integrator" {
name = "s3-integrator"
model_uuid = var.model_uuid

charm {
name = "s3-integrator"
channel = var.s3_integrator.channel
revision = var.s3_integrator.revision
}

config = var.s3_integrator.config
units = 1

provisioner "local-exec" {
command = "sleep 60; juju run ${self.name}/leader sync-s3-credentials access-key=${var.s3_integrator.access_key} secret-key=${var.s3_integrator.secret_key}"
}
}

resource "juju_application" "smtp_integrator" {
name = "smtp-integrator"
model_uuid = var.model_uuid

charm {
name = "smtp-integrator"
channel = var.smtp_integrator.channel
revision = var.smtp_integrator.revision
}

config = var.smtp_integrator.config
units = 1
}

resource "juju_application" "ingress_configurator" {
name = "ingress-configurator"
model_uuid = var.model_uuid

charm {
name = "ingress-configurator"
channel = var.ingress_configurator.channel
revision = var.ingress_configurator.revision
base = "ubuntu@24.04"
}

config = { hostname = var.external_hostname }
trust = true
units = 1
}

resource "juju_application" "self_signed_certificates" {
name = "self-signed-certificates"
model_uuid = var.model_uuid

charm {
name = "self-signed-certificates"
channel = var.self_signed_certificates.channel
revision = var.self_signed_certificates.revision
}

units = 1
}

# --- Integrations ---

resource "juju_integration" "mattermost_postgresql" {
model_uuid = var.model_uuid

application {
name = module.mattermost.app_name
endpoint = module.mattermost.requires.postgresql
}

application {
name = juju_application.postgresql.name
endpoint = "database"
}
}

resource "juju_integration" "mattermost_s3" {
model_uuid = var.model_uuid

application {
name = module.mattermost.app_name
endpoint = module.mattermost.requires.s3
}

application {
name = juju_application.s3_integrator.name
endpoint = "s3-credentials"
}
}

resource "juju_integration" "mattermost_smtp" {
model_uuid = var.model_uuid

application {
name = module.mattermost.app_name
endpoint = module.mattermost.requires.smtp
}

application {
name = juju_application.smtp_integrator.name
endpoint = "smtp"
}
}

resource "juju_integration" "postgresql_tls" {
model_uuid = var.model_uuid

application {
name = juju_application.postgresql.name
endpoint = "certificates"
}

application {
name = juju_application.self_signed_certificates.name
endpoint = "certificates"
}
}

resource "juju_integration" "mattermost_ingress" {
model_uuid = var.model_uuid

application {
name = module.mattermost.app_name
endpoint = module.mattermost.requires.ingress
}

application {
name = juju_application.ingress_configurator.name
endpoint = "ingress"
}
}
23 changes: 23 additions & 0 deletions terraform/product/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

output "mattermost_app_name" {
description = "Name of the deployed Mattermost application."
value = module.mattermost.app_name
}

output "postgresql_app_name" {
description = "Name of the deployed PostgreSQL application."
value = juju_application.postgresql.name
}

output "ingress_configurator" {
description = "Ingress configurator outputs."
value = {
app_name = juju_application.ingress_configurator.name
endpoints = {
ingress = "ingress"
haproxy_route = "haproxy-route"
}
}
}
72 changes: 72 additions & 0 deletions terraform/product/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

variable "model_uuid" {
description = "UUID of the Juju model where the applications will be deployed."
type = string
}

variable "external_hostname" {
description = "External hostname for ingress (used by ingress-configurator)."
type = string
}

variable "mattermost" {
description = "Mattermost charm configuration."
type = object({
app_name = optional(string, "mattermost-k8s")
channel = string
revision = number
base = optional(string, "ubuntu@24.04")
config = optional(map(string), {})
units = optional(number, 1)
})
}

variable "postgresql" {
description = "PostgreSQL K8s charm configuration."
type = object({
channel = string
revision = number
config = optional(map(string), {})
units = optional(number, 1)
})
}

variable "s3_integrator" {
description = "S3 integrator charm configuration."
type = object({
channel = string
revision = number
config = optional(map(string), {})
access_key = string
secret_key = string
})
}

variable "smtp_integrator" {
description = "SMTP integrator charm configuration."
type = object({
channel = string
revision = number
config = optional(map(string), {})
})
}

variable "self_signed_certificates" {
description = "Self-signed certificates charm configuration."
type = object({
channel = optional(string, "latest/stable")
revision = optional(number, null)
})
default = {}
}

variable "ingress_configurator" {
description = "Ingress configurator charm configuration."
type = object({
channel = optional(string, "latest/edge")
revision = optional(number, 72)
})
default = {}
}
12 changes: 12 additions & 0 deletions terraform/product/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

terraform {
required_version = ">= 1.12.0"
required_providers {
juju = {
source = "juju/juju"
version = "~> 1.4.3"
}
}
}
8 changes: 4 additions & 4 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
variable "app_name" {
description = "Name of the application in the Juju model."
type = string
default = "__charm_name__"
default = "mattermost-k8s"
}

variable "base" {
Expand All @@ -20,7 +20,7 @@ variable "channel" {
}

variable "config" {
description = "Application config. Details about available options can be found at https://charmhub.io/__charm_name__/configurations."
description = "Application config. Details about available options can be found at https://charmhub.io/mattermost-k8s/configurations."
type = map(string)
default = {}
}
Expand All @@ -31,8 +31,8 @@ variable "constraints" {
default = ""
}

variable "model" {
description = "Reference to a `juju_model`."
variable "model_uuid" {
description = "UUID of the Juju model where the application will be deployed."
type = string
}

Expand Down
Loading