UNPKG

@pulumi/awsx

Version:

[![Actions Status](https://github.com/pulumi/pulumi-awsx/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-awsx/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://badge.fur

102 lines 4.24 kB
"use strict"; // Copyright 2016-2018, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.NatGateway = void 0; const aws = __importStar(require("@pulumi/aws")); const pulumi = __importStar(require("@pulumi/pulumi")); const subnet_1 = require("./subnet"); class NatGateway extends pulumi.ComponentResource { natGatewayName; vpc; elasticIP; natGateway; constructor(name, vpc, args, opts = {}) { super("awsx:x:ec2:NatGateway", name, {}, { parent: vpc, ...opts }); this.vpc = vpc; this.natGatewayName = name; if (isExistingNatGatewayArgs(args)) { this.natGateway = args.natGateway; } else { // from https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html // // you must also specify an Elastic IP address to associate with the NAT gateway // when you create it. After you've created a NAT gateway, you must update the route // table associated with one or more of your private subnets to point Internet-bound // traffic to the NAT gateway. This enables instances in your private subnets to // communicate with the internet. this.elasticIP = new aws.ec2.Eip(name, { domain: "vpc", tags: { Name: name }, }, { parent: this }); const subnetId = subnet_1.Subnet.isSubnetInstance(args.subnet) ? args.subnet.id : args.subnet; this.natGateway = new aws.ec2.NatGateway(name, { ...args, subnetId, allocationId: this.elasticIP.id, }, { parent: this }); } this.registerOutputs(); } route(name, opts) { return { // From https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-create-route // Choose Add another route. For Destination, type 0.0.0.0/0. For Target, select the ID // of your NAT gateway. destinationCidrBlock: "0.0.0.0/0", natGatewayId: this.natGateway.id, }; } } exports.NatGateway = NatGateway; function isExistingNatGatewayArgs(obj) { return !!obj.natGateway; } //# sourceMappingURL=natGateway.js.map