I have written a module for GCP CloudSQL in below path
C:\new-softwares\terraform_1.2.9_windows_386\cloudsql\cloudsql-module
and in this path i have below files
main.tf
variables.tf
outputs.tf
Above main.tf looks like
resource "google_sql_database_instance" "master1" {
provider = google-beta
name = var.name
and below is output.tf
output "master_instance_name" {
description = "Name of the master database instance"
value = google_sql_database_instance.master1.name
}
Then in the below path i am using this module to create Postgress instance
C:\new-softwares\terraform_1.2.9_windows_386\cloudsql\my-posrgress
and it has files
locals.tf
main.tf
provider.tf
My terraform runs without any errors/warnings and resources are also created. But no outputs are created even when i have defined outputs in the output.tf file,what i am missing here ?
You specified output in Child module and it is necessary to connect modules to each other. but in your case, so that the output is shown in the terminal, you have to put it to the Root module also:
# Create output.tf file in directory C:\new-softwares\terraform_1.2.9_windows_386\cloudsql\my-posrgress\outputs.tf and put:
output "master_instance_name" {
description = "Name of the master database instance"
value = module.<module_name>.master_instance_name
}