How to refer the attributes from one module to another module?

Below is my directory structure

├── applications
│   ├── app01
│   │   ├── main.tf
│   │   ├── output.tf
│   │   ├── provider.tf
│   │   └── variables.tf
│   └── app02
│       ├── main.tf
│       ├── output.tf
│       ├── provider.tf
│       └── variables.tf
├── app_sg
│   └── main.tf
└── modules
    ├── instance
    │   ├── main.tf
    │   ├── output.tf
    │   └── variables.tf
    ├── sg
    │   ├── main.tf
    │   ├── output.tf
    │   └── variables.tf
    └── volume
        ├── main.tf
        ├── output.tf
        └── variables.tf

From the structure mentioned, the instance and volume resources were re-usable and common across the applications. On each application, I'm writing two modules (Instance creation and volume creation with attachment). Please let me know how to refer the instance IDs for volume attachment.

To pass values in and out of modules you need to use variable and output blocks. Traditionally these are stored in the variables.tf and outputs.tf files (although there is no requirement as all files are treated the same by Terraform).

Thanks a lot. Is there any sample code block available for reference?

Hi,

There are well done tutorials available for free on learn.hashicorp.com. For example, you have the module course at Reuse Configuration with Modules | Terraform - HashiCorp Learn.