Hi,
I cannot figure how to use the random password that RDS module generates by default when applying RDS from the module Terraform Registry
terraform state list
Shows module.db.random_password.master_password[0]
But I get error:
╵
╷
│ Error: Unsupported attribute
│
│ on ecs.tf line 102, in resource "aws_ecs_task_definition" "service-task-definition":
│ 102: {"name": "PASSWORD", "value": "${module.db.random_password.master_password[0]}"},
│ ├────────────────
│ │ module.db is a object, known only after apply
│
│ This object does not have an attribute named "random_password".
Hi @markotitel !
Here is how the RDS module defines its output that contains the password:
So it seems that in your case, it would look something like that:
{"name": "PASSWORD", "value": "${module.db.db_instance_password}"}
A module can only return some value(s) if it is explicitly defined as the output
. Generally, the module’s source code (a best practice but still may vary) contains a special file called outputs.tf
where you can see all defined outputs — all you can get from the module and reuse somewhere else.
1 Like
Hi and thank you very much for taking time to help.
Yes! This is the solution. And yes now it looks easy once you explained.
Thanks again.
1 Like
You’re always welcome, @markotitel! Perhaps the following post series will be helpful and interesting for you as well — Terraform Proficiency