Package com.pulumi.aws.ec2
Class RouteTable
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.ec2.RouteTable
-
public class RouteTable extends com.pulumi.resources.CustomResourceProvides a resource to create a VPC routing table. > **NOTE on `gatewayId` and `natGatewayId`:** 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 `propagatingVgws` and the `aws.ec2.VpnGatewayRoutePropagation` resource:** If the `propagatingVgws` 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 `propagatingVgws`. Omit this argument when defining route propagation using the separate resource. ## Example Usage ### Basic example
To subsequently remove all managed routes:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.RouteTable; import com.pulumi.aws.ec2.RouteTableArgs; import com.pulumi.aws.ec2.inputs.RouteTableRouteArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var example = new RouteTable("example", RouteTableArgs.builder() .routes( RouteTableRouteArgs.builder() .cidrBlock("10.0.1.0/24") .gatewayId(exampleAwsInternetGateway.id()) .build(), RouteTableRouteArgs.builder() .ipv6CidrBlock("::/0") .egressOnlyGatewayId(exampleAwsEgressOnlyInternetGateway.id()) .build()) .vpcId(exampleAwsVpc.id()) .tags(Map.of("Name", "example")) .build()); } }
### 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:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.RouteTable; import com.pulumi.aws.ec2.RouteTableArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var example = new RouteTable("example", RouteTableArgs.builder() .vpcId(exampleAwsVpc.id()) .routes() .tags(Map.of("Name", "example")) .build()); } }
Next, update the target of the route:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.RouteTable; import com.pulumi.aws.ec2.RouteTableArgs; import com.pulumi.aws.ec2.inputs.RouteTableRouteArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var test = new Vpc("test", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var testRouteTable = new RouteTable("testRouteTable", RouteTableArgs.builder() .routes(RouteTableRouteArgs.builder() .cidrBlock("10.1.0.0/16") .gatewayId("local") .build()) .vpcId(test.id()) .build()); } }
The target could then be updated again back to `local`. ## Import ### Identity Schema #### Required * `id` - (String) ID of the routing table. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import Route Tables using the route table `id`. For example: ```sh $ pulumi import aws:ec2/routeTable:RouteTable public_rt rtb-4e616f6d69 ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.Subnet; import com.pulumi.aws.ec2.SubnetArgs; import com.pulumi.aws.ec2.NetworkInterface; import com.pulumi.aws.ec2.NetworkInterfaceArgs; import com.pulumi.aws.ec2.RouteTable; import com.pulumi.aws.ec2.RouteTableArgs; import com.pulumi.aws.ec2.inputs.RouteTableRouteArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var test = new Vpc("test", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var testSubnet = new Subnet("testSubnet", SubnetArgs.builder() .cidrBlock("10.1.1.0/24") .vpcId(test.id()) .build()); var testNetworkInterface = new NetworkInterface("testNetworkInterface", NetworkInterfaceArgs.builder() .subnetId(testSubnet.id()) .build()); var testRouteTable = new RouteTable("testRouteTable", RouteTableArgs.builder() .routes(RouteTableRouteArgs.builder() .cidrBlock(test.cidrBlock()) .networkInterfaceId(testNetworkInterface.id()) .build()) .vpcId(test.id()) .build()); } }
-
-
Constructor Summary
Constructors Constructor Description RouteTable(java.lang.String name)RouteTable(java.lang.String name, RouteTableArgs args)RouteTable(java.lang.String name, RouteTableArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()static RouteTableget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RouteTableState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>ownerId()com.pulumi.core.Output<java.util.List<java.lang.String>>propagatingVgws()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.List<RouteTableRoute>>routes()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()com.pulumi.core.Output<java.lang.String>vpcId()
-
-
-
Constructor Detail
-
RouteTable
public RouteTable(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
RouteTable
public RouteTable(java.lang.String name, RouteTableArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
RouteTable
public RouteTable(java.lang.String name, RouteTableArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- The ARN of the route table.
-
ownerId
public com.pulumi.core.Output<java.lang.String> ownerId()
- Returns:
- The ID of the AWS account that owns the route table.
-
propagatingVgws
public com.pulumi.core.Output<java.util.List<java.lang.String>> propagatingVgws()
- Returns:
- A list of virtual gateways for propagation.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
routes
public com.pulumi.core.Output<java.util.List<RouteTableRoute>> routes()
- Returns:
- A list of route objects. Their keys are documented below. This means that omitting this argument is interpreted as ignoring any existing routes. To remove all managed routes an empty list should be specified. See the example above. > **NOTE on Route Tables and Routes:** This provider currently provides both a standalone Route resource (`aws.ec2.Route`) and a Route Table resource with routes defined in-line (`aws.ec2.RouteTable`). At this time you cannot use a `aws.ec2.RouteTable` inline `route` blocks in conjunction with any `aws.ec2.Route` resources. Doing so will cause a conflict of rule settings and will overwrite rules.
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
vpcId
public com.pulumi.core.Output<java.lang.String> vpcId()
- Returns:
- The VPC ID.
-
get
public static RouteTable get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable RouteTableState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-