Search code examples
terraformterraform-provider-azureterraform0.12+

Cannot get the outputs when terraform output is run


I am making use of modules. And this is the structure of my files - Provisioner and module are different folders.The main.tf in stack calls out the modules.

  > provisioner 
        >stack
           |--main.tf
           |--variables.tf
  > module (folder)  
    |--aks
    |     |--main.tf
    |     |--outputs.tf
    |     |--variables.tf
    |
    |--postgresql
    |     |--main.tf
    |     |--outputs.tf
    |     |--variables.tf

When i run "terraform apply" command in the provsioner directory,it is expected to return the outputs after the apply is done. I dont get outputs. When i run 'terraform output' i get- "The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the output keyword and run terraform refresh for it to become available. If you are using interpolation, please verify the interpolated value is not empty"

I would want to know why is this happening?


Solution

  • Output vars of modules won't be printed out by default. You have to explicitly define the output vars in your provisioner dir.