From 8239429851ae0f5ba66fe06a776ef06dd8dff74c Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Mon, 6 Oct 2025 17:22:43 +0700 Subject: [PATCH 01/22] add terraform --- terraform/README.md | 27 +++++++++++++-------------- terraform/main.tf | 24 ++++++++++-------------- terraform/outputs.tf | 4 ++-- terraform/variables.tf | 36 +++++++++--------------------------- 4 files changed, 34 insertions(+), 57 deletions(-) diff --git a/terraform/README.md b/terraform/README.md index f8cd491..217b6fc 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -1,7 +1,6 @@ - -# Terraform module +# Aproxy terraform module -This folder contains a base [Terraform][Terraform] module for the charm. +This folder contains a base [Terraform][Terraform] module for the aproxy charm. The module uses the [Terraform Juju provider][Terraform Juju provider] to model the charm deployment onto any Kubernetes environment managed by [Juju][Juju]. @@ -16,9 +15,9 @@ deployment onto any Kubernetes environment managed by [Juju][Juju]. the Juju application name. - **versions.tf** - Defines the Terraform provider version. -## Using base module in higher level modules +## Using aproxy base module in higher level modules -If you want to use `` base module as part of your Terraform module, import it +If you want to use `aproxy` base module as part of your Terraform module, import it like shown below: ```text @@ -26,8 +25,8 @@ data "juju_model" "my_model" { name = var.model } -module "" { - source = "git::https://github.com/canonical/-operator//terraform" +module "aproxy" { + source = "git::https://github.com/canonical/aproxy-operator//terraform" model = juju_model.my_model.name # (Customize configuration variables here if needed) @@ -37,22 +36,22 @@ module "" { Create integrations, for instance: ```text -resource "juju_integration" "-loki" { +resource "juju_integration" "aproxy_to_principal" { model = juju_model.my_model.name application { - name = module..app_name - endpoint = module..endpoints.logging + name = module.aproxy.app_name + endpoint = module.aproxy.endpoints.juju_info } application { - name = "loki-k8s" - endpoint = "logging" + name = "principal-app" + endpoint = "juju-info" } } ``` -The complete list of available integrations can be found [in the Integrations tab][-integrations]. +The complete list of available integrations can be found [in the Integrations tab][aproxy-integrations]. [Terraform]: https://www.terraform.io/ [Terraform Juju provider]: https://registry.terraform.io/providers/juju/juju/latest [Juju]: https://juju.is -[-integrations]: https://charmhub.io//integrations +[aproxy-integrations]: https://charmhub.io/aproxy/integrations diff --git a/terraform/main.tf b/terraform/main.tf index a18faef..66e8752 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,19 +1,15 @@ # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. -resource "juju_application" "charm_name" { - name = var.app_name - model = var.model +resource "juju_application" "aproxy" { + name = var.app_name + charm = var.charm_name + channel = var.channel + model = var.model + series = var.series + base = var.base + is_subordinate = true - charm { - name = "" - channel = var.channel - revision = var.revision - base = var.base - } - - config = var.config - constraints = var.constraints - units = var.units - storage_directives = var.storage + config = var.config + units = 0 } diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 07d3bd4..d995d82 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -3,11 +3,11 @@ output "app_name" { description = "Name of the deployed application." - value = juju_application.charm_name.name + value = juju_application.aproxy.name } output "endpoints" { value = { - ingress = "ingress" + juju_info = "juju-info" } } diff --git a/terraform/variables.tf b/terraform/variables.tf index c4f2b56..e0591ef 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -2,9 +2,15 @@ # See LICENSE file for licensing details. variable "app_name" { - description = "Name of the application in the Juju model." + description = "Application name for aproxy." type = string - default = "" + default = "aproxy" +} + +variable "charm_name" { + description = "Charmhub charm name for aproxy." + type = string + default = "aproxy" } variable "base" { @@ -25,31 +31,7 @@ variable "config" { default = {} } -variable "constraints" { - description = "Juju constraints to apply for this application." - type = string - default = "" -} - variable "model" { description = "Reference to a `juju_model`." type = string -} - -variable "revision" { - description = "Revision number of the charm" - type = number - default = null -} - -variable "storage" { - description = "Map of storage used by the application." - type = map(string) - default = {} -} - -variable "units" { - description = "Number of units to deploy" - type = number - default = 1 -} +} \ No newline at end of file From e5e959e257a47609d5eccae3ab771ed461ea8d35 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Mon, 6 Oct 2025 19:48:06 +0700 Subject: [PATCH 02/22] fix terraform config --- terraform/main.tf | 3 +-- terraform/variables.tf | 8 +++++++- terraform/versions.tf | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 66e8752..a196183 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -6,9 +6,8 @@ resource "juju_application" "aproxy" { charm = var.charm_name channel = var.channel model = var.model - series = var.series base = var.base - is_subordinate = true + revision = var.revision config = var.config units = 0 diff --git a/terraform/variables.tf b/terraform/variables.tf index e0591ef..00ff76e 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -26,7 +26,7 @@ variable "channel" { } variable "config" { - description = "Application config. Details about available options can be found at https://charmhub.io//configurations." + description = "Application config. Details about available options can be found at https://charmhub.io/aproxy/configurations." type = map(string) default = {} } @@ -34,4 +34,10 @@ variable "config" { variable "model" { description = "Reference to a `juju_model`." type = string +} + +variable "revision" { + description = "Revision number of the charm" + type = number + default = null } \ No newline at end of file diff --git a/terraform/versions.tf b/terraform/versions.tf index b09dca2..90fb459 100644 --- a/terraform/versions.tf +++ b/terraform/versions.tf @@ -5,7 +5,7 @@ terraform { required_providers { juju = { source = "juju/juju" - version = ">= 0.20.0" + version = ">= 0.23.0" } } } From 54682c0f4735efc963f3055e0bc2aa2f003a15ab Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 16:48:36 +0700 Subject: [PATCH 03/22] fix formatting --- terraform/main.tf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index a196183..a3ad027 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -2,13 +2,13 @@ # See LICENSE file for licensing details. resource "juju_application" "aproxy" { - name = var.app_name - charm = var.charm_name - channel = var.channel - model = var.model - base = var.base - revision = var.revision + name = var.app_name + charm = var.charm_name + channel = var.channel + model = var.model + base = var.base + revision = var.revision - config = var.config - units = 0 + config = var.config + units = 0 } From 0427a742d1b3d5c05eac63c6a557fa13fdff04fa Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 16:58:12 +0700 Subject: [PATCH 04/22] update test --- terraform/tests/main.tf | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/terraform/tests/main.tf b/terraform/tests/main.tf index 3dba012..4e0ebab 100644 --- a/terraform/tests/main.tf +++ b/terraform/tests/main.tf @@ -13,10 +13,16 @@ variable "revision" { default = null } +variable "model" { + description = "The Juju model name to use for the test deployment." + type = string + default = "test-aproxy-model" +} + terraform { required_providers { juju = { - version = "~> 0.20.0" + version = "~> 0.23.0" source = "juju/juju" } } @@ -24,10 +30,23 @@ terraform { provider "juju" {} -module "charm_name" { +module "aproxy" { source = "./.." - app_name = "charm_name" + app_name = "aproxy" channel = var.channel - model = "prod-charm_name-example" revision = var.revision + model = "prod-aproxy-example" + config = { + proxy-address = "127.0.0.1:80" + } } + +output "app_name" { + description = "The name of the deployed aproxy charm application." + value = module.aproxy.app_name +} + +output "endpoints" { + description = "Integration endpoints exposed by aproxy charm." + value = module.aproxy.endpoints +} \ No newline at end of file From 119cc68381940a15fcb5e56f2957a4abeceb02d0 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 16:58:48 +0700 Subject: [PATCH 05/22] update format --- terraform/tests/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/tests/main.tf b/terraform/tests/main.tf index 4e0ebab..eedf2c0 100644 --- a/terraform/tests/main.tf +++ b/terraform/tests/main.tf @@ -36,7 +36,7 @@ module "aproxy" { channel = var.channel revision = var.revision model = "prod-aproxy-example" - config = { + config = { proxy-address = "127.0.0.1:80" } } From 60a7199533dd5d9f3eeb457330fbae977fae5a2e Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 17:03:08 +0700 Subject: [PATCH 06/22] remove unused var --- terraform/tests/main.tf | 6 ------ 1 file changed, 6 deletions(-) diff --git a/terraform/tests/main.tf b/terraform/tests/main.tf index eedf2c0..918dc26 100644 --- a/terraform/tests/main.tf +++ b/terraform/tests/main.tf @@ -13,12 +13,6 @@ variable "revision" { default = null } -variable "model" { - description = "The Juju model name to use for the test deployment." - type = string - default = "test-aproxy-model" -} - terraform { required_providers { juju = { From 71ec35dd8a88c3eb291e91728aee8b6d94375cb5 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 17:28:29 +0700 Subject: [PATCH 07/22] update test --- .github/workflows/test_terraform_module.yaml | 82 ++++++++++---------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index 9d1b15f..bf7c8b4 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -1,58 +1,60 @@ # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. -# Attention: valid for K8s charms only - -name: Terraform module tests +name: Terraform module tests (machine-based) on: pull_request: paths: - - 'terraform/**' + - "terraform/**" permissions: contents: read jobs: test-terraform: - # remove this condition for enabling the workflow - if: false name: Test Terraform with Juju runs-on: ubuntu-latest env: - WORKING_DIR: 'terraform/tests' + WORKING_DIR: "terraform/tests" steps: - - uses: actions/checkout@@v4.2.2 - - uses: charmed-kubernetes/actions-operator@main - with: - provider: "k8s" - use-canonical-k8s: true - channel: 1.33-classic/stable - juju-channel: 3.6/stable - - name: Prepare juju tf provider environment - run: | - CONTROLLER=$(juju whoami | yq .Controller) - JUJU_CONTROLLER_ADDRESSES="$(juju show-controller | yq '.[$CONTROLLER]'.details.\"api-endpoints\" | tr -d "[]' "|tr -d '"'|tr -d '\n')" - JUJU_USERNAME="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.user|tr -d '"')" - JUJU_PASSWORD="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password|tr -d '"')" + - name: Check out code + uses: actions/checkout@@v4.2.2 + + - name: Setup Juju with LXD + uses: charmed-kubernetes/actions-operator@main + with: + provider: "lxd" + juju-channel: 3/stable + channel: "1.32-strict/stable" + + - name: Prepare juju tf provider environment + run: | + set -e + CONTROLLER=$(juju whoami | yq .Controller) + JUJU_CONTROLLER_ADDRESSES="$(juju show-controller | yq '.[$CONTROLLER]'.details.\"api-endpoints\" | tr -d "[]' "|tr -d '"'|tr -d '\n')" + JUJU_USERNAME="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.user|tr -d '"')" + JUJU_PASSWORD="$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password|tr -d '"')" - echo "JUJU_CONTROLLER_ADDRESSES=$JUJU_CONTROLLER_ADDRESSES" >> "$GITHUB_ENV" - echo "JUJU_USERNAME=$JUJU_USERNAME" >> "$GITHUB_ENV" - echo "JUJU_PASSWORD=$JUJU_PASSWORD" >> "$GITHUB_ENV" - { - echo 'JUJU_CA_CERT<> "$GITHUB_ENV" - - uses: hashicorp/setup-terraform@v3.1.2 - - run: terraform init - working-directory: ${{env.WORKING_DIR}} - - run: terraform plan -out=tfplan - working-directory: ${{env.WORKING_DIR}} - - run: terraform show tfplan - working-directory: ${{env.WORKING_DIR}} - - run: | - juju add-model prod-chat-example - set -e # Exit on error - terraform test || { echo "Terraform test failed"; exit 1; } - working-directory: ${{env.WORKING_DIR}} + echo "JUJU_CONTROLLER_ADDRESSES=$JUJU_CONTROLLER_ADDRESSES" >> "$GITHUB_ENV" + echo "JUJU_USERNAME=$JUJU_USERNAME" >> "$GITHUB_ENV" + echo "JUJU_PASSWORD=$JUJU_PASSWORD" >> "$GITHUB_ENV" + { + echo 'JUJU_CA_CERT<> "$GITHUB_ENV" + - uses: hashicorp/setup-terraform@v3.1.2 + - run: terraform init + working-directory: ${{env.WORKING_DIR}} + - run: terraform validate + working-directory: ${{env.WORKING_DIR}} + - run: terraform plan -out=tfplan + working-directory: ${{env.WORKING_DIR}} + - run: terraform show tfplan + working-directory: ${{env.WORKING_DIR}} + - run: | + juju add-model test-aproxy-example + set -e # Exit on error + terraform test || { echo "Terraform test failed"; exit 1; } + working-directory: ${{env.WORKING_DIR}} From 29b85dbd637029169e8bed420c3f2cf26fab5eba Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 17:34:23 +0700 Subject: [PATCH 08/22] fix file path --- .github/workflows/test_terraform_module.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index bf7c8b4..9e4412a 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -19,7 +19,7 @@ jobs: WORKING_DIR: "terraform/tests" steps: - name: Check out code - uses: actions/checkout@@v4.2.2 + uses: actions/checkout@v4.2.2 - name: Setup Juju with LXD uses: charmed-kubernetes/actions-operator@main From ec5ac5a2ffbf6b642ed69479491cf57e27463908 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 17:38:43 +0700 Subject: [PATCH 09/22] update channel --- .github/workflows/test_terraform_module.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index 9e4412a..39ab302 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -26,7 +26,7 @@ jobs: with: provider: "lxd" juju-channel: 3/stable - channel: "1.32-strict/stable" + channel: "latest/stable" - name: Prepare juju tf provider environment run: | From 09341d5904dc0cb68f37f14d037c4c46845dbe89 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 17:46:33 +0700 Subject: [PATCH 10/22] update format --- terraform/main.tf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index a3ad027..33150ce 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -2,13 +2,15 @@ # See LICENSE file for licensing details. resource "juju_application" "aproxy" { - name = var.app_name - charm = var.charm_name - channel = var.channel - model = var.model - base = var.base - revision = var.revision + name = var.app_name + charm { + name = var.charm_name + channel = var.channel + revision = var.revision + base = var.base + } + model = var.model config = var.config units = 0 } From c7e44bcc003705f422946acc2e88430513f08289 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Wed, 8 Oct 2025 17:53:27 +0700 Subject: [PATCH 11/22] change model name --- terraform/tests/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/tests/main.tf b/terraform/tests/main.tf index 918dc26..4891b39 100644 --- a/terraform/tests/main.tf +++ b/terraform/tests/main.tf @@ -29,7 +29,7 @@ module "aproxy" { app_name = "aproxy" channel = var.channel revision = var.revision - model = "prod-aproxy-example" + model = "test-aproxy-example" config = { proxy-address = "127.0.0.1:80" } From a772d4cb5ddfcdce7913c53b36480962f1782568 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 00:59:31 +0700 Subject: [PATCH 12/22] adjust units --- terraform/main.tf | 2 +- terraform/variables.tf | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index 33150ce..1685eba 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -12,5 +12,5 @@ resource "juju_application" "aproxy" { model = var.model config = var.config - units = 0 + units = var.units } diff --git a/terraform/variables.tf b/terraform/variables.tf index 00ff76e..d358185 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -40,4 +40,10 @@ variable "revision" { description = "Revision number of the charm" type = number default = null +} + +variable "units" { + description = "Number of units to deploy" + type = number + default = 1 } \ No newline at end of file From 55f5e72fbb0f385fd12b2b7fcb1c320fb33c659d Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 01:06:54 +0700 Subject: [PATCH 13/22] modify assert --- terraform/tests/main.tftest.hcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/tests/main.tftest.hcl b/terraform/tests/main.tftest.hcl index 619ebf5..fe9168e 100644 --- a/terraform/tests/main.tftest.hcl +++ b/terraform/tests/main.tftest.hcl @@ -3,13 +3,13 @@ variables { channel = "latest/edge" - # renovate: depName="charm_name" + # renovate: depName="aproxy" revision = 1 } run "basic_deploy" { assert { - condition = module.charm_name.app_name == "charm_name" + condition = module.charm_name.app_name == "aproxy" error_message = "charm_name app_name did not match expected" } } From 7772cb2482d2929de61b9aa56717cedf2114c623 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 01:27:36 +0700 Subject: [PATCH 14/22] fix charm name --- terraform/tests/main.tftest.hcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/tests/main.tftest.hcl b/terraform/tests/main.tftest.hcl index fe9168e..3e76399 100644 --- a/terraform/tests/main.tftest.hcl +++ b/terraform/tests/main.tftest.hcl @@ -9,7 +9,7 @@ variables { run "basic_deploy" { assert { - condition = module.charm_name.app_name == "aproxy" - error_message = "charm_name app_name did not match expected" + condition = module.aproxy.app_name == "aproxy" + error_message = "aproxy app_name did not match expected" } } From dac6fb30e05a4142cf6ae01687006109b5a4cfaa Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 16:36:06 +0700 Subject: [PATCH 15/22] modify workflow --- .github/workflows/test_terraform_module.yaml | 19 +++++++++++++++++++ terraform/tests/main.tf | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index 39ab302..ecb6aa9 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -58,3 +58,22 @@ jobs: set -e # Exit on error terraform test || { echo "Terraform test failed"; exit 1; } working-directory: ${{env.WORKING_DIR}} + + - name: Apply Terraform + run: terraform apply -auto-approve + working-directory: ${{ env.WORKING_DIR }} + + - name: Wait for Juju model to settle + run: | + echo "Waiting for model to stabilize..." + juju status --model test-aproxy-example --watch 1s --color + + - name: Verify aproxy application is active + run: | + STATUS=$(juju status aproxy --model test-aproxy-example --format=json | jq -r '.applications.aproxy["application-status"].current') + echo "aproxy status: $STATUS" + if [ "$STATUS" != "active" ]; then + echo "aproxy did not reach active state" + juju status --model test-aproxy-example + exit 1 + fi diff --git a/terraform/tests/main.tf b/terraform/tests/main.tf index 4891b39..7c811d1 100644 --- a/terraform/tests/main.tf +++ b/terraform/tests/main.tf @@ -43,4 +43,4 @@ output "app_name" { output "endpoints" { description = "Integration endpoints exposed by aproxy charm." value = module.aproxy.endpoints -} \ No newline at end of file +} From e19db0a8da85a14e7eb822679e1ee2859bd4978f Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 16:44:38 +0700 Subject: [PATCH 16/22] use juju wait --- .github/workflows/test_terraform_module.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index ecb6aa9..dfd17eb 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -63,10 +63,10 @@ jobs: run: terraform apply -auto-approve working-directory: ${{ env.WORKING_DIR }} - - name: Wait for Juju model to settle + - name: Wait for Juju model to become active run: | - echo "Waiting for model to stabilize..." - juju status --model test-aproxy-example --watch 1s --color + echo "Waiting for model to be active..." + juju wait -m test-aproxy-example --timeout 10m - name: Verify aproxy application is active run: | From 8e10ad7f8c04422a04a4083f81d9684bccc6448d Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 16:57:57 +0700 Subject: [PATCH 17/22] use juju wait-for --- .github/workflows/test_terraform_module.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index dfd17eb..4488887 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -66,7 +66,7 @@ jobs: - name: Wait for Juju model to become active run: | echo "Waiting for model to be active..." - juju wait -m test-aproxy-example --timeout 10m + juju wait-for application aproxy --query='status=="active" || status=="idle"' --timeout=10m - name: Verify aproxy application is active run: | From 024694ace3401ae1bba2f1c7739ed8f75f92a28f Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 16:58:40 +0700 Subject: [PATCH 18/22] modify name --- .github/workflows/test_terraform_module.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index 4488887..5e38808 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -63,9 +63,9 @@ jobs: run: terraform apply -auto-approve working-directory: ${{ env.WORKING_DIR }} - - name: Wait for Juju model to become active + - name: Wait for aproxy to become active run: | - echo "Waiting for model to be active..." + echo "Waiting for aproxy to be active..." juju wait-for application aproxy --query='status=="active" || status=="idle"' --timeout=10m - name: Verify aproxy application is active From e5a896b4fe94ce61c9e2e4547a76fcb2ea08d4c1 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 17:36:35 +0700 Subject: [PATCH 19/22] deploy principal --- .github/workflows/test_terraform_module.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index 5e38808..950f887 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -63,6 +63,11 @@ jobs: run: terraform apply -auto-approve working-directory: ${{ env.WORKING_DIR }} + - name: Deploy principal and relate aproxy + run: | + juju deploy ubuntu --channel=latest/stable --model test-aproxy-example + juju integrate ubuntu aproxy --model test-aproxy-example + - name: Wait for aproxy to become active run: | echo "Waiting for aproxy to be active..." From 8bf1e719b80c1568318d725e8faf42dce10038d1 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 17:55:35 +0700 Subject: [PATCH 20/22] add proxy-address --- .github/workflows/test_terraform_module.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index 950f887..a160bc0 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -66,6 +66,7 @@ jobs: - name: Deploy principal and relate aproxy run: | juju deploy ubuntu --channel=latest/stable --model test-aproxy-example + juju config aproxy proxy-address="127.0.0.1" juju integrate ubuntu aproxy --model test-aproxy-example - name: Wait for aproxy to become active From 37b25c121cfa34a886f56ebbf5508b3c0acc9b37 Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Fri, 10 Oct 2025 18:25:57 +0700 Subject: [PATCH 21/22] simplify check --- .github/workflows/test_terraform_module.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_terraform_module.yaml b/.github/workflows/test_terraform_module.yaml index a160bc0..63d098c 100644 --- a/.github/workflows/test_terraform_module.yaml +++ b/.github/workflows/test_terraform_module.yaml @@ -66,20 +66,19 @@ jobs: - name: Deploy principal and relate aproxy run: | juju deploy ubuntu --channel=latest/stable --model test-aproxy-example - juju config aproxy proxy-address="127.0.0.1" juju integrate ubuntu aproxy --model test-aproxy-example - - name: Wait for aproxy to become active + - name: Wait for aproxy to be deployed run: | - echo "Waiting for aproxy to be active..." - juju wait-for application aproxy --query='status=="active" || status=="idle"' --timeout=10m + echo "Waiting for aproxy to be deployed..." + juju wait-for application aproxy --query='status=="maintenance" || status=="blocked"' --timeout=10m - - name: Verify aproxy application is active + - name: Verify aproxy application is deployed run: | STATUS=$(juju status aproxy --model test-aproxy-example --format=json | jq -r '.applications.aproxy["application-status"].current') echo "aproxy status: $STATUS" - if [ "$STATUS" != "active" ]; then - echo "aproxy did not reach active state" + if [ "$STATUS" == "error" ] || [ "$STATUS" == "unknown" ]; then + echo "aproxy failed to deploy or is unknown" juju status --model test-aproxy-example exit 1 fi From 34300e72a6a261ff295ace2c5e25652dc63387de Mon Sep 17 00:00:00 2001 From: florentianayuwono Date: Tue, 14 Oct 2025 15:59:41 +0700 Subject: [PATCH 22/22] apply suggestion --- terraform/main.tf | 4 ++-- terraform/variables.tf | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 1685eba..45ff265 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -4,7 +4,7 @@ resource "juju_application" "aproxy" { name = var.app_name charm { - name = var.charm_name + name = "aproxy" channel = var.channel revision = var.revision base = var.base @@ -12,5 +12,5 @@ resource "juju_application" "aproxy" { model = var.model config = var.config - units = var.units + units = 1 } diff --git a/terraform/variables.tf b/terraform/variables.tf index d358185..0b936e0 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -7,12 +7,6 @@ variable "app_name" { default = "aproxy" } -variable "charm_name" { - description = "Charmhub charm name for aproxy." - type = string - default = "aproxy" -} - variable "base" { description = "The operating system on which to deploy" type = string @@ -41,9 +35,3 @@ variable "revision" { type = number default = null } - -variable "units" { - description = "Number of units to deploy" - type = number - default = 1 -} \ No newline at end of file