<p>Terraform scans the configuration directory for all files whose name end in <code>.tf</code>, and loads them all as configuration.</p>

<p>A common cause of this problem is if you accidentally duplicate one of the <code>.tf</code> files under a new name, and do not update its contents. In that case, Terraform will see both files define the same resource and produce the error shown here.</p>

CC BY-SA 3.0
2017-06-22T15:23:53.710Z
2017-06-22T15:23:53.710Z
Martin Atkins
<p>I have a terraform plan which consists of multiple <code>aws_sqs_queue</code> resources which more of less share the same config. Before I remove any repeating configs and use variables I wanted to run <code>terraform plan</code> to see if it works. However I keep running into - </p>

<pre><code>module root: 1 error(s) occurred:

* data.template_file.ep_match_result_queues: resource repeated multiple times
</code></pre>

<p>Ive tried googling but there is not much information available. Any help will be much appreciated. My plan looks like this: (ignore extra braces, typos as this is just a skeleton to give you a general idea how the plan is sturctured):</p>

<pre><code>data "template_file" "ep_match_result_queues" {
  template = "${var.namespace}-sm-ep"
}

resource "aws_sns_topic" "sns_topic_name" {
  name            = "ep_sm_match_result_topic${var.environment}"
  display_name    = ""
  policy          = &lt;&lt;POLICY
{
 #policy
}


resource "aws_sqs_queue" "queue1" {
 #config
}

resource "aws_sqs_queue" "queue2" {
 #config

    redrive_policy             = &lt;&lt;POLICY
{
 #policy
}
POLICY
}

resource "aws_sqs_queue" "queue3" {
#config
}

resource "aws_sqs_queue" "queue4" {
 #config

    redrive_policy             = &lt;&lt;POLICY
{
 #policy
}
POLICY
}

resource "aws_sqs_queue" "queue5" {
 #config
}

resource "aws_sqs_queue" "queue6" {
  #config

    redrive_policy             = &lt;&lt;POLICY
{
 #policy
}
POLICY
}

resource "aws_sqs_queue" "queue7" {
 #config
}

resource "aws_sqs_queue" "queue8" {
  #config

    redrive_policy             = &lt;&lt;POLICY
{
 #policy
}
POLICY
}

resource "aws_sqs_queue_policy" "queue_policy" {
  queue_url = [ ... ]
  policy    = "${data.aws_iam_policy_document.match_result_queues_policy.json}"
}

data "aws_iam_policy_document" "match_result_queues_policy" {
 #policy
}
</code></pre>

CC BY-SA 3.0
2017-06-07T16:47:41.833Z
Do you have any other `.tf` files in your working directory? Terraform reads all files with that extension and combines them together to form a single configuration, so names must be unique across all files.
Martin Atkins
CC BY-SA 3.0
2017-06-07T16:52:52.693Z
Yeah there was one file which shared a similar name. It was uncommented out by mistake. I changed the name and that issue went away
letsc
CC BY-SA 3.0
2017-06-22T15:24:21.707Z
Great! I've posted my response as an answer here just in case it helps someone else who searches for this same error message in the future.
Martin Atkins
<amazon-web-services><terraform>
Terraform - resource repeated multiple times
letsc
# Terraform - resource repeated multiple times

(Asked by: username_0 on 2017-06-06)

I have a terraform plan which consists of multiple aws_sqs_queue resources which more of less share the same config. Before I remove any repeating configs and use variables I wanted to run terraform plan to see if it works. However I keep running into - 
module root: 1 error(s) occurred:

* data.template_file.ep_match_result_queues: resource repeated multiple times

Ive tried googling but there is not much information available. Any help will be much appreciated. My plan looks like this: (ignore extra braces, typos as this is just a skeleton to give you a general idea how the plan is sturctured):
data "template_file" "ep_match_result_queues" {
  template = "${var.namespace}-sm-ep"
}

resource "aws_sns_topic" "sns_topic_name" {
  name            = "ep_sm_match_result_topic${var.environment}"
  display_name    = ""
  policy          = <

**Tags:** amazon-web-services, terraform

> **Comments:**
> **username_1**: Do you have any other `.tf` files in your working directory? Terraform reads all files with that extension and combines them together to form a single configuration, so names must be unique across all files.  
> **username_0**: Yeah there was one file which shared a similar name. It was uncommented out by mistake. I changed the name and that issue went away  
> **username_1**: Great! I've posted my response as an answer here just in case it helps someone else who searches for this same error message in the future.  

---

## 1 answers

### Answer by username_1 on 2017-06-22. Score: 1

Terraform scans the configuration directory for all files whose name end in `.tf`, and loads them all as configuration.

A common cause of this problem is if you accidentally duplicate one of the `.tf` files under a new name, and do not update its contents. In that case, Terraform will see both files define the same resource and produce the error shown here.


---

