Open kian99 opened 4 months ago
@kian99, What do the terraform plans look like in this case? And how are they used? As we have 2 users in the example, please include user in the provider definition block.
My full TF plan looked as follows, using the local provider,
terraform {
required_providers {
juju = {
version = "0.12.0"
source = "registry.terraform.io/juju/juju"
}
}
}
provider "juju" {
controller_addresses = "10.16.149.168:17070"
username = "bob"
password = "bob"
}
resource "juju_application" "wordpress" {
name = "wordpress"
model = "foo"
charm {
name = "wordpress"
}
units = 1
}
Description
The Juju Terraform provider doesn't behave correctly when a user has access to multiple models with the same name. This is mainly relevant to VM models where a model name is only unique according to
<ownerName>/<modelName>
. On K8s clouds names are unique thanks to namespace rules but if a Juju controller had multiple k8s clouds, this could also be an issue there.Urgency
Casually reporting
Terraform Juju Provider version
0.12.0
Terraform version
1.8.5
Juju version
3.5.1
Terraform Configuration(s)
Reproduce / Test
Note: To switch users run
juju logout
thenjuju login -u <user> -c test
.Now Alice will have access to 2 models with the same name but different owners. At this point it's a little tough to prove the issue without extra debugging in the provider. One can add the following debug line to the provider, compile it locally and view the output.
Add
Above this line. Then use the custom provider with the above plan. Before running
terraform apply
runexport TF_LOG="TRACE"
to set the debug level for Terraform to trace in order to see the debug logs. They should resemble something similar to,Whatever order is returned by Juju will determine which model the terraform plan will apply to.