UNPKG

@pulumi/aws

Version:

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

207 lines • 8.49 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.NatGateway = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides a resource to create a VPC NAT Gateway. * * !> **WARNING:** You should not use the `aws.ec2.NatGateway` resource that has `secondaryAllocationIds` in conjunction with an `aws.ec2.NatGatewayEipAssociation` resource. Doing so may cause perpetual differences, and result in associations being overwritten. * * ## Example Usage * * ### Public NAT * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ec2.NatGateway("example", { * allocationId: exampleAwsEip.id, * subnetId: exampleAwsSubnet.id, * tags: { * Name: "gw NAT", * }, * }, { * dependsOn: [exampleAwsInternetGateway], * }); * ``` * * ### Public NAT with Secondary Private IP Addresses * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ec2.NatGateway("example", { * allocationId: exampleAwsEip.id, * subnetId: exampleAwsSubnet.id, * secondaryAllocationIds: [secondary.id], * secondaryPrivateIpAddresses: ["10.0.1.5"], * }); * ``` * * ### Private NAT * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ec2.NatGateway("example", { * connectivityType: "private", * subnetId: exampleAwsSubnet.id, * }); * ``` * * ### Private NAT with Secondary Private IP Addresses * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ec2.NatGateway("example", { * connectivityType: "private", * subnetId: exampleAwsSubnet.id, * secondaryPrivateIpAddressCount: 7, * }); * ``` * * ### Regional NAT Gateway with auto mode * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const available = aws.getAvailabilityZones({}); * const example = new aws.ec2.Vpc("example", {cidrBlock: "10.0.0.0/16"}); * const exampleInternetGateway = new aws.ec2.InternetGateway("example", {vpcId: example.id}); * const exampleNatGateway = new aws.ec2.NatGateway("example", { * vpcId: example.id, * availabilityMode: "regional", * }); * ``` * * ### Regional NAT Gateway with manual mode * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const available = aws.getAvailabilityZones({}); * const example = new aws.ec2.Vpc("example", {cidrBlock: "10.0.0.0/16"}); * const exampleInternetGateway = new aws.ec2.InternetGateway("example", {vpcId: example.id}); * const exampleEip: aws.ec2.Eip[] = []; * for (const range = {value: 0}; range.value < 3; range.value++) { * exampleEip.push(new aws.ec2.Eip(`example-${range.value}`, {domain: "vpc"})); * } * const exampleNatGateway = new aws.ec2.NatGateway("example", { * vpcId: example.id, * availabilityMode: "regional", * availabilityZoneAddresses: [ * { * allocationIds: [exampleEip[0].id], * availabilityZone: available.then(available => available.names?.[0]), * }, * { * allocationIds: [ * exampleEip[1].id, * exampleEip[2].id, * ], * availabilityZone: available.then(available => available.names?.[1]), * }, * ], * }); * ``` * * ## Import * * Using `pulumi import`, import NAT Gateways using the `id`. For example: * * ```sh * $ pulumi import aws:ec2/natGateway:NatGateway private_gw nat-05dba92075d71c408 * ``` */ class NatGateway extends pulumi.CustomResource { /** * Get an existing NatGateway 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 NatGateway(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of NatGateway. 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'] === NatGateway.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["allocationId"] = state?.allocationId; resourceInputs["associationId"] = state?.associationId; resourceInputs["autoProvisionZones"] = state?.autoProvisionZones; resourceInputs["autoScalingIps"] = state?.autoScalingIps; resourceInputs["availabilityMode"] = state?.availabilityMode; resourceInputs["availabilityZoneAddresses"] = state?.availabilityZoneAddresses; resourceInputs["connectivityType"] = state?.connectivityType; resourceInputs["networkInterfaceId"] = state?.networkInterfaceId; resourceInputs["privateIp"] = state?.privateIp; resourceInputs["publicIp"] = state?.publicIp; resourceInputs["region"] = state?.region; resourceInputs["regionalNatGatewayAddresses"] = state?.regionalNatGatewayAddresses; resourceInputs["regionalNatGatewayAutoMode"] = state?.regionalNatGatewayAutoMode; resourceInputs["routeTableId"] = state?.routeTableId; resourceInputs["secondaryAllocationIds"] = state?.secondaryAllocationIds; resourceInputs["secondaryPrivateIpAddressCount"] = state?.secondaryPrivateIpAddressCount; resourceInputs["secondaryPrivateIpAddresses"] = state?.secondaryPrivateIpAddresses; resourceInputs["subnetId"] = state?.subnetId; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["vpcId"] = state?.vpcId; } else { const args = argsOrState; resourceInputs["allocationId"] = args?.allocationId; resourceInputs["availabilityMode"] = args?.availabilityMode; resourceInputs["availabilityZoneAddresses"] = args?.availabilityZoneAddresses; resourceInputs["connectivityType"] = args?.connectivityType; resourceInputs["privateIp"] = args?.privateIp; resourceInputs["region"] = args?.region; resourceInputs["secondaryAllocationIds"] = args?.secondaryAllocationIds; resourceInputs["secondaryPrivateIpAddressCount"] = args?.secondaryPrivateIpAddressCount; resourceInputs["secondaryPrivateIpAddresses"] = args?.secondaryPrivateIpAddresses; resourceInputs["subnetId"] = args?.subnetId; resourceInputs["tags"] = args?.tags; resourceInputs["vpcId"] = args?.vpcId; resourceInputs["associationId"] = undefined /*out*/; resourceInputs["autoProvisionZones"] = undefined /*out*/; resourceInputs["autoScalingIps"] = undefined /*out*/; resourceInputs["networkInterfaceId"] = undefined /*out*/; resourceInputs["publicIp"] = undefined /*out*/; resourceInputs["regionalNatGatewayAddresses"] = undefined /*out*/; resourceInputs["regionalNatGatewayAutoMode"] = undefined /*out*/; resourceInputs["routeTableId"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(NatGateway.__pulumiType, name, resourceInputs, opts); } } exports.NatGateway = NatGateway; /** @internal */ NatGateway.__pulumiType = 'aws:ec2/natGateway:NatGateway'; //# sourceMappingURL=natGateway.js.map