From 0b065ef5b9c058f7162918bb7bba7c6f71511a33 Mon Sep 17 00:00:00 2001 From: Manos Vlassis <57320708+mvlassis@users.noreply.github.com> Date: Thu, 26 Sep 2024 15:48:58 +0300 Subject: [PATCH] Feat: Add Terraform module (#572) * Add Terraform module * Update Github action * Update Terraform modules with correct names * Update README.md * Remove channel from terraform action * Update default Terraform channel * Update default Terraform channel * Add note about the model name in the tests --- .github/workflows/integrate.yaml | 21 +++++++ .gitignore | 2 + charms/kfp-api/terraform/README.md | 60 +++++++++++++++++++ charms/kfp-api/terraform/main.tf | 13 ++++ charms/kfp-api/terraform/outputs.tf | 21 +++++++ charms/kfp-api/terraform/variables.tf | 34 +++++++++++ charms/kfp-api/terraform/versions.tf | 9 +++ charms/kfp-api/tox.ini | 7 +++ .../kfp-metadata-writer/terraform/README.md | 57 ++++++++++++++++++ charms/kfp-metadata-writer/terraform/main.tf | 13 ++++ .../kfp-metadata-writer/terraform/outputs.tf | 14 +++++ .../terraform/variables.tf | 34 +++++++++++ .../kfp-metadata-writer/terraform/versions.tf | 9 +++ charms/kfp-metadata-writer/tox.ini | 7 +++ charms/kfp-persistence/terraform/README.md | 57 ++++++++++++++++++ charms/kfp-persistence/terraform/main.tf | 13 ++++ charms/kfp-persistence/terraform/outputs.tf | 14 +++++ charms/kfp-persistence/terraform/variables.tf | 34 +++++++++++ charms/kfp-persistence/terraform/versions.tf | 9 +++ charms/kfp-persistence/tox.ini | 7 +++ .../terraform/README.md | 57 ++++++++++++++++++ .../kfp-profile-controller/terraform/main.tf | 13 ++++ .../terraform/outputs.tf | 14 +++++ .../terraform/variables.tf | 34 +++++++++++ .../terraform/versions.tf | 9 +++ charms/kfp-profile-controller/tox.ini | 7 +++ charms/kfp-schedwf/terraform/README.md | 57 ++++++++++++++++++ charms/kfp-schedwf/terraform/main.tf | 13 ++++ charms/kfp-schedwf/terraform/outputs.tf | 13 ++++ charms/kfp-schedwf/terraform/variables.tf | 34 +++++++++++ charms/kfp-schedwf/terraform/versions.tf | 9 +++ charms/kfp-schedwf/tox.ini | 7 +++ charms/kfp-ui/terraform/README.md | 57 ++++++++++++++++++ charms/kfp-ui/terraform/main.tf | 13 ++++ charms/kfp-ui/terraform/outputs.tf | 19 ++++++ charms/kfp-ui/terraform/variables.tf | 34 +++++++++++ charms/kfp-ui/terraform/versions.tf | 9 +++ charms/kfp-ui/tox.ini | 7 +++ charms/kfp-viewer/terraform/README.md | 57 ++++++++++++++++++ charms/kfp-viewer/terraform/main.tf | 13 ++++ charms/kfp-viewer/terraform/outputs.tf | 13 ++++ charms/kfp-viewer/terraform/variables.tf | 34 +++++++++++ charms/kfp-viewer/terraform/versions.tf | 9 +++ charms/kfp-viewer/tox.ini | 7 +++ charms/kfp-viz/terraform/README.md | 57 ++++++++++++++++++ charms/kfp-viz/terraform/main.tf | 13 ++++ charms/kfp-viz/terraform/outputs.tf | 15 +++++ charms/kfp-viz/terraform/variables.tf | 34 +++++++++++ charms/kfp-viz/terraform/versions.tf | 9 +++ charms/kfp-viz/tox.ini | 7 +++ 50 files changed, 1109 insertions(+) create mode 100644 charms/kfp-api/terraform/README.md create mode 100644 charms/kfp-api/terraform/main.tf create mode 100644 charms/kfp-api/terraform/outputs.tf create mode 100644 charms/kfp-api/terraform/variables.tf create mode 100644 charms/kfp-api/terraform/versions.tf create mode 100644 charms/kfp-metadata-writer/terraform/README.md create mode 100644 charms/kfp-metadata-writer/terraform/main.tf create mode 100644 charms/kfp-metadata-writer/terraform/outputs.tf create mode 100644 charms/kfp-metadata-writer/terraform/variables.tf create mode 100644 charms/kfp-metadata-writer/terraform/versions.tf create mode 100644 charms/kfp-persistence/terraform/README.md create mode 100644 charms/kfp-persistence/terraform/main.tf create mode 100644 charms/kfp-persistence/terraform/outputs.tf create mode 100644 charms/kfp-persistence/terraform/variables.tf create mode 100644 charms/kfp-persistence/terraform/versions.tf create mode 100644 charms/kfp-profile-controller/terraform/README.md create mode 100644 charms/kfp-profile-controller/terraform/main.tf create mode 100644 charms/kfp-profile-controller/terraform/outputs.tf create mode 100644 charms/kfp-profile-controller/terraform/variables.tf create mode 100644 charms/kfp-profile-controller/terraform/versions.tf create mode 100644 charms/kfp-schedwf/terraform/README.md create mode 100644 charms/kfp-schedwf/terraform/main.tf create mode 100644 charms/kfp-schedwf/terraform/outputs.tf create mode 100644 charms/kfp-schedwf/terraform/variables.tf create mode 100644 charms/kfp-schedwf/terraform/versions.tf create mode 100644 charms/kfp-ui/terraform/README.md create mode 100644 charms/kfp-ui/terraform/main.tf create mode 100644 charms/kfp-ui/terraform/outputs.tf create mode 100644 charms/kfp-ui/terraform/variables.tf create mode 100644 charms/kfp-ui/terraform/versions.tf create mode 100644 charms/kfp-viewer/terraform/README.md create mode 100644 charms/kfp-viewer/terraform/main.tf create mode 100644 charms/kfp-viewer/terraform/outputs.tf create mode 100644 charms/kfp-viewer/terraform/variables.tf create mode 100644 charms/kfp-viewer/terraform/versions.tf create mode 100644 charms/kfp-viz/terraform/README.md create mode 100644 charms/kfp-viz/terraform/main.tf create mode 100644 charms/kfp-viz/terraform/outputs.tf create mode 100644 charms/kfp-viz/terraform/variables.tf create mode 100644 charms/kfp-viz/terraform/versions.tf diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index f310f101..431e5213 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -66,6 +66,27 @@ jobs: - run: python3 -m pip install tox - run: tox -e ${{ matrix.charm }}-unit + terraform-checks: + name: Terraform + uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-checks.yaml@main + strategy: + matrix: + charm: + - kfp-api + - kfp-metadata-writer + - kfp-persistence + - kfp-profile-controller + - kfp-schedwf + - kfp-ui + - kfp-viewer + - kfp-viz + with: + charm-path: ./charms/${{ matrix.charm }} + # The namespace is hardcoded in the upstream project + # So the model's name must be kubeflow + # See: https://github.com/kubeflow/kubeflow/issues/6136 + model: kubeflow + integration: name: Integration tests (microk8s) runs-on: ubuntu-20.04 diff --git a/.gitignore b/.gitignore index fc37ceca..029f0198 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ __pycache__/ .idea .vscode venv +.terraform* +*.tfstate* diff --git a/charms/kfp-api/terraform/README.md b/charms/kfp-api/terraform/README.md new file mode 100644 index 00000000..a0f073d1 --- /dev/null +++ b/charms/kfp-api/terraform/README.md @@ -0,0 +1,60 @@ +# Terraform module for kfp-api + +This is a Terraform module facilitating the deployment of the kfp-api charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## Requirements +This module requires a `juju` model to be available. Refer to the [usage section](#usage) below for more details. + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-api" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-api" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-api/terraform/main.tf b/charms/kfp-api/terraform/main.tf new file mode 100644 index 00000000..4bc8b2ba --- /dev/null +++ b/charms/kfp-api/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_api" { + charm { + name = "kfp-api" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-api/terraform/outputs.tf b/charms/kfp-api/terraform/outputs.tf new file mode 100644 index 00000000..d7ffb6b5 --- /dev/null +++ b/charms/kfp-api/terraform/outputs.tf @@ -0,0 +1,21 @@ +output "app_name" { + value = juju_application.kfp_api.name +} + +output "provides" { + value = { + kfp_api = "kfp-api", + metrics_endpoint = "metrics-endpoint", + grafana_dashboard = "grafana-dashboard", + } +} + +output "requires" { + value = { + mysql = "mysql", + relational_db = "relational-db", + object_storage = "object-storage", + kfp_viz = "kfp-viz", + logging = "logging", + } +} diff --git a/charms/kfp-api/terraform/variables.tf b/charms/kfp-api/terraform/variables.tf new file mode 100644 index 00000000..c88a9c0f --- /dev/null +++ b/charms/kfp-api/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-api" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-api/terraform/versions.tf b/charms/kfp-api/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-api/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-api/tox.ini b/charms/kfp-api/tox.ini index da167271..f1c5b985 100644 --- a/charms/kfp-api/tox.ini +++ b/charms/kfp-api/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-metadata-writer/terraform/README.md b/charms/kfp-metadata-writer/terraform/README.md new file mode 100644 index 00000000..b9ef61d0 --- /dev/null +++ b/charms/kfp-metadata-writer/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-metadata-writer + +This is a Terraform module facilitating the deployment of the kfp-metadata-writer charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-metadata-writer" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-metadata-writer" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-metadata-writer/terraform/main.tf b/charms/kfp-metadata-writer/terraform/main.tf new file mode 100644 index 00000000..9063def1 --- /dev/null +++ b/charms/kfp-metadata-writer/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_metadata_writer" { + charm { + name = "kfp-metadata-writer" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-metadata-writer/terraform/outputs.tf b/charms/kfp-metadata-writer/terraform/outputs.tf new file mode 100644 index 00000000..cc48f56b --- /dev/null +++ b/charms/kfp-metadata-writer/terraform/outputs.tf @@ -0,0 +1,14 @@ +output "app_name" { + value = juju_application.kfp_metadata_writer.name +} + +output "provides" { + value = {} +} + +output "requires" { + value = { + grpc = "grpc", + logging = "logging" + } +} diff --git a/charms/kfp-metadata-writer/terraform/variables.tf b/charms/kfp-metadata-writer/terraform/variables.tf new file mode 100644 index 00000000..fa2e65a0 --- /dev/null +++ b/charms/kfp-metadata-writer/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-metadata-writer" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-metadata-writer/terraform/versions.tf b/charms/kfp-metadata-writer/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-metadata-writer/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-metadata-writer/tox.ini b/charms/kfp-metadata-writer/tox.ini index 81868cf0..d5781c81 100644 --- a/charms/kfp-metadata-writer/tox.ini +++ b/charms/kfp-metadata-writer/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-persistence/terraform/README.md b/charms/kfp-persistence/terraform/README.md new file mode 100644 index 00000000..d9e5a85a --- /dev/null +++ b/charms/kfp-persistence/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-persistence + +This is a Terraform module facilitating the deployment of the kfp-persistence charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-persistence" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-persistence" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-persistence/terraform/main.tf b/charms/kfp-persistence/terraform/main.tf new file mode 100644 index 00000000..2990154a --- /dev/null +++ b/charms/kfp-persistence/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_persistence" { + charm { + name = "kfp-persistence" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-persistence/terraform/outputs.tf b/charms/kfp-persistence/terraform/outputs.tf new file mode 100644 index 00000000..c33cf13e --- /dev/null +++ b/charms/kfp-persistence/terraform/outputs.tf @@ -0,0 +1,14 @@ +output "app_name" { + value = juju_application.kfp_persistence.name +} + +output "provides" { + value = {} +} + +output "requires" { + value = { + kfp_api = "kfp-api", + logging = "logging" + } +} diff --git a/charms/kfp-persistence/terraform/variables.tf b/charms/kfp-persistence/terraform/variables.tf new file mode 100644 index 00000000..a77d91ce --- /dev/null +++ b/charms/kfp-persistence/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-persistence" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-persistence/terraform/versions.tf b/charms/kfp-persistence/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-persistence/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-persistence/tox.ini b/charms/kfp-persistence/tox.ini index 0febc1cf..09b954eb 100644 --- a/charms/kfp-persistence/tox.ini +++ b/charms/kfp-persistence/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-profile-controller/terraform/README.md b/charms/kfp-profile-controller/terraform/README.md new file mode 100644 index 00000000..a9792673 --- /dev/null +++ b/charms/kfp-profile-controller/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-profile-controller + +This is a Terraform module facilitating the deployment of the kfp-profile-controller charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-profile-controller" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-profile-controller" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-profile-controller/terraform/main.tf b/charms/kfp-profile-controller/terraform/main.tf new file mode 100644 index 00000000..a09d9432 --- /dev/null +++ b/charms/kfp-profile-controller/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_profile_controller" { + charm { + name = "kfp-profile-controller" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-profile-controller/terraform/outputs.tf b/charms/kfp-profile-controller/terraform/outputs.tf new file mode 100644 index 00000000..67f60874 --- /dev/null +++ b/charms/kfp-profile-controller/terraform/outputs.tf @@ -0,0 +1,14 @@ +output "app_name" { + value = juju_application.kfp_profile_controller.name +} + +output "provides" { + value = {} +} + +output "requires" { + value = { + object_storage = "object-storage", + logging = "logging", + } +} diff --git a/charms/kfp-profile-controller/terraform/variables.tf b/charms/kfp-profile-controller/terraform/variables.tf new file mode 100644 index 00000000..b6cd0935 --- /dev/null +++ b/charms/kfp-profile-controller/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-profile-controller" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-profile-controller/terraform/versions.tf b/charms/kfp-profile-controller/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-profile-controller/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-profile-controller/tox.ini b/charms/kfp-profile-controller/tox.ini index 0febc1cf..09b954eb 100644 --- a/charms/kfp-profile-controller/tox.ini +++ b/charms/kfp-profile-controller/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-schedwf/terraform/README.md b/charms/kfp-schedwf/terraform/README.md new file mode 100644 index 00000000..b76ad7e4 --- /dev/null +++ b/charms/kfp-schedwf/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-schedwf + +This is a Terraform module facilitating the deployment of the kfp-schedwf charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-schedwf" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-schedwf" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-schedwf/terraform/main.tf b/charms/kfp-schedwf/terraform/main.tf new file mode 100644 index 00000000..eb37fd38 --- /dev/null +++ b/charms/kfp-schedwf/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_schedwf" { + charm { + name = "kfp-schedwf" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-schedwf/terraform/outputs.tf b/charms/kfp-schedwf/terraform/outputs.tf new file mode 100644 index 00000000..e3641e4d --- /dev/null +++ b/charms/kfp-schedwf/terraform/outputs.tf @@ -0,0 +1,13 @@ +output "app_name" { + value = juju_application.kfp_schedwf.name +} + +output "provides" { + value = {} +} + +output "requires" { + value = { + logging = "logging" + } +} diff --git a/charms/kfp-schedwf/terraform/variables.tf b/charms/kfp-schedwf/terraform/variables.tf new file mode 100644 index 00000000..0670b020 --- /dev/null +++ b/charms/kfp-schedwf/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-schedwf" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-schedwf/terraform/versions.tf b/charms/kfp-schedwf/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-schedwf/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-schedwf/tox.ini b/charms/kfp-schedwf/tox.ini index 0febc1cf..09b954eb 100644 --- a/charms/kfp-schedwf/tox.ini +++ b/charms/kfp-schedwf/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-ui/terraform/README.md b/charms/kfp-ui/terraform/README.md new file mode 100644 index 00000000..c2e8a621 --- /dev/null +++ b/charms/kfp-ui/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-ui + +This is a Terraform module facilitating the deployment of the kfp-ui charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-ui" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-ui" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-ui/terraform/main.tf b/charms/kfp-ui/terraform/main.tf new file mode 100644 index 00000000..38ac4b3a --- /dev/null +++ b/charms/kfp-ui/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_ui" { + charm { + name = "kfp-ui" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-ui/terraform/outputs.tf b/charms/kfp-ui/terraform/outputs.tf new file mode 100644 index 00000000..31180b81 --- /dev/null +++ b/charms/kfp-ui/terraform/outputs.tf @@ -0,0 +1,19 @@ +output "app_name" { + value = juju_application.kfp_ui.name +} + +output "provides" { + value = { + kfp_ui = "kfp-ui" + } +} + +output "requires" { + value = { + object_storage = "object-storage", + kfp_api = "kfp-api", + ingress = "ingress", + dashboard_links = "dashboard-links", + logging = "logging" + } +} diff --git a/charms/kfp-ui/terraform/variables.tf b/charms/kfp-ui/terraform/variables.tf new file mode 100644 index 00000000..d0a82e5b --- /dev/null +++ b/charms/kfp-ui/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-ui" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-ui/terraform/versions.tf b/charms/kfp-ui/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-ui/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-ui/tox.ini b/charms/kfp-ui/tox.ini index 764f8028..5a486fa2 100644 --- a/charms/kfp-ui/tox.ini +++ b/charms/kfp-ui/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-viewer/terraform/README.md b/charms/kfp-viewer/terraform/README.md new file mode 100644 index 00000000..e2dafb29 --- /dev/null +++ b/charms/kfp-viewer/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-viewer + +This is a Terraform module facilitating the deployment of the kfp-viewer charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-viewer" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-viewer" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-viewer/terraform/main.tf b/charms/kfp-viewer/terraform/main.tf new file mode 100644 index 00000000..2a6a8873 --- /dev/null +++ b/charms/kfp-viewer/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_viewer" { + charm { + name = "kfp-viewer" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-viewer/terraform/outputs.tf b/charms/kfp-viewer/terraform/outputs.tf new file mode 100644 index 00000000..3e9078f4 --- /dev/null +++ b/charms/kfp-viewer/terraform/outputs.tf @@ -0,0 +1,13 @@ +output "app_name" { + value = juju_application.kfp_viewer.name +} + +output "provides" { + value = {} +} + +output "requires" { + value = { + logging = "logging" + } +} diff --git a/charms/kfp-viewer/terraform/variables.tf b/charms/kfp-viewer/terraform/variables.tf new file mode 100644 index 00000000..f4630fc7 --- /dev/null +++ b/charms/kfp-viewer/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-viewer" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-viewer/terraform/versions.tf b/charms/kfp-viewer/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-viewer/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-viewer/tox.ini b/charms/kfp-viewer/tox.ini index d1c301e4..63a274ad 100644 --- a/charms/kfp-viewer/tox.ini +++ b/charms/kfp-viewer/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \ diff --git a/charms/kfp-viz/terraform/README.md b/charms/kfp-viz/terraform/README.md new file mode 100644 index 00000000..09aabd7e --- /dev/null +++ b/charms/kfp-viz/terraform/README.md @@ -0,0 +1,57 @@ +# Terraform module for kfp-viz + +This is a Terraform module facilitating the deployment of the kfp-viz charm, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs). + +## API + +### Inputs +The module offers the following configurable inputs: + +| Name | Type | Description | Required | +| - | - | - | - | +| `app_name`| string | Application name | False | +| `channel`| string | Channel that the charm is deployed from | False | +| `config`| map(string) | Map of the charm configuration options | False | +| `model_name`| string | Name of the model that the charm is deployed on | True | +| `resources`| map(string) | Map of the charm resources | False | +| `revision`| number | Revision number of the charm name | False | + +### Outputs +Upon applied, the module exports the following outputs: + +| Name | Description | +| - | - | +| `app_name`| Application name | +| `provides`| Map of `provides` endpoints | +| `requires`| Map of `reqruires` endpoints | + +## Usage + +This module is intended to be used as part of a higher-level module. When defining one, users should ensure that Terraform is aware of the `juju_model` dependency of the charm module. There are two options to do so when creating a high-level module: + +### Define a `juju_model` resource +Define a `juju_model` resource and pass to the `model_name` input a reference to the `juju_model` resource's name. For example: + +``` +resource "juju_model" "testing" { + name = kubeflow +} + +module "kfp-viz" { + source = "" + model_name = juju_model.testing.name +} +``` + +### Define a `data` source +Define a `data` source and pass to the `model_name` input a reference to the `data.juju_model` resource's name. This will enable Terraform to look for a `juju_model` resource with a name attribute equal to the one provided, and apply only if this is present. Otherwise, it will fail before applying anything. +``` +data "juju_model" "testing" { + name = var.model_name +} + +module "kfp-viz" { + source = "" + model_name = data.juju_model.testing.name +} +``` diff --git a/charms/kfp-viz/terraform/main.tf b/charms/kfp-viz/terraform/main.tf new file mode 100644 index 00000000..eb35f2d8 --- /dev/null +++ b/charms/kfp-viz/terraform/main.tf @@ -0,0 +1,13 @@ +resource "juju_application" "kfp_viz" { + charm { + name = "kfp-viz" + channel = var.channel + revision = var.revision + } + config = var.config + model = var.model_name + name = var.app_name + resources = var.resources + trust = true + units = 1 +} diff --git a/charms/kfp-viz/terraform/outputs.tf b/charms/kfp-viz/terraform/outputs.tf new file mode 100644 index 00000000..0033390f --- /dev/null +++ b/charms/kfp-viz/terraform/outputs.tf @@ -0,0 +1,15 @@ +output "app_name" { + value = juju_application.kfp_viz.name +} + +output "provides" { + value = { + kfp_viz = "kfp-viz" + } +} + +output "requires" { + value = { + logging = "logging" + } +} diff --git a/charms/kfp-viz/terraform/variables.tf b/charms/kfp-viz/terraform/variables.tf new file mode 100644 index 00000000..2ba80e0b --- /dev/null +++ b/charms/kfp-viz/terraform/variables.tf @@ -0,0 +1,34 @@ +variable "app_name" { + description = "Application name" + type = string + default = "kfp-viz" +} + +variable "channel" { + description = "Charm channel" + type = string + default = null +} + +variable "config" { + description = "Map of charm configuration options" + type = map(string) + default = {} +} + +variable "model_name" { + description = "Model name" + type = string +} + +variable "resources" { + description = "Map of resources" + type = map(string) + default = null +} + +variable "revision" { + description = "Charm revision" + type = number + default = null +} diff --git a/charms/kfp-viz/terraform/versions.tf b/charms/kfp-viz/terraform/versions.tf new file mode 100644 index 00000000..eb357ca6 --- /dev/null +++ b/charms/kfp-viz/terraform/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.6" + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + } +} diff --git a/charms/kfp-viz/tox.ini b/charms/kfp-viz/tox.ini index 0febc1cf..09b954eb 100644 --- a/charms/kfp-viz/tox.ini +++ b/charms/kfp-viz/tox.ini @@ -64,6 +64,13 @@ deps = -r requirements-lint.txt description = Check code against coding style standards +[testenv:tflint] +allowlist_externals = + tflint +commands = + tflint --chdir=terraform --recursive +description = Check Terraform code against coding style standards + [testenv:unit] commands = coverage run --source={[vars]src_path} \