From a4f76e46b29f7dd7d8f06d8d7ff41d5abff24bc9 Mon Sep 17 00:00:00 2001 From: "Jan-Yaeger Dhillon (charmkeeper)" Date: Fri, 24 Apr 2026 15:49:36 -0600 Subject: [PATCH 1/2] chore(terraform): update terraform modules to latest standards - Update required_version to ~> 1.12 and juju provider to ~> 1.0 - Add terraform/.tflint.hcl at the terraform root with required_version rule - Add renovate.json with charmhub custom datasource for automated revision tracking - Add tftest setup modules for charm and product modules - Fix copyright year typo in outputs.tf (2026 -> 2025) - Update README docs sections to reflect new version constraints Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- renovate.json | 79 +++++++++++++++++++ terraform/.tflint.hcl | 5 ++ terraform/charm/README.md | 2 +- terraform/charm/outputs.tf | 2 +- terraform/charm/tests/main.tftest.hcl | 21 +++++ terraform/charm/tests/setup/main.tf | 21 +++++ terraform/charm/versions.tf | 2 +- .../modules/landscape-scalable/README.md | 2 +- .../landscape-scalable/tests/main.tftest.hcl | 23 ++++++ .../landscape-scalable/tests/setup/main.tf | 21 +++++ .../modules/landscape-scalable/versions.tf | 2 +- 11 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 renovate.json create mode 100644 terraform/.tflint.hcl create mode 100644 terraform/charm/tests/main.tftest.hcl create mode 100644 terraform/charm/tests/setup/main.tf create mode 100644 terraform/product/modules/landscape-scalable/tests/main.tftest.hcl create mode 100644 terraform/product/modules/landscape-scalable/tests/setup/main.tf diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..d6ede418 --- /dev/null +++ b/renovate.json @@ -0,0 +1,79 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "automerge": true, + "customDatasources": { + "charmhub": { + "defaultRegistryUrlTemplate": "https://api.charmhub.io/v2/charms/info/{{packageName}}?fields=channel-map", + "format": "json", + "transformTemplates": [ + "{\"releases\": [{\"version\": $string($$.(`channel-map`[channel.risk = 'edge' and channel.track = 'latest' and channel.base.architecture = 'amd64' and channel.base.channel = '24.04'].revision.revision))}]}" + ] + } + }, + "customManagers": [ + { + "customType": "regex", + "datasourceTemplate": "docker", + "description": "Update base image references", + "managerFilePatterns": [ + "/(^|/)rockcraft.yaml$/" + ], + "matchStrings": [ + "# renovate: build-base:\\s+(?[^:]*):(?[^\\s@]*)(@(?sha256:[0-9a-f]*))?", + "# renovate: base:\\s+(?[^:]*):(?[^\\s@]*)(@(?sha256:[0-9a-f]*))?" + ], + "matchStringsStrategy": "any", + "versioningTemplate": "ubuntu" + }, + { + "customType": "regex", + "datasourceTemplate": "custom.charmhub", + "fileMatch": [ + "\\.tftest\\.hcl$", + "\\.tf$" + ], + "matchStrings": [ + "# renovate: depName=\"(?[^\"]+)\"\\s*\\n\\s*(?[a-zA-Z0-9_]+)\\s*=\\s*(?\\d+)" + ], + "versioningTemplate": "semver-coerced" + } + ], + "extends": [ + "config:recommended", + "group:allNonMajor" + ], + "ignorePaths": [], + "packageRules": [ + { + "enabled": true, + "matchDatasources": [ + "docker" + ], + "pinDigests": true + }, + { + "automerge": true, + "enabled": true, + "matchDatasources": [ + "custom.charmhub" + ] + }, + { + "enabled": false, + "matchFileNames": [ + "rockcraft.yaml" + ], + "matchUpdateTypes": [ + "major", + "minor", + "patch" + ] + } + ], + "schedule": [ + "* * * * 0,6" + ], + "vulnerabilityAlerts": { + "enabled": true + } +} diff --git a/terraform/.tflint.hcl b/terraform/.tflint.hcl new file mode 100644 index 00000000..ee21740d --- /dev/null +++ b/terraform/.tflint.hcl @@ -0,0 +1,5 @@ +# © 2025 Canonical Ltd. + +rule "terraform_required_version" { + enabled = true +} diff --git a/terraform/charm/README.md b/terraform/charm/README.md index 2f34b2ce..624e9cb0 100644 --- a/terraform/charm/README.md +++ b/terraform/charm/README.md @@ -91,7 +91,7 @@ make fix-charm-module | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.10 | +| [terraform](#requirement\_terraform) | ~> 1.12 | | [juju](#requirement\_juju) | ~> 1.0 | ## Providers diff --git a/terraform/charm/outputs.tf b/terraform/charm/outputs.tf index 922065c6..a38173ea 100644 --- a/terraform/charm/outputs.tf +++ b/terraform/charm/outputs.tf @@ -1,4 +1,4 @@ -# © 2026 Canonical Ltd. +# © 2025 Canonical Ltd. # The following outputs are meant to conform with Canonical's standards for # charm modules in a Terraform ecosystem (CC008). diff --git a/terraform/charm/tests/main.tftest.hcl b/terraform/charm/tests/main.tftest.hcl new file mode 100644 index 00000000..0bdffb1c --- /dev/null +++ b/terraform/charm/tests/main.tftest.hcl @@ -0,0 +1,21 @@ +# © 2025 Canonical Ltd. + +run "setup_tests" { + module { + source = "./tests/setup" + } +} + +run "basic_deploy" { + variables { + model_uuid = run.setup_tests.model_uuid + channel = "latest/edge" + # renovate: depName="landscape-server" + revision = 143 + } + + assert { + condition = output.app_name == "landscape-server" + error_message = "landscape-server app_name did not match expected" + } +} diff --git a/terraform/charm/tests/setup/main.tf b/terraform/charm/tests/setup/main.tf new file mode 100644 index 00000000..56abf817 --- /dev/null +++ b/terraform/charm/tests/setup/main.tf @@ -0,0 +1,21 @@ +# © 2025 Canonical Ltd. + +terraform { + required_version = "~> 1.12" + required_providers { + juju = { + version = "~> 1.0" + source = "juju/juju" + } + } +} + +provider "juju" {} + +resource "juju_model" "test_model" { + name = "tf-testing-${formatdate("YYYYMMDDhhmmss", timestamp())}" +} + +output "model_uuid" { + value = juju_model.test_model.uuid +} diff --git a/terraform/charm/versions.tf b/terraform/charm/versions.tf index 72e33ceb..fbf26ab1 100644 --- a/terraform/charm/versions.tf +++ b/terraform/charm/versions.tf @@ -1,7 +1,7 @@ # © 2025 Canonical Ltd. terraform { - required_version = ">= 1.10" + required_version = "~> 1.12" required_providers { juju = { source = "juju/juju" diff --git a/terraform/product/modules/landscape-scalable/README.md b/terraform/product/modules/landscape-scalable/README.md index 33a8a6c0..a8eb7748 100644 --- a/terraform/product/modules/landscape-scalable/README.md +++ b/terraform/product/modules/landscape-scalable/README.md @@ -58,7 +58,7 @@ This module uses the [Landscape Server charm module](https://github.com/canonica | Name | Version | | ------------------------------------------------------------------------- | ------- | -| [terraform](#requirement\_terraform) | >= 1.10 | +| [terraform](#requirement\_terraform) | ~> 1.12 | | [juju](#requirement\_juju) | ~> 1.0 | ## Providers diff --git a/terraform/product/modules/landscape-scalable/tests/main.tftest.hcl b/terraform/product/modules/landscape-scalable/tests/main.tftest.hcl new file mode 100644 index 00000000..98758345 --- /dev/null +++ b/terraform/product/modules/landscape-scalable/tests/main.tftest.hcl @@ -0,0 +1,23 @@ +# © 2025 Canonical Ltd. + +run "setup_tests" { + module { + source = "./tests/setup" + } +} + +run "basic_deploy" { + variables { + model_uuid = run.setup_tests.model_uuid + landscape_server = { + channel = "latest/edge" + # renovate: depName="landscape-server" + revision = 143 + } + } + + assert { + condition = output.applications.landscape_server.app_name == "landscape-server" + error_message = "landscape-server app_name did not match expected" + } +} diff --git a/terraform/product/modules/landscape-scalable/tests/setup/main.tf b/terraform/product/modules/landscape-scalable/tests/setup/main.tf new file mode 100644 index 00000000..56abf817 --- /dev/null +++ b/terraform/product/modules/landscape-scalable/tests/setup/main.tf @@ -0,0 +1,21 @@ +# © 2025 Canonical Ltd. + +terraform { + required_version = "~> 1.12" + required_providers { + juju = { + version = "~> 1.0" + source = "juju/juju" + } + } +} + +provider "juju" {} + +resource "juju_model" "test_model" { + name = "tf-testing-${formatdate("YYYYMMDDhhmmss", timestamp())}" +} + +output "model_uuid" { + value = juju_model.test_model.uuid +} diff --git a/terraform/product/modules/landscape-scalable/versions.tf b/terraform/product/modules/landscape-scalable/versions.tf index 72e33ceb..fbf26ab1 100644 --- a/terraform/product/modules/landscape-scalable/versions.tf +++ b/terraform/product/modules/landscape-scalable/versions.tf @@ -1,7 +1,7 @@ # © 2025 Canonical Ltd. terraform { - required_version = ">= 1.10" + required_version = "~> 1.12" required_providers { juju = { source = "juju/juju" From 22819f592beaa70820300793a5db9fc6b583d967 Mon Sep 17 00:00:00 2001 From: "Jan-Yaeger Dhillon (charmkeeper)" Date: Fri, 24 Apr 2026 16:39:17 -0600 Subject: [PATCH 2/2] fix(terraform): revert copyright year, add workflow, fix CI terraform version - Revert outputs.tf copyright year to 2026 (was wrongly changed to 2025) - Add missing .github/workflows/test_terraform_modules.yaml (requires workflow PAT scope) - Update CI to use terraform ~1.12 to match required_version in modules Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/lint.yaml | 2 +- .github/workflows/test_terraform_modules.yaml | 18 ++++++++++++++++++ .github/workflows/unit-test.yaml | 2 +- terraform/charm/outputs.tf | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test_terraform_modules.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5ea9d19b..676ccf40 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v5 - uses: hashicorp/setup-terraform@v3 with: - terraform_version: "~1.10" + terraform_version: "~1.12" - uses: terraform-linters/setup-tflint@v4 - run: make terraform-check-all diff --git a/.github/workflows/test_terraform_modules.yaml b/.github/workflows/test_terraform_modules.yaml new file mode 100644 index 00000000..b615fd2b --- /dev/null +++ b/.github/workflows/test_terraform_modules.yaml @@ -0,0 +1,18 @@ +# Copyright 2025 Canonical Ltd. +# See LICENSE file for licensing details. + +name: Terraform modules tests + +on: + workflow_dispatch: + pull_request: + paths: + - 'terraform/**' + +jobs: + terraform-tests: + uses: canonical/operator-workflows/.github/workflows/terraform_modules_test.yaml@main + secrets: inherit + with: + lxd-controller: true + terraform-directories: '["terraform/charm", "terraform/product/modules/landscape-scalable"]' diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 8c1f64df..e7cb13e8 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -42,7 +42,7 @@ jobs: - uses: hashicorp/setup-terraform@v3 with: - terraform_version: "~1.10" + terraform_version: "~1.12" - name: Run terraform tests run: make terraform-test-all diff --git a/terraform/charm/outputs.tf b/terraform/charm/outputs.tf index a38173ea..922065c6 100644 --- a/terraform/charm/outputs.tf +++ b/terraform/charm/outputs.tf @@ -1,4 +1,4 @@ -# © 2025 Canonical Ltd. +# © 2026 Canonical Ltd. # The following outputs are meant to conform with Canonical's standards for # charm modules in a Terraform ecosystem (CC008).