@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
186 lines • 6.74 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.RouteTable = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides 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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.ec2.RouteTable("example", {
* 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:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.ec2.RouteTable("example", {
* 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:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const test = new aws.ec2.Vpc("test", {cidrBlock: "10.1.0.0/16"});
* const testRouteTable = new aws.ec2.RouteTable("test", {
* vpcId: test.id,
* routes: [{
* cidrBlock: "10.1.0.0/16",
* gatewayId: "local",
* }],
* });
* ```
*
* Next, update the target of the route:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const test = new aws.ec2.Vpc("test", {cidrBlock: "10.1.0.0/16"});
* const testSubnet = new aws.ec2.Subnet("test", {
* cidrBlock: "10.1.1.0/24",
* vpcId: test.id,
* });
* const testNetworkInterface = new aws.ec2.NetworkInterface("test", {subnetId: testSubnet.id});
* const testRouteTable = new aws.ec2.RouteTable("test", {
* vpcId: test.id,
* routes: [{
* cidrBlock: test.cidrBlock,
* networkInterfaceId: testNetworkInterface.id,
* }],
* });
* ```
*
* The target could then be updated again back to `local`.
*
* ## Import
*
* ### Identity Schema
*
* #### Required
*
* * `id` - (String) ID of the routing table.
*
* #### Optional
*
* * `account_id` (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:
*
* console
*
* % pulumi import aws_route_table.public_rt rtb-4e616f6d69
*/
class RouteTable extends pulumi.CustomResource {
/**
* Get an existing RouteTable 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 Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new RouteTable(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of RouteTable. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === RouteTable.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["ownerId"] = state?.ownerId;
resourceInputs["propagatingVgws"] = state?.propagatingVgws;
resourceInputs["region"] = state?.region;
resourceInputs["routes"] = state?.routes;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["vpcId"] = state?.vpcId;
}
else {
const args = argsOrState;
if (args?.vpcId === undefined && !opts.urn) {
throw new Error("Missing required property 'vpcId'");
}
resourceInputs["propagatingVgws"] = args?.propagatingVgws;
resourceInputs["region"] = args?.region;
resourceInputs["routes"] = args?.routes;
resourceInputs["tags"] = args?.tags;
resourceInputs["vpcId"] = args?.vpcId;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["ownerId"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(RouteTable.__pulumiType, name, resourceInputs, opts);
}
}
exports.RouteTable = RouteTable;
/** @internal */
RouteTable.__pulumiType = 'aws:ec2/routeTable:RouteTable';
//# sourceMappingURL=routeTable.js.map