UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

180 lines 7.14 kB
"use strict"; // *** 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 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 `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 * * Using `pulumi import`, import Route Tables using the route table `id`. For example: * * ```sh * $ pulumi import aws:ec2/routeTable:RouteTable 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, Object.assign(Object.assign({}, 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 ? state.arn : undefined; resourceInputs["ownerId"] = state ? state.ownerId : undefined; resourceInputs["propagatingVgws"] = state ? state.propagatingVgws : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["routes"] = state ? state.routes : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["vpcId"] = state ? state.vpcId : undefined; } else { const args = argsOrState; if ((!args || args.vpcId === undefined) && !opts.urn) { throw new Error("Missing required property 'vpcId'"); } resourceInputs["propagatingVgws"] = args ? args.propagatingVgws : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["routes"] = args ? args.routes : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["vpcId"] = args ? args.vpcId : undefined; 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