Description
When trying to use a variable for a charm resource as below, a Value Conversion Error is thrown.
Resource definition:
resource juju_application "temporal_worker" {
name = "temporal-worker-k8s"
for_each = juju_model.temporal_worker
model = each.value.name
units = 1
charm {
name = "temporal-worker-k8s"
channel = var.temporal_worker_channel
revision = var.temporal_worker_revision
}
resources = {
temporal-worker-image = var.temporal_worker_resource
}
}
Variable definition:
variable temporal_worker_resource {
description = "OCI Image resource for temporal worker"
type = string
default = "ghcr.io/canonical/msm-temporal-worker:1.0"
}
Error thrown:
╷
│ Error: Value Conversion Error
│
│ with juju_application.temporal_worker,
│ on main.tf line 319, in resource "juju_application" "temporal_worker":
│ 319: resource juju_application "temporal_worker" {
│
│ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to
│ the provider developer:
│
│ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom
│ type that handles unknown values.
│
│ Path: ["temporal-worker-image"]
│ Target Type: string
│ Suggested Type: basetypes.StringValue
Workaround
Defining the variable as a map will remove the error:
variable temporal_worker_resources {
description = "OCI Image resource version for temporal worker"
type = map
default = {temporal-worker-resource:"ghcr.io/canonical/msm-temporal-worker:1.0"}
}
resources = var.temporal_worker_resources
Urgency
Casually reporting
Terraform Juju Provider version
0.21.0
Terraform version
1.12.2
Juju version
3.6.8
Terraform Configuration(s)
#variables.tf
variable temporal_worker_resource {
description = "OCI Image resource for temporal worker"
type = string
default = "ghcr.io/canonical/msm-temporal-worker:1.0"
}
#main.tf
terraform {
required_providers {
juju = {
version = "~> 0.21.0"
source = "juju/juju"
}
}
}
resource "juju_model" "temporal_worker" {
name = "temporal-worker"
cloud {
name = "microk8s"
}
}
resource juju_application "temporal_worker" {
name = "temporal-worker-k8s"
model = juju_model.temporal_worker.name
units = 1
charm {
name = "temporal-worker-k8s"
channel = "latest/stable"
}
resources = {
temporal-worker-image = var.temporal_worker_resource
}
}
Reproduce / Test
terraform init
terraform validate
Debug/Panic Output
╷
│ Error: Value Conversion Error
│
│ with juju_application.temporal_worker,
│ on main.tf line 319, in resource "juju_application" "temporal_worker":
│ 319: resource juju_application "temporal_worker" {
│
│ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to
│ the provider developer:
│
│ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom
│ type that handles unknown values.
│
│ Path: ["temporal-worker-image"]
│ Target Type: string
│ Suggested Type: basetypes.StringValue
Notes & References
No response
Description
When trying to use a variable for a charm resource as below, a Value Conversion Error is thrown.
Resource definition:
Variable definition:
Error thrown:
Workaround
Defining the variable as a map will remove the error:
Urgency
Casually reporting
Terraform Juju Provider version
0.21.0
Terraform version
1.12.2
Juju version
3.6.8
Terraform Configuration(s)
Reproduce / Test
Debug/Panic Output
Notes & References
No response