Answers: <p>A Terraform module is represented by a whole directory, not an individual file. If you create a directory <code>./modules/queues</code> and move <code>./modules/queues.tf</code> to <code>./modules/queues/queues.tf</code> then you can call that module like this:</p>
  
  <pre><code>module "pae_queues" {
    source = "./modules/queues"
  
    environments = var.environments
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-11-05T01:04:46.763Z
Answers: I had tried moving it to it's own directory (after posting) but was calling still a specific file in that directory but that failed. So I just have to call the directory not any particular file?
Answers: joshk132
Answers: CC BY-SA 4.0
Answers: 2019-11-05T16:56:09.283Z
Answers: Yes, a Terraform module is a directory of `.tf` files, not an individual `.tf` file.
Answers: Martin Atkins
Answers: CC BY-SA 4.0
Answers: 2022-08-05T17:21:06.110Z
Answers: Thanks, i just needed to do source ="./modules" for me!
Answers: John Franke
Answers: CC BY-SA 4.0
Answers: 2019-11-04T17:14:22.960Z
Answers: 2019-11-04T17:14:22.960Z
Answers: Martin Atkins
Body: <p>I am trying to setup terraform with modules and when doing <code>terraform init</code> after creating a module I have ran into an issue where I am told it does not exist or can't be read. I've checked many times and tried many paths to it and it does exist where I think it does. </p>
  
  <p>Not sure in that case why it can't be read. I've included my main.tf file as well as the modules/queues.tf file</p>
  
  <pre><code>main.tf
    | main.tf
    | modules
       | queues.tf
  </code></pre>
  
  <p>main.tf</p>
  
  <pre><code># This file brings together all of the modules
  variable "environments" {
    type = list(string)
  }
  
  
  module "pae_queues" {
      source = "./modules/queues.tf"
  
      environments = "${var.environments}"
  }
  </code></pre>
  
  <p>queues.tf</p>
  
  <pre><code>variable "environments" {
    type = "list(string)"
  }
  
  resource "aws_sqs_queue" "email_queue_${var.environments[count.index]}" {
    count = length(${var.environments})
    name                      = "email_queue_${var.environments[count.index]}"
    delay_seconds             = 0
    max_message_size          = 2048
    message_retention_seconds = 86400
    receive_wait_time_seconds = 10
    redrive_policy            = "{\"deadLetterTargetArn\":\"${aws_sqs_queue.terraform_queue_deadletter.arn}\",\"maxReceiveCount\":3}"
  
    tags = {
      Environment = "${var.environments[count.index]}"
    }
  }
  
  
  </code></pre>
  
Tags: <terraform><terraform-module>
Title: Module directory modules/queues.tf does not exist or cannot be read
UserDisplayName: joshk132
ThreadText: # Module directory modules/queues.tf does not exist or cannot be read
  
  (Asked by: username_0 on 2019-11-03)
  
  I am trying to setup terraform with modules and when doing `terraform init` after creating a module I have ran into an issue where I am told it does not exist or can't be read. I've checked many times and tried many paths to it and it does exist where I think it does.
  
  Not sure in that case why it can't be read. I've included my main.tf file as well as the modules/queues.tf file
  
  ```
  main.tf
    | main.tf
    | modules
       | queues.tf
  
  ```
  
  main.tf
  
  ```
  # This file brings together all of the modules
  variable "environments" {
    type = list(string)
  }
  
  module "pae_queues" {
      source = "./modules/queues.tf"
  
      environments = "${var.environments}"
  }
  
  ```
  
  queues.tf
  
  ```
  variable "environments" {
    type = "list(string)"
  }
  
  resource "aws_sqs_queue" "email_queue_${var.environments[count.index]}" {
    count = length(${var.environments})
    name                      = "email_queue_${var.environments[count.index]}"
    delay_seconds             = 0
    max_message_size          = 2048
    message_retention_seconds = 86400
    receive_wait_time_seconds = 10
    redrive_policy            = "{\"deadLetterTargetArn\":\"${aws_sqs_queue.terraform_queue_deadletter.arn}\",\"maxReceiveCount\":3}"
  
    tags = {
      Environment = "${var.environments[count.index]}"
    }
  }
  
  ```
  
  **Tags:** terraform, terraform-module
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-04. Score: 5 | Accepted answer
  
  A Terraform module is represented by a whole directory, not an individual file. If you create a directory `./modules/queues` and move `./modules/queues.tf` to `./modules/queues/queues.tf` then you can call that module like this:
  
  ```
  module "pae_queues" {
    source = "./modules/queues"
  
    environments = var.environments
  }
  
  ```
  
  > **Comments:**
  > **username_0**: I had tried moving it to it's own directory (after posting) but was calling still a specific file in that directory but that failed. So I just have to call the directory not any particular file?  
  > **username_1**: Yes, a Terraform module is a directory of `.tf` files, not an individual `.tf` file.  
  > **username_2**: Thanks, i just needed to do source ="./modules" for me!  
  
  ---
  
  