Hi @tmihoc
In the terraform juju tutorial while trying to run terraform plan, got error “Reference to undeclared resource”
I checked and found some issue with the example in the tutorial’s main.tf file.
while defining the “postgresql-k8s” juju_application resource (lines 21 - 37 ) , the model “welcome-k8s” was referenced (line 23) instead of the “chat” model that was created earlier in the same tf file (lines 8- 10).
I changed line 23 to “model = juju_model.chat.name” and the terraform plan was successful.
My changes below
21 resource "juju_application" "postgresql-k8s" {
22
23 model = juju_model.welcome-k8s.name (removed)
24 model = juju_model.chat.name (added)
25
26 charm {
27 name = "postgresql-k8s"
28 channel = "14/stable"
29 }
30
31 trust = true
32
33 config = {
34 profile = "testing"
35 }
36
37 }
The originally created model “chat” should be referenced when creating the resource “juju_application” “postgresql-k8s” or the model “welcome-k8s.name” should be created first before being referenced.
Thank you!