From 5e00716478f5231a189b249a336d6ad14f589896 Mon Sep 17 00:00:00 2001 From: Ghislain Bourgeois Date: Fri, 4 Oct 2024 19:30:55 -0400 Subject: [PATCH] Refactor sdcore-control-plane-k8s to follow spec CC006. --- modules/sdcore-control-plane-k8s/README.md | 10 +- modules/sdcore-control-plane-k8s/main.tf | 302 +++++++++--------- modules/sdcore-control-plane-k8s/outputs.tf | 4 +- modules/sdcore-control-plane-k8s/variables.tf | 11 +- 4 files changed, 166 insertions(+), 161 deletions(-) diff --git a/modules/sdcore-control-plane-k8s/README.md b/modules/sdcore-control-plane-k8s/README.md index cd26f42..9a409f8 100644 --- a/modules/sdcore-control-plane-k8s/README.md +++ b/modules/sdcore-control-plane-k8s/README.md @@ -11,7 +11,7 @@ The module can be used to deploy the `sdcore-control-plane-k8s` separately as we - **main.tf** - Defines the Juju application to be deployed. - **variables.tf** - Allows customization of the deployment including Juju model name, charm's channel and configuration. - **output.tf** - Responsible for integrating the module with other Terraform modules, primarily by defining potential integration endpoints (charm integrations). -- **terraform.tf** - Defines the Terraform provider. +- **versions.tf** - Defines the Terraform provider. ## Deploying sdcore-control-plane-k8s module separately @@ -73,7 +73,11 @@ Create the `terraform.tfvars` file to specify the name of the Juju model to depl ```console cat << EOF | tee terraform.tfvars -model_name = "put your model-name here" +data "juju_model" "sdcore_k8s" { + name = "put your model-name here" +} + +model = data.juju_model.sdcore_k8s.name # Customize the configuration variables here if needed EOF @@ -181,7 +185,7 @@ If you want to use `sdcore-control-plane-k8s` module as part of your Terraform m module "sdcore-control-plane" { source = "git::https://github.com/canonical/https://github.com/canonical/terraform-juju-sdcore-k8s//modules/sdcore-control-plane-k8s" - model_name = "juju_model_name" + model = data.juju_model.model.name (Customize configuration variables here if needed) } ``` diff --git a/modules/sdcore-control-plane-k8s/main.tf b/modules/sdcore-control-plane-k8s/main.tf index c4f2a0a..335a7f4 100644 --- a/modules/sdcore-control-plane-k8s/main.tf +++ b/modules/sdcore-control-plane-k8s/main.tf @@ -1,91 +1,99 @@ # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. -resource "juju_model" "sdcore" { - count = var.create_model == true ? 1 : 0 - name = var.model_name +data "juju_model" "sdcore" { + name = var.model } module "amf" { - source = "git::https://github.com/canonical/sdcore-amf-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel - config = var.amf_config + source = "git::https://github.com/canonical/sdcore-amf-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + config = var.amf_config + constraints = "arch=amd64" } module "ausf" { - source = "git::https://github.com/canonical/sdcore-ausf-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-ausf-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "nms" { - source = "git::https://github.com/canonical/sdcore-nms-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-nms-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "nrf" { - source = "git::https://github.com/canonical/sdcore-nrf-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-nrf-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "nssf" { - source = "git::https://github.com/canonical/sdcore-nssf-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel - config = var.nssf_config + source = "git::https://github.com/canonical/sdcore-nssf-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + config = var.nssf_config + constraints = "arch=amd64" } module "pcf" { - source = "git::https://github.com/canonical/sdcore-pcf-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-pcf-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "smf" { - source = "git::https://github.com/canonical/sdcore-smf-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-smf-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "udm" { - source = "git::https://github.com/canonical/sdcore-udm-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-udm-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "udr" { - source = "git::https://github.com/canonical/sdcore-udr-k8s-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name - channel = var.sdcore_channel + source = "git::https://github.com/canonical/sdcore-udr-k8s-operator//terraform?ref=chore-cc006" + model = data.juju_model.sdcore.name + channel = var.sdcore_channel + constraints = "arch=amd64" } module "mongodb" { source = "../external/mongodb-k8s" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model_name = data.juju_model.sdcore.name channel = var.mongo_channel config = var.mongo_config } module "grafana-agent" { source = "../external/grafana-agent-k8s" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model_name = data.juju_model.sdcore.name channel = var.grafana_agent_channel config = var.grafana_agent_config } module "self-signed-certificates" { source = "git::https://github.com/canonical/self-signed-certificates-operator//terraform" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model_name = data.juju_model.sdcore.name channel = var.self_signed_certificates_channel config = var.self_signed_certificates_config } module "traefik" { source = "../external/traefik-k8s" - model_name = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model_name = data.juju_model.sdcore.name channel = var.traefik_channel config = var.traefik_config } @@ -93,111 +101,111 @@ module "traefik" { # Integrations for `fiveg-nrf` endpoint resource "juju_integration" "amf-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.amf.app_name - endpoint = module.amf.fiveg_nrf_endpoint + endpoint = module.amf.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } resource "juju_integration" "udm-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udm.app_name - endpoint = module.udm.fiveg_nrf_endpoint + endpoint = module.udm.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } resource "juju_integration" "smf-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.smf.app_name - endpoint = module.smf.fiveg_nrf_endpoint + endpoint = module.smf.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } resource "juju_integration" "pcf-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.pcf.app_name - endpoint = module.pcf.fiveg_nrf_endpoint + endpoint = module.pcf.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } resource "juju_integration" "nssf-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nssf.app_name - endpoint = module.nssf.fiveg_nrf_endpoint + endpoint = module.nssf.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } resource "juju_integration" "udr-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.fiveg_nrf_endpoint + endpoint = module.udr.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } resource "juju_integration" "ausf-fiveg-nrf" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.ausf.app_name - endpoint = module.ausf.fiveg_nrf_endpoint + endpoint = module.ausf.requires.fiveg_nrf } application { name = module.nrf.app_name - endpoint = module.nrf.fiveg_nrf_endpoint + endpoint = module.nrf.provides.fiveg_nrf } } # Integrations for `database` endpoint resource "juju_integration" "udr-auth-database" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.auth_database_endpoint + endpoint = module.udr.requires.auth_database } application { @@ -207,11 +215,11 @@ resource "juju_integration" "udr-auth-database" { } resource "juju_integration" "udr-common-database" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.common_database_endpoint + endpoint = module.udr.requires.common_database } application { @@ -221,11 +229,11 @@ resource "juju_integration" "udr-common-database" { } resource "juju_integration" "nrf-database" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nrf.app_name - endpoint = module.nrf.database_endpoint + endpoint = module.nrf.requires.database } application { @@ -235,11 +243,11 @@ resource "juju_integration" "nrf-database" { } resource "juju_integration" "nms-auth-database" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nms.app_name - endpoint = module.nms.auth_database_endpoint + endpoint = module.nms.requires.auth_database } application { @@ -249,11 +257,11 @@ resource "juju_integration" "nms-auth-database" { } resource "juju_integration" "nms-common-database" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nms.app_name - endpoint = module.nms.common_database_endpoint + endpoint = module.nms.requires.common_database } application { @@ -265,125 +273,125 @@ resource "juju_integration" "nms-common-database" { # Integrations for `sdcore_config` endpoint resource "juju_integration" "amf-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.amf.app_name - endpoint = module.amf.sdcore_config_endpoint + endpoint = module.amf.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "ausf-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.ausf.app_name - endpoint = module.ausf.sdcore_config_endpoint + endpoint = module.ausf.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "nrf-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nrf.app_name - endpoint = module.nrf.sdcore_config_endpoint + endpoint = module.nrf.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "nssf-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nssf.app_name - endpoint = module.nssf.sdcore_config_endpoint + endpoint = module.nssf.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "pcf-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.pcf.app_name - endpoint = module.pcf.sdcore_config_endpoint + endpoint = module.pcf.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "smf-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.smf.app_name - endpoint = module.smf.sdcore_config_endpoint + endpoint = module.smf.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "udm-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udm.app_name - endpoint = module.udm.sdcore_config_endpoint + endpoint = module.udm.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } resource "juju_integration" "udr-sdcore-config" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.sdcore_config_endpoint + endpoint = module.udr.requires.sdcore_config } application { name = module.nms.app_name - endpoint = module.nms.sdcore_config_endpoint + endpoint = module.nms.provides.sdcore_config } } # Integrations for `metrics` endpoint resource "juju_integration" "amf-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.amf.app_name - endpoint = module.amf.metrics_endpoint + endpoint = module.amf.provides.metrics } application { @@ -393,11 +401,11 @@ resource "juju_integration" "amf-metrics" { } resource "juju_integration" "ausf-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.ausf.app_name - endpoint = module.ausf.metrics_endpoint + endpoint = module.ausf.provides.metrics } application { @@ -407,7 +415,7 @@ resource "juju_integration" "ausf-metrics" { } resource "juju_integration" "mongodb-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.mongodb.app_name @@ -421,11 +429,11 @@ resource "juju_integration" "mongodb-metrics" { } resource "juju_integration" "nrf-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nrf.app_name - endpoint = module.nrf.metrics_endpoint + endpoint = module.nrf.provides.metrics } application { @@ -435,11 +443,11 @@ resource "juju_integration" "nrf-metrics" { } resource "juju_integration" "nssf-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nssf.app_name - endpoint = module.nssf.metrics_endpoint + endpoint = module.nssf.provides.metrics } application { @@ -449,11 +457,11 @@ resource "juju_integration" "nssf-metrics" { } resource "juju_integration" "pcf-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.pcf.app_name - endpoint = module.pcf.metrics_endpoint + endpoint = module.pcf.provides.metrics } application { @@ -463,11 +471,11 @@ resource "juju_integration" "pcf-metrics" { } resource "juju_integration" "smf-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.smf.app_name - endpoint = module.smf.metrics_endpoint + endpoint = module.smf.provides.metrics } application { @@ -477,11 +485,11 @@ resource "juju_integration" "smf-metrics" { } resource "juju_integration" "udm-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udm.app_name - endpoint = module.udm.metrics_endpoint + endpoint = module.udm.provides.metrics } application { @@ -491,11 +499,11 @@ resource "juju_integration" "udm-metrics" { } resource "juju_integration" "udr-metrics" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.metrics_endpoint + endpoint = module.udr.provides.metrics } application { @@ -507,11 +515,11 @@ resource "juju_integration" "udr-metrics" { # Integrations for `certificates` endpoint resource "juju_integration" "amf-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.amf.app_name - endpoint = module.amf.certificates_endpoint + endpoint = module.amf.requires.certificates } application { @@ -521,11 +529,11 @@ resource "juju_integration" "amf-certificates" { } resource "juju_integration" "udm-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udm.app_name - endpoint = module.udm.certificates_endpoint + endpoint = module.udm.requires.certificates } application { @@ -535,11 +543,11 @@ resource "juju_integration" "udm-certificates" { } resource "juju_integration" "smf-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.smf.app_name - endpoint = module.smf.certificates_endpoint + endpoint = module.smf.requires.certificates } application { @@ -549,11 +557,11 @@ resource "juju_integration" "smf-certificates" { } resource "juju_integration" "pcf-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.pcf.app_name - endpoint = module.pcf.certificates_endpoint + endpoint = module.pcf.requires.certificates } application { @@ -563,11 +571,11 @@ resource "juju_integration" "pcf-certificates" { } resource "juju_integration" "nssf-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nssf.app_name - endpoint = module.nssf.certificates_endpoint + endpoint = module.nssf.requires.certificates } application { @@ -577,11 +585,11 @@ resource "juju_integration" "nssf-certificates" { } resource "juju_integration" "nrf-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nrf.app_name - endpoint = module.nrf.certificates_endpoint + endpoint = module.nrf.requires.certificates } application { @@ -591,11 +599,11 @@ resource "juju_integration" "nrf-certificates" { } resource "juju_integration" "ausf-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.ausf.app_name - endpoint = module.ausf.certificates_endpoint + endpoint = module.ausf.requires.certificates } application { @@ -605,11 +613,11 @@ resource "juju_integration" "ausf-certificates" { } resource "juju_integration" "udr-certificates" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.certificates_endpoint + endpoint = module.udr.requires.certificates } application { @@ -621,11 +629,11 @@ resource "juju_integration" "udr-certificates" { # Integrations for `ingress` endpoint resource "juju_integration" "nms-ingress" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nms.app_name - endpoint = module.nms.ingress_endpoint + endpoint = module.nms.requires.ingress } application { @@ -637,7 +645,7 @@ resource "juju_integration" "nms-ingress" { # Integrations for `logging` endpoint resource "juju_integration" "mongodb-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.mongodb.app_name @@ -651,11 +659,11 @@ resource "juju_integration" "mongodb-logging" { } resource "juju_integration" "amf-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.amf.app_name - endpoint = module.amf.logging_endpoint + endpoint = module.amf.requires.logging } application { @@ -665,11 +673,11 @@ resource "juju_integration" "amf-logging" { } resource "juju_integration" "ausf-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.ausf.app_name - endpoint = module.ausf.logging_endpoint + endpoint = module.ausf.requires.logging } application { @@ -679,11 +687,11 @@ resource "juju_integration" "ausf-logging" { } resource "juju_integration" "nrf-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nrf.app_name - endpoint = module.nrf.logging_endpoint + endpoint = module.nrf.requires.logging } application { @@ -693,11 +701,11 @@ resource "juju_integration" "nrf-logging" { } resource "juju_integration" "nssf-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nssf.app_name - endpoint = module.nssf.logging_endpoint + endpoint = module.nssf.requires.logging } application { @@ -707,11 +715,11 @@ resource "juju_integration" "nssf-logging" { } resource "juju_integration" "pcf-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.pcf.app_name - endpoint = module.pcf.logging_endpoint + endpoint = module.pcf.requires.logging } application { @@ -721,11 +729,11 @@ resource "juju_integration" "pcf-logging" { } resource "juju_integration" "smf-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.smf.app_name - endpoint = module.smf.logging_endpoint + endpoint = module.smf.requires.logging } application { @@ -735,11 +743,11 @@ resource "juju_integration" "smf-logging" { } resource "juju_integration" "udm-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udm.app_name - endpoint = module.udm.logging_endpoint + endpoint = module.udm.requires.logging } application { @@ -749,11 +757,11 @@ resource "juju_integration" "udm-logging" { } resource "juju_integration" "udr-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.udr.app_name - endpoint = module.udr.logging_endpoint + endpoint = module.udr.requires.logging } application { @@ -763,11 +771,11 @@ resource "juju_integration" "udr-logging" { } resource "juju_integration" "nms-logging" { - model = var.create_model == true ? juju_model.sdcore[0].name : var.model_name + model = data.juju_model.sdcore.name application { name = module.nms.app_name - endpoint = module.nms.logging_endpoint + endpoint = module.nms.requires.logging } application { @@ -779,7 +787,7 @@ resource "juju_integration" "nms-logging" { # Cross-model integrations resource "juju_offer" "amf-fiveg-n2" { - model = var.model_name + model = data.juju_model.sdcore.name application_name = module.amf.app_name - endpoint = module.amf.fiveg_n2_endpoint + endpoint = module.amf.provides.fiveg_n2 } diff --git a/modules/sdcore-control-plane-k8s/outputs.tf b/modules/sdcore-control-plane-k8s/outputs.tf index ffa774f..3e52882 100644 --- a/modules/sdcore-control-plane-k8s/outputs.tf +++ b/modules/sdcore-control-plane-k8s/outputs.tf @@ -16,11 +16,11 @@ output "nms_app_name" { } output "fiveg_n4_endpoint" { description = "Name of the endpoint to integrate with fiveg_n4 interface." - value = module.nms.fiveg_n4_endpoint + value = module.nms.requires.fiveg_n4 } output "fiveg_gnb_identity_endpoint" { description = "Name of the endpoint to integrate with fiveg_gnb_identity interface." - value = module.nms.fiveg_gnb_identity_endpoint + value = module.nms.requires.fiveg_gnb_identity } output "grafana_agent_app_name" { diff --git a/modules/sdcore-control-plane-k8s/variables.tf b/modules/sdcore-control-plane-k8s/variables.tf index 021bb7b..445c3a9 100644 --- a/modules/sdcore-control-plane-k8s/variables.tf +++ b/modules/sdcore-control-plane-k8s/variables.tf @@ -1,16 +1,9 @@ # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. -variable "model_name" { - description = "Name of Juju model to deploy application to." +variable "model" { + description = "Reference to the Juju model to deploy application to." type = string - default = "" -} - -variable "create_model" { - description = "Allows to skip Juju model creation and re-use a model created in a higher level module." - type = bool - default = true } variable "sdcore_channel" {