Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add terraform module #198

Merged
merged 21 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
18 changes: 17 additions & 1 deletion .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
lib-check:
name: Check libraries
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@main
uses: canonical/charmed-kubeflow-workflows/.github/workflows/_quality-checks.yaml@orfeas-k-update-linting
secrets: inherit
with:
charm-path: ./charms/argo-controller
Expand All @@ -24,8 +24,24 @@ jobs:
- run: |
sudo apt update
sudo apt install tox
- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
- run: tox -vve argo-controller-lint

terraform-check:
name: Check Terraform
uses: canonical/sdcore-github-workflows/.github/workflows/terraform.yaml@v1.0.0
with:
working-directory: charms/argo-controller/terraform

terraform-deploy:
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
name: Deploy Terraform
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-deploy.yaml@orfeas-k-add-terraform-reusable-workflow
with:
model: kubeflow
channel: latest/edge
working-directory: charms/argo-controller/terraform

unit:
name: Unit Tests
runs-on: ubuntu-20.04
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ __pycache__
operators/argo-controller/build
.tox
.idea
venv/
.terraform*
*.tfstate*
3 changes: 3 additions & 0 deletions charms/argo-controller/terraform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Terraform module for argo-controller

This is a Terraform module facilitating the deployment of argo-controller charm, using the [Terraform juju provider](https://registry.terraform.io/providers/juju/juju/latest/docs).
13 changes: 13 additions & 0 deletions charms/argo-controller/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "juju_application" "argo_controller" {
name = var.app_name
model = var.model_name
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
trust = true
resources = var.resources
charm {
name = "argo-controller"
channel = var.channel
revision = var.revision
}
units = 1
config = var.config
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
}
17 changes: 17 additions & 0 deletions charms/argo-controller/terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
output "app_name" {
value = juju_application.argo_controller.name
}

output "provides" {
value = {
metrics_endpoint = "metrics-endpoint",
grafana_dashboard = "grafana-dashboard"
}
}

output "requires" {
value = {
object_storage = "object-storage",
logging = "logging"
}
}
34 changes: 34 additions & 0 deletions charms/argo-controller/terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
variable "app_name" {
description = "Application name"
type = string
default = "argo-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 revisions"
type = map(number)
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
default = null
}

variable "revision" {
description = "Charm revision"
type = number
default = null
}
9 changes: 9 additions & 0 deletions charms/argo-controller/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.5"
required_providers {
juju = {
source = "juju/juju"
version = "~> 0.13.0"
}
}
}
3 changes: 3 additions & 0 deletions charms/argo-controller/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ deps =
description = Apply coding style standards to code

[testenv:lint]
allowlist_externals =
tflint
commands =
# uncomment the following line if this charm owns a lib
# codespell {[vars]lib_path}
Expand All @@ -60,6 +62,7 @@ commands =
pflake8 {[vars]all_path}
isort --check-only --diff {[vars]all_path}
black --check --diff {[vars]all_path}
tflint --chdir=terraform --recursive
deps =
-r requirements-lint.txt
description = Check code against coding style standards
Expand Down
Loading