pulumi_wasm_providers_aws_mini::ec2

Module route_table

source
Expand description

Provides a resource to create a VPC routing table.

NOTE on Route Tables and Routes: This provider 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.

NOTE on gateway_id and nat_gateway_id: The AWS API is very forgiving with these two attributes and the aws.ec2.RouteTable resource can be created with a NAT ID specified as a Gateway ID attribute. This will lead to a permanent diff between your configuration and statefile, as the API returns the correct parameters in the returned route table. If you’re experiencing constant diffs in your aws.ec2.RouteTable resources, the first thing to check is whether or not you’re specifying a NAT ID instead of a Gateway ID, or vice-versa.

NOTE on propagating_vgws and the aws.ec2.VpnGatewayRoutePropagation resource: If the propagating_vgws argument is present, it’s not supported to also define route propagations using aws.ec2.VpnGatewayRoutePropagation, since this resource will delete any propagating gateways not explicitly listed in propagating_vgws. Omit this argument when defining route propagation using the separate resource.

§Example Usage

§Basic example

resources:
  example:
    type: aws:ec2:RouteTable
    properties:
      vpcId: ${exampleAwsVpc.id}
      routes:
        - cidrBlock: 10.0.1.0/24
          gatewayId: ${exampleAwsInternetGateway.id}
        - ipv6CidrBlock: ::/0
          egressOnlyGatewayId: ${exampleAwsEgressOnlyInternetGateway.id}
      tags:
        Name: example

To subsequently remove all managed routes:

resources:
  example:
    type: aws:ec2:RouteTable
    properties:
      vpcId: ${exampleAwsVpc.id}
      routes: []
      tags:
        Name: example

§Adopting an existing local route

AWS creates certain routes that the AWS provider mostly ignores. You can manage them by importing or adopting them. See Import below for information on importing. This example shows adopting a route and then updating its target.

First, adopt an existing AWS-created route:

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let test = vpc::create(
        "test",
        VpcArgs::builder().cidr_block("10.1.0.0/16").build_struct(),
    );
    let testRouteTable = route_table::create(
        "testRouteTable",
        RouteTableArgs::builder()
            .routes(
                vec![
                    RouteTableRoute::builder().cidrBlock("10.1.0.0/16")
                    .gatewayId("local").build_struct(),
                ],
            )
            .vpc_id("${test.id}")
            .build_struct(),
    );
}

Next, update the target of the route:

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let test = vpc::create(
        "test",
        VpcArgs::builder().cidr_block("10.1.0.0/16").build_struct(),
    );
    let testNetworkInterface = network_interface::create(
        "testNetworkInterface",
        NetworkInterfaceArgs::builder().subnet_id("${testSubnet.id}").build_struct(),
    );
    let testRouteTable = route_table::create(
        "testRouteTable",
        RouteTableArgs::builder()
            .routes(
                vec![
                    RouteTableRoute::builder().cidrBlock("${test.cidrBlock}")
                    .networkInterfaceId("${testNetworkInterface.id}").build_struct(),
                ],
            )
            .vpc_id("${test.id}")
            .build_struct(),
    );
    let testSubnet = subnet::create(
        "testSubnet",
        SubnetArgs::builder()
            .cidr_block("10.1.1.0/24")
            .vpc_id("${test.id}")
            .build_struct(),
    );
}

The target could then be updated again back to local.

§Import

Using pulumi import, import Route Tables using the route table id. For example:

$ pulumi import aws:ec2/routeTable:RouteTable public_rt rtb-4e616f6d69

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments