All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.compute.kotlin.NetworkEndpointGroup.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.compute.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit

/**
 * Builder for [NetworkEndpointGroup].
 */
@PulumiTagMarker
public class NetworkEndpointGroupResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: NetworkEndpointGroupArgs = NetworkEndpointGroupArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend NetworkEndpointGroupArgsBuilder.() -> Unit) {
        val builder = NetworkEndpointGroupArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): NetworkEndpointGroup {
        val builtJavaResource = com.pulumi.gcp.compute.NetworkEndpointGroup(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return NetworkEndpointGroup(builtJavaResource)
    }
}

/**
 * Network endpoint groups (NEGs) are zonal resources that represent
 * collections of IP address and port combinations for GCP resources within a
 * single subnet. Each IP address and port combination is called a network
 * endpoint.
 * Network endpoint groups can be used as backends in backend services for
 * HTTP(S), TCP proxy, and SSL proxy load balancers. You cannot use NEGs as a
 * backend with internal load balancers. Because NEG backends allow you to
 * specify IP addresses and ports, you can distribute traffic in a granular
 * fashion among applications or containers running within VM instances.
 * Recreating a network endpoint group that's in use by another resource will give a
 * `resourceInUseByAnotherResource` error. Use `lifecycle.create_before_destroy`
 * to avoid this type of error.
 * To get more information about NetworkEndpointGroup, see:
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/networkEndpointGroups)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/load-balancing/docs/negs/)
 * ## Example Usage
 * ### Network Endpoint Group
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.compute.Network("default", {
 *     name: "neg-network",
 *     autoCreateSubnetworks: false,
 * });
 * const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
 *     name: "neg-subnetwork",
 *     ipCidrRange: "10.0.0.0/16",
 *     region: "us-central1",
 *     network: _default.id,
 * });
 * const neg = new gcp.compute.NetworkEndpointGroup("neg", {
 *     name: "my-lb-neg",
 *     network: _default.id,
 *     subnetwork: defaultSubnetwork.id,
 *     defaultPort: 90,
 *     zone: "us-central1-a",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.compute.Network("default",
 *     name="neg-network",
 *     auto_create_subnetworks=False)
 * default_subnetwork = gcp.compute.Subnetwork("default",
 *     name="neg-subnetwork",
 *     ip_cidr_range="10.0.0.0/16",
 *     region="us-central1",
 *     network=default.id)
 * neg = gcp.compute.NetworkEndpointGroup("neg",
 *     name="my-lb-neg",
 *     network=default.id,
 *     subnetwork=default_subnetwork.id,
 *     default_port=90,
 *     zone="us-central1-a")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.Compute.Network("default", new()
 *     {
 *         Name = "neg-network",
 *         AutoCreateSubnetworks = false,
 *     });
 *     var defaultSubnetwork = new Gcp.Compute.Subnetwork("default", new()
 *     {
 *         Name = "neg-subnetwork",
 *         IpCidrRange = "10.0.0.0/16",
 *         Region = "us-central1",
 *         Network = @default.Id,
 *     });
 *     var neg = new Gcp.Compute.NetworkEndpointGroup("neg", new()
 *     {
 *         Name = "my-lb-neg",
 *         Network = @default.Id,
 *         Subnetwork = defaultSubnetwork.Id,
 *         DefaultPort = 90,
 *         Zone = "us-central1-a",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
 * 			Name:                  pulumi.String("neg-network"),
 * 			AutoCreateSubnetworks: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		defaultSubnetwork, err := compute.NewSubnetwork(ctx, "default", &compute.SubnetworkArgs{
 * 			Name:        pulumi.String("neg-subnetwork"),
 * 			IpCidrRange: pulumi.String("10.0.0.0/16"),
 * 			Region:      pulumi.String("us-central1"),
 * 			Network:     _default.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = compute.NewNetworkEndpointGroup(ctx, "neg", &compute.NetworkEndpointGroupArgs{
 * 			Name:        pulumi.String("my-lb-neg"),
 * 			Network:     _default.ID(),
 * 			Subnetwork:  defaultSubnetwork.ID(),
 * 			DefaultPort: pulumi.Int(90),
 * 			Zone:        pulumi.String("us-central1-a"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.compute.Subnetwork;
 * import com.pulumi.gcp.compute.SubnetworkArgs;
 * import com.pulumi.gcp.compute.NetworkEndpointGroup;
 * import com.pulumi.gcp.compute.NetworkEndpointGroupArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var default_ = new Network("default", NetworkArgs.builder()
 *             .name("neg-network")
 *             .autoCreateSubnetworks(false)
 *             .build());
 *         var defaultSubnetwork = new Subnetwork("defaultSubnetwork", SubnetworkArgs.builder()
 *             .name("neg-subnetwork")
 *             .ipCidrRange("10.0.0.0/16")
 *             .region("us-central1")
 *             .network(default_.id())
 *             .build());
 *         var neg = new NetworkEndpointGroup("neg", NetworkEndpointGroupArgs.builder()
 *             .name("my-lb-neg")
 *             .network(default_.id())
 *             .subnetwork(defaultSubnetwork.id())
 *             .defaultPort("90")
 *             .zone("us-central1-a")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   neg:
 *     type: gcp:compute:NetworkEndpointGroup
 *     properties:
 *       name: my-lb-neg
 *       network: ${default.id}
 *       subnetwork: ${defaultSubnetwork.id}
 *       defaultPort: '90'
 *       zone: us-central1-a
 *   default:
 *     type: gcp:compute:Network
 *     properties:
 *       name: neg-network
 *       autoCreateSubnetworks: false
 *   defaultSubnetwork:
 *     type: gcp:compute:Subnetwork
 *     name: default
 *     properties:
 *       name: neg-subnetwork
 *       ipCidrRange: 10.0.0.0/16
 *       region: us-central1
 *       network: ${default.id}
 * ```
 * 
 * ### Network Endpoint Group Non Gcp
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.compute.Network("default", {name: "neg-network"});
 * const neg = new gcp.compute.NetworkEndpointGroup("neg", {
 *     name: "my-lb-neg",
 *     network: _default.id,
 *     defaultPort: 90,
 *     zone: "us-central1-a",
 *     networkEndpointType: "NON_GCP_PRIVATE_IP_PORT",
 * });
 * const default_endpoint = new gcp.compute.NetworkEndpoint("default-endpoint", {
 *     networkEndpointGroup: neg.name,
 *     port: neg.defaultPort,
 *     ipAddress: "127.0.0.1",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.compute.Network("default", name="neg-network")
 * neg = gcp.compute.NetworkEndpointGroup("neg",
 *     name="my-lb-neg",
 *     network=default.id,
 *     default_port=90,
 *     zone="us-central1-a",
 *     network_endpoint_type="NON_GCP_PRIVATE_IP_PORT")
 * default_endpoint = gcp.compute.NetworkEndpoint("default-endpoint",
 *     network_endpoint_group=neg.name,
 *     port=neg.default_port,
 *     ip_address="127.0.0.1")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.Compute.Network("default", new()
 *     {
 *         Name = "neg-network",
 *     });
 *     var neg = new Gcp.Compute.NetworkEndpointGroup("neg", new()
 *     {
 *         Name = "my-lb-neg",
 *         Network = @default.Id,
 *         DefaultPort = 90,
 *         Zone = "us-central1-a",
 *         NetworkEndpointType = "NON_GCP_PRIVATE_IP_PORT",
 *     });
 *     var default_endpoint = new Gcp.Compute.NetworkEndpoint("default-endpoint", new()
 *     {
 *         NetworkEndpointGroup = neg.Name,
 *         Port = neg.DefaultPort,
 *         IpAddress = "127.0.0.1",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := compute.NewNetwork(ctx, "default", &compute.NetworkArgs{
 * 			Name: pulumi.String("neg-network"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		neg, err := compute.NewNetworkEndpointGroup(ctx, "neg", &compute.NetworkEndpointGroupArgs{
 * 			Name:                pulumi.String("my-lb-neg"),
 * 			Network:             _default.ID(),
 * 			DefaultPort:         pulumi.Int(90),
 * 			Zone:                pulumi.String("us-central1-a"),
 * 			NetworkEndpointType: pulumi.String("NON_GCP_PRIVATE_IP_PORT"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = compute.NewNetworkEndpoint(ctx, "default-endpoint", &compute.NetworkEndpointArgs{
 * 			NetworkEndpointGroup: neg.Name,
 * 			Port:                 neg.DefaultPort,
 * 			IpAddress:            pulumi.String("127.0.0.1"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.compute.NetworkEndpointGroup;
 * import com.pulumi.gcp.compute.NetworkEndpointGroupArgs;
 * import com.pulumi.gcp.compute.NetworkEndpoint;
 * import com.pulumi.gcp.compute.NetworkEndpointArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 *     public static void stack(Context ctx) {
 *         var default_ = new Network("default", NetworkArgs.builder()
 *             .name("neg-network")
 *             .build());
 *         var neg = new NetworkEndpointGroup("neg", NetworkEndpointGroupArgs.builder()
 *             .name("my-lb-neg")
 *             .network(default_.id())
 *             .defaultPort("90")
 *             .zone("us-central1-a")
 *             .networkEndpointType("NON_GCP_PRIVATE_IP_PORT")
 *             .build());
 *         var default_endpoint = new NetworkEndpoint("default-endpoint", NetworkEndpointArgs.builder()
 *             .networkEndpointGroup(neg.name())
 *             .port(neg.defaultPort())
 *             .ipAddress("127.0.0.1")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   neg:
 *     type: gcp:compute:NetworkEndpointGroup
 *     properties:
 *       name: my-lb-neg
 *       network: ${default.id}
 *       defaultPort: '90'
 *       zone: us-central1-a
 *       networkEndpointType: NON_GCP_PRIVATE_IP_PORT
 *   default-endpoint:
 *     type: gcp:compute:NetworkEndpoint
 *     properties:
 *       networkEndpointGroup: ${neg.name}
 *       port: ${neg.defaultPort}
 *       ipAddress: 127.0.0.1
 *   default:
 *     type: gcp:compute:Network
 *     properties:
 *       name: neg-network
 * ```
 * 
 * ## Import
 * NetworkEndpointGroup can be imported using any of these accepted formats:
 * * `projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}`
 * * `{{project}}/{{zone}}/{{name}}`
 * * `{{zone}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, NetworkEndpointGroup can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default {{project}}/{{zone}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default {{zone}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/networkEndpointGroup:NetworkEndpointGroup default {{name}}
 * ```
 */
public class NetworkEndpointGroup internal constructor(
    override val javaResource: com.pulumi.gcp.compute.NetworkEndpointGroup,
) : KotlinCustomResource(javaResource, NetworkEndpointGroupMapper) {
    /**
     * The default port used if the port number is not specified in the
     * network endpoint.
     */
    public val defaultPort: Output?
        get() = javaResource.defaultPort().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * An optional description of this resource. Provide this property when
     * you create the resource.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Name of the resource; provided by the client when the resource is
     * created. The name must be 1-63 characters long, and comply with
     * RFC1035. Specifically, the name must be 1-63 characters long and match
     * the regular expression `a-z?` which means the
     * first character must be a lowercase letter, and all following
     * characters must be a dash, lowercase letter, or digit, except the last
     * character, which cannot be a dash.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The network to which all network endpoints in the NEG belong.
     * Uses "default" project network if unspecified.
     * - - -
     */
    public val network: Output
        get() = javaResource.network().applyValue({ args0 -> args0 })

    /**
     * Type of network endpoints in this network endpoint group.
     * NON_GCP_PRIVATE_IP_PORT is used for hybrid connectivity network
     * endpoint groups (see https://cloud.google.com/load-balancing/docs/hybrid).
     * Note that NON_GCP_PRIVATE_IP_PORT can only be used with Backend Services
     * that 1) have the following load balancing schemes: EXTERNAL, EXTERNAL_MANAGED,
     * INTERNAL_MANAGED, and INTERNAL_SELF_MANAGED and 2) support the RATE or
     * CONNECTION balancing modes.
     * Possible values include: GCE_VM_IP, GCE_VM_IP_PORT, NON_GCP_PRIVATE_IP_PORT, INTERNET_IP_PORT, INTERNET_FQDN_PORT, SERVERLESS, and PRIVATE_SERVICE_CONNECT.
     * Default value is `GCE_VM_IP_PORT`.
     * Possible values are: `GCE_VM_IP`, `GCE_VM_IP_PORT`, `NON_GCP_PRIVATE_IP_PORT`, `INTERNET_IP_PORT`, `INTERNET_FQDN_PORT`, `SERVERLESS`, `PRIVATE_SERVICE_CONNECT`.
     */
    public val networkEndpointType: Output?
        get() = javaResource.networkEndpointType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The URI of the created resource.
     */
    public val selfLink: Output
        get() = javaResource.selfLink().applyValue({ args0 -> args0 })

    /**
     * Number of network endpoints in the network endpoint group.
     */
    public val size: Output
        get() = javaResource.size().applyValue({ args0 -> args0 })

    /**
     * Optional subnetwork to which all network endpoints in the NEG belong.
     */
    public val subnetwork: Output?
        get() = javaResource.subnetwork().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Zone where the network endpoint group is located.
     */
    public val zone: Output
        get() = javaResource.zone().applyValue({ args0 -> args0 })
}

public object NetworkEndpointGroupMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.compute.NetworkEndpointGroup::class == javaResource::class

    override fun map(javaResource: Resource): NetworkEndpointGroup = NetworkEndpointGroup(
        javaResource
            as com.pulumi.gcp.compute.NetworkEndpointGroup,
    )
}

/**
 * @see [NetworkEndpointGroup].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [NetworkEndpointGroup].
 */
public suspend fun networkEndpointGroup(
    name: String,
    block: suspend NetworkEndpointGroupResourceBuilder.() -> Unit,
): NetworkEndpointGroup {
    val builder = NetworkEndpointGroupResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [NetworkEndpointGroup].
 * @param name The _unique_ name of the resulting resource.
 */
public fun networkEndpointGroup(name: String): NetworkEndpointGroup {
    val builder = NetworkEndpointGroupResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy