Here is my project tree which is hosted on a github private repo
├── deployment
│ ├── security-groups
│ │ ├── data.tf
│ │ ├── outputs.tf
│ │ ├── providers.tf
│ │ ├── sg-eks.tf
│ │ ├── terraform.auto.tfvars
│ │ └── variables.tf
│ └── vpc
│ ├── data.tf
│ ├── locals.tf
│ ├── main.tf
│ ├── outputs.tf
│ ├── providers.tf
│ ├── terraform.auto.tfvars
│ └── variables.tf
├── modules
│ ├── security-groups
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ └── vpc
│ ├── data.tf
│ ├── locals.tf
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
module/vpc/outputs.tf
output "vpc_id" {
description = "The VPC ID"
value = aws_vpc.vpc.id
}
output "public_subnets" {
description = "List of IDs of public subnets"
value = values(aws_subnet.public)[*].id
}
output "private_subnets" {
description = "List of IDs of private subnets"
value = values(aws_subnet.private)[*].id
}
and the deployment/vpc/outputs.tf
output "vpc_id" {
description = "The VPC ID"
value = module.vpc.vpc_id
}
output "public_subnets" {
description = "List of IDs of public subnets"
value = module.vpc.public_subnets
}
output "private_subnets" {
value = module.vpc.private_subnets
}
plan and apply work but when I do the same for another module:
modules/security-groups/output.tf
output "security_group_arn" {
description = "The ARN of the security group"
value = values(aws_security_group.sg)[*].arn
}
deployment\security-groups/output.tf
output "security_group_arn" {
description = "The ARN of the security group"
value = module.security-groups.security_group_arn
}
I get Reference to undeclared module No module call named "security-groups" is declared in the root module. I call on this module in my source "/barak-kalai/terraform-infra.git//modules/security-groups?ref=dev" this works if I plan without the outputs so the module is in place
I'm expecting that apply will produce outputs that I can later use in other module The vpc output is working and I call on it in the terraform cloud remote tfstate
The module name is defined in the root and i was using the file name