diff --git a/server/terraform/charm/outputs.tf b/server/terraform/charm/outputs.tf index feb84a1ab..c1987ec1b 100644 --- a/server/terraform/charm/outputs.tf +++ b/server/terraform/charm/outputs.tf @@ -6,6 +6,7 @@ output "app_name" { output "endpoints" { description = "Map of all endpoints" value = { - nginx_route = "nginx-route" + nginx_route = "nginx-route" + traefik_route = "traefik-route" } } diff --git a/server/terraform/charm/variables.tf b/server/terraform/charm/variables.tf index 40fc5f4d6..262adec66 100644 --- a/server/terraform/charm/variables.tf +++ b/server/terraform/charm/variables.tf @@ -1,6 +1,6 @@ variable "app_name" { type = string - default = "api" + default = "hwapi" description = "Name to give the deployed application" } diff --git a/server/terraform/product/README.md b/server/terraform/product/README.md index 0733094d9..70b8a4f5b 100644 --- a/server/terraform/product/README.md +++ b/server/terraform/product/README.md @@ -39,27 +39,25 @@ deployment onto any Kubernetes environment managed by [Juju]. | Name | Type | | ------------------------------------------------------------- | ----------- | | [juju_model.hardware_api][juju_model] | data source | -| [juju_application.nginx_ingress_integrator][juju_application] | resource | -| [juju_integration.hardware_api_ingress][juju_integration] | resource | +| [juju_application.traefik_k8s][juju_application] | resource | +| [juju_integration.traefik_k8s-hardware_api][juju_integration] | resource | +| [juju_application.lego][juju_application] | resource | +| [juju_integration.lego-traefik_k8s][juju_integration] | resource | ## Inputs -| Name | Description | Type | -| ------------------------ | --------------------------------------------------------------------------------- | ------ | -| model | Reference to an existing model resource or data source for the model to deploy to | string | -| hardware_api | n/a | object | -| nginx_ingress_integrator | n/a | object | +| Name | Description | Type | +| ------------ | --------------------------------------------------------------------------------- | ------ | +| model | Reference to an existing model resource or data source for the model to deploy to | string | +| hardware_api | n/a | object | +| traefik_k8s | n/a | object | +| lego | n/a | object | ## Outputs -| Name | Description | -| --------------------------------- | --------------------------------------------------------- | -| hardware_api_app_name | Name of the deployed Hardware API application | -| hardware_api_requires | | -| hardware_api_provides | | -| nginx_ingress_integrator_app_name | Name of the deployed NGINX Ingress Integrator application | -| nginx_ingress_integrator_requires | | -| nginx_ingress_integrator_provides | | +| Name | Description | +| ------------ | -------------------------------------- | +| applications | The applications making up the product | [terraform]: https://terraform.io [hardware-api-charm]: https://charmhub.io/hardware-api diff --git a/server/terraform/product/main.tf b/server/terraform/product/main.tf index fde01cdf1..1dba58c8f 100644 --- a/server/terraform/product/main.tf +++ b/server/terraform/product/main.tf @@ -14,27 +14,51 @@ module "hardware_api" { units = var.hardware_api.units } -resource "juju_application" "nginx_ingress_integrator" { - name = var.nginx_ingress_integrator.app_name +resource "juju_application" "traefik_k8s" { + name = var.traefik_k8s.app_name model = data.juju_model.hardware_api.name trust = true charm { - name = "nginx-ingress-integrator" - channel = var.nginx_ingress_integrator.channel - revision = var.nginx_ingress_integrator.revision + name = "traefik-k8s" + channel = var.traefik_k8s.channel + revision = var.traefik_k8s.revision } - units = var.nginx_ingress_integrator.units - config = var.nginx_ingress_integrator.config + units = 1 + config = var.traefik_k8s.config } -resource "juju_integration" "hardware_api_ingress" { +resource "juju_integration" "traefik_k8s-hardware_api" { model = data.juju_model.hardware_api.name + application { + name = juju_application.traefik_k8s.name + endpoint = "traefik-route" + } application { name = module.hardware_api.app_name - endpoint = module.hardware_api.endpoints.nginx_route + endpoint = module.hardware_api.endpoints.traefik_route + } +} + +resource "juju_application" "lego" { + name = var.lego.app_name + model = data.juju_model.hardware_api.name + charm { + name = "lego" + channel = var.lego.channel + revision = var.lego.revision + } + units = 1 + config = var.lego.config +} + +resource "juju_integration" "lego-traefik_k8s" { + model = data.juju_model.hardware_api.name + application { + name = juju_application.lego.name + endpoint = "certificates" } application { - name = juju_application.nginx_ingress_integrator.name - endpoint = "nginx-route" + name = juju_application.traefik_k8s.name + endpoint = "certificates" } } diff --git a/server/terraform/product/outputs.tf b/server/terraform/product/outputs.tf index e0cafd81f..e3c22690b 100644 --- a/server/terraform/product/outputs.tf +++ b/server/terraform/product/outputs.tf @@ -1,29 +1,7 @@ -output "hardware_api_app_name" { - description = "The name of the Hardware API application" - value = module.hardware_api.app_name -} - -output "hardware_api_requires" { - value = { - nginx_route = "nginx-route" - } -} - -output "hardware_api_provides" { - value = {} -} - -output "nginx_ingress_integrator_app_name" { - description = "The name of the NGINX Ingress Integrator application" - value = juju_application.nginx_ingress_integrator.name -} - -output "nginx_ingress_integrator_requires" { - value = {} -} - -output "nginx_ingress_integrator_provides" { +output "applications" { value = { - nginx_route = "nginx-route" + hardware_api = module.hardware_api + traefik_k8s = juju_application.traefik_k8s + lego = juju_application.lego } } diff --git a/server/terraform/product/variables.tf b/server/terraform/product/variables.tf index ced691d7e..330005450 100644 --- a/server/terraform/product/variables.tf +++ b/server/terraform/product/variables.tf @@ -7,7 +7,7 @@ variable "model" { variable "hardware_api" { type = object({ - app_name = optional(string, "api") + app_name = optional(string, "hwapi") channel = optional(string, "latest/edge") config = optional(map(string), {}) constraints = optional(string, "arch=amd64") @@ -17,12 +17,20 @@ variable "hardware_api" { }) } -variable "nginx_ingress_integrator" { +variable "traefik_k8s" { type = object({ app_name = optional(string, "ingress") channel = optional(string, "latest/stable") config = optional(map(string), {}) revision = optional(number) - units = optional(number, 1) + }) +} + +variable "lego" { + type = object({ + app_name = optional(string, "certificates") + channel = optional(string, "latest/stable") + config = optional(map(string), {}) + revision = optional(number) }) }