com.pulumi.aws.ec2.Route Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws Show documentation
Show all versions of aws Show documentation
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
The newest version!
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.aws.ec2;
import com.pulumi.aws.Utilities;
import com.pulumi.aws.ec2.RouteArgs;
import com.pulumi.aws.ec2.inputs.RouteState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.String;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Provides a resource to create a routing table entry (a route) in 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` attribute:** The AWS API is very forgiving with the resource ID passed in the `gateway_id` attribute. For example an `aws.ec2.Route` resource can be created with an `aws.ec2.NatGateway` or `aws.ec2.EgressOnlyInternetGateway` ID specified for the `gateway_id` attribute. Specifying anything other than an `aws.ec2.InternetGateway` or `aws.ec2.VpnGateway` ID will lead to this provider reporting a permanent diff between your configuration and recorded state, as the AWS API returns the more-specific attribute. If you are experiencing constant diffs with an `aws.ec2.Route` resource, the first thing to check is that the correct attribute is being specified.
*
* > **NOTE on combining `vpc_endpoint_id` and `destination_prefix_list_id` attributes:** To associate a Gateway VPC Endpoint (such as S3) with destination prefix list, use the `aws.ec2.VpcEndpointRouteTableAssociation` resource instead.
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.aws.ec2.Route;
* import com.pulumi.aws.ec2.RouteArgs;
* import java.util.List;
* import java.util.ArrayList;
* 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 r = new Route("r", RouteArgs.builder()
* .routeTableId(testing.id())
* .destinationCidrBlock("10.0.1.0/22")
* .vpcPeeringConnectionId("pcx-45ff3dc1")
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Example IPv6 Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* 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.EgressOnlyInternetGateway;
* import com.pulumi.aws.ec2.EgressOnlyInternetGatewayArgs;
* import com.pulumi.aws.ec2.Route;
* import com.pulumi.aws.ec2.RouteArgs;
* import java.util.List;
* import java.util.ArrayList;
* 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 vpc = new Vpc("vpc", VpcArgs.builder()
* .cidrBlock("10.1.0.0/16")
* .assignGeneratedIpv6CidrBlock(true)
* .build());
*
* var egress = new EgressOnlyInternetGateway("egress", EgressOnlyInternetGatewayArgs.builder()
* .vpcId(vpc.id())
* .build());
*
* var r = new Route("r", RouteArgs.builder()
* .routeTableId("rtb-4fbb3ac4")
* .destinationIpv6CidrBlock("::/0")
* .egressOnlyGatewayId(egress.id())
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* Import a route in route table `rtb-656C65616E6F72` with an IPv6 destination CIDR of `2620:0:2d0:200::8/125`:
*
* Import a route in route table `rtb-656C65616E6F72` with a managed prefix list destination of `pl-0570a1d2d725c16be`:
*
* __Using `pulumi import` to import__ individual routes using `ROUTETABLEID_DESTINATION`. Import [local routes](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html#RouteTables) using the VPC's IPv4 or IPv6 CIDR blocks. For example:
*
* Import a route in route table `rtb-656C65616E6F72` with an IPv4 destination CIDR of `10.42.0.0/16`:
*
* ```sh
* $ pulumi import aws:ec2/route:Route my_route rtb-656C65616E6F72_10.42.0.0/16
* ```
* Import a route in route table `rtb-656C65616E6F72` with an IPv6 destination CIDR of `2620:0:2d0:200::8/125`:
*
* ```sh
* $ pulumi import aws:ec2/route:Route my_route rtb-656C65616E6F72_2620:0:2d0:200::8/125
* ```
* Import a route in route table `rtb-656C65616E6F72` with a managed prefix list destination of `pl-0570a1d2d725c16be`:
*
* ```sh
* $ pulumi import aws:ec2/route:Route my_route rtb-656C65616E6F72_pl-0570a1d2d725c16be
* ```
*
*/
@ResourceType(type="aws:ec2/route:Route")
public class Route extends com.pulumi.resources.CustomResource {
/**
* Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone.
*
*/
@Export(name="carrierGatewayId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> carrierGatewayId;
/**
* @return Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone.
*
*/
public Output> carrierGatewayId() {
return Codegen.optional(this.carrierGatewayId);
}
/**
* The Amazon Resource Name (ARN) of a core network.
*
*/
@Export(name="coreNetworkArn", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> coreNetworkArn;
/**
* @return The Amazon Resource Name (ARN) of a core network.
*
*/
public Output> coreNetworkArn() {
return Codegen.optional(this.coreNetworkArn);
}
/**
* The destination CIDR block.
*
*/
@Export(name="destinationCidrBlock", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> destinationCidrBlock;
/**
* @return The destination CIDR block.
*
*/
public Output> destinationCidrBlock() {
return Codegen.optional(this.destinationCidrBlock);
}
/**
* The destination IPv6 CIDR block.
*
*/
@Export(name="destinationIpv6CidrBlock", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> destinationIpv6CidrBlock;
/**
* @return The destination IPv6 CIDR block.
*
*/
public Output> destinationIpv6CidrBlock() {
return Codegen.optional(this.destinationIpv6CidrBlock);
}
/**
* The ID of a managed prefix list destination.
*
* One of the following target arguments must be supplied:
*
*/
@Export(name="destinationPrefixListId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> destinationPrefixListId;
/**
* @return The ID of a managed prefix list destination.
*
* One of the following target arguments must be supplied:
*
*/
public Output> destinationPrefixListId() {
return Codegen.optional(this.destinationPrefixListId);
}
/**
* Identifier of a VPC Egress Only Internet Gateway.
*
*/
@Export(name="egressOnlyGatewayId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> egressOnlyGatewayId;
/**
* @return Identifier of a VPC Egress Only Internet Gateway.
*
*/
public Output> egressOnlyGatewayId() {
return Codegen.optional(this.egressOnlyGatewayId);
}
/**
* Identifier of a VPC internet gateway or a virtual private gateway. Specify `local` when updating a previously imported local route.
*
*/
@Export(name="gatewayId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> gatewayId;
/**
* @return Identifier of a VPC internet gateway or a virtual private gateway. Specify `local` when updating a previously imported local route.
*
*/
public Output> gatewayId() {
return Codegen.optional(this.gatewayId);
}
/**
* Identifier of an EC2 instance.
*
*/
@Export(name="instanceId", refs={String.class}, tree="[0]")
private Output instanceId;
/**
* @return Identifier of an EC2 instance.
*
*/
public Output instanceId() {
return this.instanceId;
}
/**
* The AWS account ID of the owner of the EC2 instance.
*
*/
@Export(name="instanceOwnerId", refs={String.class}, tree="[0]")
private Output instanceOwnerId;
/**
* @return The AWS account ID of the owner of the EC2 instance.
*
*/
public Output instanceOwnerId() {
return this.instanceOwnerId;
}
/**
* Identifier of a Outpost local gateway.
*
*/
@Export(name="localGatewayId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> localGatewayId;
/**
* @return Identifier of a Outpost local gateway.
*
*/
public Output> localGatewayId() {
return Codegen.optional(this.localGatewayId);
}
/**
* Identifier of a VPC NAT gateway.
*
*/
@Export(name="natGatewayId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> natGatewayId;
/**
* @return Identifier of a VPC NAT gateway.
*
*/
public Output> natGatewayId() {
return Codegen.optional(this.natGatewayId);
}
/**
* Identifier of an EC2 network interface.
*
*/
@Export(name="networkInterfaceId", refs={String.class}, tree="[0]")
private Output networkInterfaceId;
/**
* @return Identifier of an EC2 network interface.
*
*/
public Output networkInterfaceId() {
return this.networkInterfaceId;
}
/**
* How the route was created - `CreateRouteTable`, `CreateRoute` or `EnableVgwRoutePropagation`.
*
*/
@Export(name="origin", refs={String.class}, tree="[0]")
private Output origin;
/**
* @return How the route was created - `CreateRouteTable`, `CreateRoute` or `EnableVgwRoutePropagation`.
*
*/
public Output origin() {
return this.origin;
}
/**
* The ID of the routing table.
*
* One of the following destination arguments must be supplied:
*
*/
@Export(name="routeTableId", refs={String.class}, tree="[0]")
private Output routeTableId;
/**
* @return The ID of the routing table.
*
* One of the following destination arguments must be supplied:
*
*/
public Output routeTableId() {
return this.routeTableId;
}
/**
* The state of the route - `active` or `blackhole`.
*
*/
@Export(name="state", refs={String.class}, tree="[0]")
private Output state;
/**
* @return The state of the route - `active` or `blackhole`.
*
*/
public Output state() {
return this.state;
}
/**
* Identifier of an EC2 Transit Gateway.
*
*/
@Export(name="transitGatewayId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> transitGatewayId;
/**
* @return Identifier of an EC2 Transit Gateway.
*
*/
public Output> transitGatewayId() {
return Codegen.optional(this.transitGatewayId);
}
/**
* Identifier of a VPC Endpoint.
*
*/
@Export(name="vpcEndpointId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> vpcEndpointId;
/**
* @return Identifier of a VPC Endpoint.
*
*/
public Output> vpcEndpointId() {
return Codegen.optional(this.vpcEndpointId);
}
/**
* Identifier of a VPC peering connection.
*
* Note that the default route, mapping the VPC's CIDR block to "local", is created implicitly and cannot be specified.
*
*/
@Export(name="vpcPeeringConnectionId", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> vpcPeeringConnectionId;
/**
* @return Identifier of a VPC peering connection.
*
* Note that the default route, mapping the VPC's CIDR block to "local", is created implicitly and cannot be specified.
*
*/
public Output> vpcPeeringConnectionId() {
return Codegen.optional(this.vpcPeeringConnectionId);
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public Route(java.lang.String name) {
this(name, RouteArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public Route(java.lang.String name, RouteArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public Route(java.lang.String name, RouteArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("aws:ec2/route:Route", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private Route(java.lang.String name, Output id, @Nullable RouteState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("aws:ec2/route:Route", name, state, makeResourceOptions(options, id), false);
}
private static RouteArgs makeArgs(RouteArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? RouteArgs.Empty : args;
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static Route get(java.lang.String name, Output id, @Nullable RouteState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new Route(name, id, state, options);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy