Answers: <p>These are two ways of accomplishing the same thing with limitations.</p>
  <p>Note that you cannot use both methods for the same table.  In other words if you create routes in the <code>aws_route_table</code> you cannot associate routes created with <code>aws_route</code></p>
  <blockquote>
  <p>Terraform currently provides both a standalone Route resource and a Route Table resource with routes defined in-line. At this time you cannot use a Route Table with in-line routes in conjunction with any Route resources. Doing so will cause a conflict of rule settings and will overwrite rules.</p>
  </blockquote>
  <p>Q1. The route block in <code>aws_route_table</code> is creating a route inside the routing table without the need to create a separate route using <code>aws_route</code>.</p>
  <p>Q2.  Yes, they accomplish the same result.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-07-08T14:42:59.970Z
Answers: That answers my question!
  Thank you @kenlukas
Answers: Shaddar
Answers: CC BY-SA 4.0
Answers: 2022-07-08T14:10:57.330Z
Answers: 2022-07-08T14:10:57.330Z
Answers: kenlukas
Body: <p>I'm struggling to understand the difference between the following Terraform Resources:</p>
  <p>Example 1:</p>
  <pre><code>resource &quot;aws_route_table&quot; &quot;public_1&quot; {
    vpc_id = aws_vpc.test.id
    route {
      cidr_block = &quot;0.0.0.0/0&quot;
      gateway_id = aws_internet_gateway.main.id
    }
    tags = {
      Name = &quot;test-route&quot;
    }
  }
  resource &quot;aws_route_table_association&quot; &quot;test_pub_route&quot; {
    subnet_id      = aws_subnet.test_pub.id
    route_table_id = aws_route_table.public_1.id
  }
  
  </code></pre>
  <p>Correct me if I'm wrong but in this example I'm just creating a route and a route table with <code>public_1</code> resource.<br />
  In the second part I'm just associating the public_1 route table subnet called test_pub.</p>
  <p><strong>Question 1:</strong>
  I don't understand what does the block route do in <code>public_1</code>
  The documentation <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table" rel="nofollow noreferrer">here</a> doesn't make much sense to me.</p>
  <p>Example 2:</p>
  <pre><code>resource &quot;aws_route_table&quot; &quot;public&quot; {
    vpc_id = aws_vpc.main.id
  }
  resource &quot;aws_route&quot; &quot;public&quot; {
    route_table_id         = aws_route_table.public.id
    destination_cidr_block = &quot;0.0.0.0/0&quot;
    gateway_id             = aws_internet_gateway.main.id
  }
  resource &quot;aws_route_table_association&quot; &quot;public&quot; {
    subnet_id      = aws_subnet.test_pub.id
    route_table_id = aws_route_table.public.id
  }
  
  </code></pre>
  <p><strong>Question 2(main)</strong>
  I'm trying to understand if these two examples are actually the same. And that the only difference is that in the first example we have route block which is equivalent to resource aws_route in the second example.<br />
  Even the required variables are the same just name is little bit different.</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-07-08T11:48:40.593Z
Comments: Through testing i have confirmed that resutls are the same.
Comments: Shaddar
Tags: <amazon-web-services><terraform><aws-vpc>
Title: AWS-Terraform VPC difference between aws_route_table and aws_route
UserDisplayName: Shaddar
ThreadText: # AWS-Terraform VPC difference between aws_route_table and aws_route
  
  (Asked by: username_0 on 2022-07-08)
  
  I'm struggling to understand the difference between the following Terraform Resources:
  
  Example 1:
  
  ```
  resource "aws_route_table" "public_1" {
    vpc_id = aws_vpc.test.id
    route {
      cidr_block = "0.0.0.0/0"
      gateway_id = aws_internet_gateway.main.id
    }
    tags = {
      Name = "test-route"
    }
  }
  resource "aws_route_table_association" "test_pub_route" {
    subnet_id      = aws_subnet.test_pub.id
    route_table_id = aws_route_table.public_1.id
  }
  
  ```
  
  Correct me if I'm wrong but in this example I'm just creating a route and a route table with `public_1` resource.  
  In the second part I'm just associating the public\_1 route table subnet called test\_pub.
  
  **Question 1:**
  I don't understand what does the block route do in `public_1`
  The documentation [here](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route_table) doesn't make much sense to me.
  
  Example 2:
  
  ```
  resource "aws_route_table" "public" {
    vpc_id = aws_vpc.main.id
  }
  resource "aws_route" "public" {
    route_table_id         = aws_route_table.public.id
    destination_cidr_block = "0.0.0.0/0"
    gateway_id             = aws_internet_gateway.main.id
  }
  resource "aws_route_table_association" "public" {
    subnet_id      = aws_subnet.test_pub.id
    route_table_id = aws_route_table.public.id
  }
  
  ```
  
  **Question 2(main)**
  I'm trying to understand if these two examples are actually the same. And that the only difference is that in the first example we have route block which is equivalent to resource aws\_route in the second example.  
  Even the required variables are the same just name is little bit different.
  
  **Tags:** amazon-web-services, terraform, aws-vpc
  
  > **Comments:**
  > **username_0**: Through testing i have confirmed that resutls are the same.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-08. Score: 2
  
  These are two ways of accomplishing the same thing with limitations.
  
  Note that you cannot use both methods for the same table. In other words if you create routes in the `aws_route_table` you cannot associate routes created with `aws_route`
  
  > Terraform currently provides both a standalone Route resource and a Route Table resource with routes defined in-line. At this time you cannot use a Route Table with in-line routes in conjunction with any Route resources. Doing so will cause a conflict of rule settings and will overwrite rules.
  
  Q1. The route block in `aws_route_table` is creating a route inside the routing table without the need to create a separate route using `aws_route`.
  
  Q2. Yes, they accomplish the same result.
  
  > **Comments:**
  > **username_0**: That answers my question! Thank you @username_1  
  
  ---
  
  