"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.RouterNat = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A NAT service created in a router.
 *
 * > **Note:** Recreating a `gcp.compute.Address` that is being used by `gcp.compute.RouterNat` will give a `resourceInUseByAnotherResource` error.
 * Use `lifecycle.create_before_destroy` on this address resource to avoid this type of error as shown in the Manual Ips example.
 *
 * To get more information about RouterNat, see:
 *
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/routers)
 * * How-to Guides
 *     * [Google Cloud Router](https://cloud.google.com/router/docs/)
 *
 * ## Example Usage
 *
 * ### Router Nat Basic
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const net = new gcp.compute.Network("net", {name: "my-network"});
 * const subnet = new gcp.compute.Subnetwork("subnet", {
 *     name: "my-subnetwork",
 *     network: net.id,
 *     ipCidrRange: "10.0.0.0/16",
 *     region: "us-central1",
 * });
 * const router = new gcp.compute.Router("router", {
 *     name: "my-router",
 *     region: subnet.region,
 *     network: net.id,
 *     bgp: {
 *         asn: 64514,
 *     },
 * });
 * const nat = new gcp.compute.RouterNat("nat", {
 *     name: "my-router-nat",
 *     router: router.name,
 *     region: router.region,
 *     natIpAllocateOption: "AUTO_ONLY",
 *     sourceSubnetworkIpRangesToNat: "ALL_SUBNETWORKS_ALL_IP_RANGES",
 *     logConfig: {
 *         enable: true,
 *         filter: "ERRORS_ONLY",
 *     },
 * });
 * ```
 * ### Router Nat Rules
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const net = new gcp.compute.Network("net", {
 *     name: "my-network",
 *     autoCreateSubnetworks: false,
 * });
 * const subnet = new gcp.compute.Subnetwork("subnet", {
 *     name: "my-subnetwork",
 *     network: net.id,
 *     ipCidrRange: "10.0.0.0/16",
 *     region: "us-central1",
 * });
 * const router = new gcp.compute.Router("router", {
 *     name: "my-router",
 *     region: subnet.region,
 *     network: net.id,
 * });
 * const addr1 = new gcp.compute.Address("addr1", {
 *     name: "nat-address1",
 *     region: subnet.region,
 * });
 * const addr2 = new gcp.compute.Address("addr2", {
 *     name: "nat-address2",
 *     region: subnet.region,
 * });
 * const addr3 = new gcp.compute.Address("addr3", {
 *     name: "nat-address3",
 *     region: subnet.region,
 * });
 * const natRules = new gcp.compute.RouterNat("nat_rules", {
 *     name: "my-router-nat",
 *     router: router.name,
 *     region: router.region,
 *     natIpAllocateOption: "MANUAL_ONLY",
 *     natIps: [addr1.selfLink],
 *     sourceSubnetworkIpRangesToNat: "LIST_OF_SUBNETWORKS",
 *     subnetworks: [{
 *         name: subnet.id,
 *         sourceIpRangesToNats: ["ALL_IP_RANGES"],
 *     }],
 *     rules: [{
 *         ruleNumber: 100,
 *         description: "nat rules example",
 *         match: "inIpRange(destination.ip, '1.1.0.0/16') || inIpRange(destination.ip, '2.2.0.0/16')",
 *         action: {
 *             sourceNatActiveIps: [
 *                 addr2.selfLink,
 *                 addr3.selfLink,
 *             ],
 *         },
 *     }],
 *     enableEndpointIndependentMapping: false,
 * });
 * ```
 * ### Router Nat Private
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const net = new gcp.compute.Network("net", {name: "my-network"});
 * const subnet = new gcp.compute.Subnetwork("subnet", {
 *     name: "my-subnetwork",
 *     network: net.id,
 *     ipCidrRange: "10.0.0.0/16",
 *     region: "us-central1",
 *     purpose: "PRIVATE_NAT",
 * });
 * const router = new gcp.compute.Router("router", {
 *     name: "my-router",
 *     region: subnet.region,
 *     network: net.id,
 * });
 * const hub = new gcp.networkconnectivity.Hub("hub", {
 *     name: "my-hub",
 *     description: "vpc hub for inter vpc nat",
 * });
 * const spoke = new gcp.networkconnectivity.Spoke("spoke", {
 *     name: "my-spoke",
 *     location: "global",
 *     description: "vpc spoke for inter vpc nat",
 *     hub: hub.id,
 *     linkedVpcNetwork: {
 *         excludeExportRanges: [
 *             "198.51.100.0/24",
 *             "10.10.0.0/16",
 *         ],
 *         uri: net.selfLink,
 *     },
 * });
 * const natType = new gcp.compute.RouterNat("nat_type", {
 *     name: "my-router-nat",
 *     router: router.name,
 *     region: router.region,
 *     sourceSubnetworkIpRangesToNat: "LIST_OF_SUBNETWORKS",
 *     enableDynamicPortAllocation: false,
 *     enableEndpointIndependentMapping: false,
 *     minPortsPerVm: 32,
 *     type: "PRIVATE",
 *     subnetworks: [{
 *         name: subnet.id,
 *         sourceIpRangesToNats: ["ALL_IP_RANGES"],
 *     }],
 *     rules: [{
 *         ruleNumber: 100,
 *         description: "rule for private nat",
 *         match: "nexthop.hub == \"//networkconnectivity.googleapis.com/projects/acm-test-proj-123/locations/global/hubs/my-hub\"",
 *         action: {
 *             sourceNatActiveRanges: [subnet.selfLink],
 *         },
 *     }],
 * });
 * ```
 *
 * ## Import
 *
 * RouterNat can be imported using any of these accepted formats:
 *
 * * `projects/{{project}}/regions/{{region}}/routers/{{router}}/{{name}}`
 *
 * * `{{project}}/{{region}}/{{router}}/{{name}}`
 *
 * * `{{region}}/{{router}}/{{name}}`
 *
 * * `{{router}}/{{name}}`
 *
 * When using the `pulumi import` command, RouterNat can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:compute/routerNat:RouterNat default projects/{{project}}/regions/{{region}}/routers/{{router}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/routerNat:RouterNat default {{project}}/{{region}}/{{router}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/routerNat:RouterNat default {{region}}/{{router}}/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:compute/routerNat:RouterNat default {{router}}/{{name}}
 * ```
 */
class RouterNat extends pulumi.CustomResource {
    /**
     * Get an existing RouterNat 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 RouterNat(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of RouterNat.  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'] === RouterNat.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["autoNetworkTier"] = state?.autoNetworkTier;
            resourceInputs["drainNatIps"] = state?.drainNatIps;
            resourceInputs["enableDynamicPortAllocation"] = state?.enableDynamicPortAllocation;
            resourceInputs["enableEndpointIndependentMapping"] = state?.enableEndpointIndependentMapping;
            resourceInputs["endpointTypes"] = state?.endpointTypes;
            resourceInputs["icmpIdleTimeoutSec"] = state?.icmpIdleTimeoutSec;
            resourceInputs["initialNatIps"] = state?.initialNatIps;
            resourceInputs["logConfig"] = state?.logConfig;
            resourceInputs["maxPortsPerVm"] = state?.maxPortsPerVm;
            resourceInputs["minPortsPerVm"] = state?.minPortsPerVm;
            resourceInputs["name"] = state?.name;
            resourceInputs["nat64Subnetworks"] = state?.nat64Subnetworks;
            resourceInputs["natIpAllocateOption"] = state?.natIpAllocateOption;
            resourceInputs["natIps"] = state?.natIps;
            resourceInputs["project"] = state?.project;
            resourceInputs["region"] = state?.region;
            resourceInputs["router"] = state?.router;
            resourceInputs["rules"] = state?.rules;
            resourceInputs["sourceSubnetworkIpRangesToNat"] = state?.sourceSubnetworkIpRangesToNat;
            resourceInputs["sourceSubnetworkIpRangesToNat64"] = state?.sourceSubnetworkIpRangesToNat64;
            resourceInputs["subnetworks"] = state?.subnetworks;
            resourceInputs["tcpEstablishedIdleTimeoutSec"] = state?.tcpEstablishedIdleTimeoutSec;
            resourceInputs["tcpTimeWaitTimeoutSec"] = state?.tcpTimeWaitTimeoutSec;
            resourceInputs["tcpTransitoryIdleTimeoutSec"] = state?.tcpTransitoryIdleTimeoutSec;
            resourceInputs["type"] = state?.type;
            resourceInputs["udpIdleTimeoutSec"] = state?.udpIdleTimeoutSec;
        }
        else {
            const args = argsOrState;
            if (args?.router === undefined && !opts.urn) {
                throw new Error("Missing required property 'router'");
            }
            if (args?.sourceSubnetworkIpRangesToNat === undefined && !opts.urn) {
                throw new Error("Missing required property 'sourceSubnetworkIpRangesToNat'");
            }
            resourceInputs["autoNetworkTier"] = args?.autoNetworkTier;
            resourceInputs["drainNatIps"] = args?.drainNatIps;
            resourceInputs["enableDynamicPortAllocation"] = args?.enableDynamicPortAllocation;
            resourceInputs["enableEndpointIndependentMapping"] = args?.enableEndpointIndependentMapping;
            resourceInputs["endpointTypes"] = args?.endpointTypes;
            resourceInputs["icmpIdleTimeoutSec"] = args?.icmpIdleTimeoutSec;
            resourceInputs["initialNatIps"] = args?.initialNatIps;
            resourceInputs["logConfig"] = args?.logConfig;
            resourceInputs["maxPortsPerVm"] = args?.maxPortsPerVm;
            resourceInputs["minPortsPerVm"] = args?.minPortsPerVm;
            resourceInputs["name"] = args?.name;
            resourceInputs["nat64Subnetworks"] = args?.nat64Subnetworks;
            resourceInputs["natIpAllocateOption"] = args?.natIpAllocateOption;
            resourceInputs["natIps"] = args?.natIps;
            resourceInputs["project"] = args?.project;
            resourceInputs["region"] = args?.region;
            resourceInputs["router"] = args?.router;
            resourceInputs["rules"] = args?.rules;
            resourceInputs["sourceSubnetworkIpRangesToNat"] = args?.sourceSubnetworkIpRangesToNat;
            resourceInputs["sourceSubnetworkIpRangesToNat64"] = args?.sourceSubnetworkIpRangesToNat64;
            resourceInputs["subnetworks"] = args?.subnetworks;
            resourceInputs["tcpEstablishedIdleTimeoutSec"] = args?.tcpEstablishedIdleTimeoutSec;
            resourceInputs["tcpTimeWaitTimeoutSec"] = args?.tcpTimeWaitTimeoutSec;
            resourceInputs["tcpTransitoryIdleTimeoutSec"] = args?.tcpTransitoryIdleTimeoutSec;
            resourceInputs["type"] = args?.type;
            resourceInputs["udpIdleTimeoutSec"] = args?.udpIdleTimeoutSec;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        super(RouterNat.__pulumiType, name, resourceInputs, opts);
    }
}
exports.RouterNat = RouterNat;
/** @internal */
RouterNat.__pulumiType = 'gcp:compute/routerNat:RouterNat';
//# sourceMappingURL=routerNat.js.map