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

com.pulumi.gcp.compute.kotlin.Network.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 [Network].
 */
@PulumiTagMarker
public class NetworkResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: NetworkArgs = NetworkArgs()

    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 NetworkArgsBuilder.() -> Unit) {
        val builder = NetworkArgsBuilder()
        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(): Network {
        val builtJavaResource = com.pulumi.gcp.compute.Network(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Network(builtJavaResource)
    }
}

/**
 * Manages a VPC network or legacy network resource on GCP.
 * To get more information about Network, see:
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/networks)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/vpc/docs/vpc)
 * ## Example Usage
 * ### Network Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const vpcNetwork = new gcp.compute.Network("vpc_network", {name: "vpc-network"});
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * vpc_network = gcp.compute.Network("vpc_network", name="vpc-network")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var vpcNetwork = new Gcp.Compute.Network("vpc_network", new()
 *     {
 *         Name = "vpc-network",
 *     });
 * });
 * ```
 * ```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, "vpc_network", &compute.NetworkArgs{
 * 			Name: pulumi.String("vpc-network"),
 * 		})
 * 		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 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 vpcNetwork = new Network("vpcNetwork", NetworkArgs.builder()
 *             .name("vpc-network")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   vpcNetwork:
 *     type: gcp:compute:Network
 *     name: vpc_network
 *     properties:
 *       name: vpc-network
 * ```
 * 
 * ### Network Custom Mtu
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const vpcNetwork = new gcp.compute.Network("vpc_network", {
 *     project: "my-project-name",
 *     name: "vpc-network",
 *     autoCreateSubnetworks: true,
 *     mtu: 1460,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * vpc_network = gcp.compute.Network("vpc_network",
 *     project="my-project-name",
 *     name="vpc-network",
 *     auto_create_subnetworks=True,
 *     mtu=1460)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var vpcNetwork = new Gcp.Compute.Network("vpc_network", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "vpc-network",
 *         AutoCreateSubnetworks = true,
 *         Mtu = 1460,
 *     });
 * });
 * ```
 * ```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, "vpc_network", &compute.NetworkArgs{
 * 			Project:               pulumi.String("my-project-name"),
 * 			Name:                  pulumi.String("vpc-network"),
 * 			AutoCreateSubnetworks: pulumi.Bool(true),
 * 			Mtu:                   pulumi.Int(1460),
 * 		})
 * 		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 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 vpcNetwork = new Network("vpcNetwork", NetworkArgs.builder()
 *             .project("my-project-name")
 *             .name("vpc-network")
 *             .autoCreateSubnetworks(true)
 *             .mtu(1460)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   vpcNetwork:
 *     type: gcp:compute:Network
 *     name: vpc_network
 *     properties:
 *       project: my-project-name
 *       name: vpc-network
 *       autoCreateSubnetworks: true
 *       mtu: 1460
 * ```
 * 
 * ### Network Custom Firewall Enforcement Order
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const vpcNetwork = new gcp.compute.Network("vpc_network", {
 *     project: "my-project-name",
 *     name: "vpc-network",
 *     autoCreateSubnetworks: true,
 *     networkFirewallPolicyEnforcementOrder: "BEFORE_CLASSIC_FIREWALL",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * vpc_network = gcp.compute.Network("vpc_network",
 *     project="my-project-name",
 *     name="vpc-network",
 *     auto_create_subnetworks=True,
 *     network_firewall_policy_enforcement_order="BEFORE_CLASSIC_FIREWALL")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var vpcNetwork = new Gcp.Compute.Network("vpc_network", new()
 *     {
 *         Project = "my-project-name",
 *         Name = "vpc-network",
 *         AutoCreateSubnetworks = true,
 *         NetworkFirewallPolicyEnforcementOrder = "BEFORE_CLASSIC_FIREWALL",
 *     });
 * });
 * ```
 * ```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, "vpc_network", &compute.NetworkArgs{
 * 			Project:                               pulumi.String("my-project-name"),
 * 			Name:                                  pulumi.String("vpc-network"),
 * 			AutoCreateSubnetworks:                 pulumi.Bool(true),
 * 			NetworkFirewallPolicyEnforcementOrder: pulumi.String("BEFORE_CLASSIC_FIREWALL"),
 * 		})
 * 		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 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 vpcNetwork = new Network("vpcNetwork", NetworkArgs.builder()
 *             .project("my-project-name")
 *             .name("vpc-network")
 *             .autoCreateSubnetworks(true)
 *             .networkFirewallPolicyEnforcementOrder("BEFORE_CLASSIC_FIREWALL")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   vpcNetwork:
 *     type: gcp:compute:Network
 *     name: vpc_network
 *     properties:
 *       project: my-project-name
 *       name: vpc-network
 *       autoCreateSubnetworks: true
 *       networkFirewallPolicyEnforcementOrder: BEFORE_CLASSIC_FIREWALL
 * ```
 * 
 * ## Import
 * Network can be imported using any of these accepted formats:
 * * `projects/{{project}}/global/networks/{{name}}`
 * * `{{project}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Network can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:compute/network:Network default projects/{{project}}/global/networks/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/network:Network default {{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/network:Network default {{name}}
 * ```
 */
public class Network internal constructor(
    override val javaResource: com.pulumi.gcp.compute.Network,
) : KotlinCustomResource(javaResource, NetworkMapper) {
    /**
     * When set to `true`, the network is created in "auto subnet mode" and
     * it will create a subnet for each region automatically across the
     * `10.128.0.0/9` address range.
     * When set to `false`, the network is created in "custom subnet mode" so
     * the user can explicitly connect subnetwork resources.
     */
    public val autoCreateSubnetworks: Output?
        get() = javaResource.autoCreateSubnetworks().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * If set to `true`, default routes (`0.0.0.0/0`) will be deleted
     * immediately after network creation. Defaults to `false`.
     */
    public val deleteDefaultRoutesOnCreate: Output?
        get() = javaResource.deleteDefaultRoutesOnCreate().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * An optional description of this resource. The resource must be
     * recreated to modify this field.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Enable ULA internal ipv6 on this network. Enabling this feature will assign
     * a /48 from google defined ULA prefix fd20::/20.
     */
    public val enableUlaInternalIpv6: Output?
        get() = javaResource.enableUlaInternalIpv6().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The gateway address for default routing out of the network. This value
     * is selected by GCP.
     */
    public val gatewayIpv4: Output
        get() = javaResource.gatewayIpv4().applyValue({ args0 -> args0 })

    /**
     * When enabling ula internal ipv6, caller optionally can specify the /48 range
     * they want from the google defined ULA prefix fd20::/20. The input must be a
     * valid /48 ULA IPv6 address and must be within the fd20::/20. Operation will
     * fail if the speficied /48 is already in used by another resource.
     * If the field is not speficied, then a /48 range will be randomly allocated from fd20::/20 and returned via this field.
     */
    public val internalIpv6Range: Output
        get() = javaResource.internalIpv6Range().applyValue({ args0 -> args0 })

    /**
     * Maximum Transmission Unit in bytes. The default value is 1460 bytes.
     * The minimum value for this field is 1300 and the maximum value is 8896 bytes (jumbo frames).
     * Note that packets larger than 1500 bytes (standard Ethernet) can be subject to TCP-MSS clamping or dropped
     * with an ICMP `Fragmentation-Needed` message if the packets are routed to the Internet or other VPCs
     * with varying MTUs.
     */
    public val mtu: Output
        get() = javaResource.mtu().applyValue({ args0 -> args0 })

    /**
     * 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 })

    /**
     * Set the order that Firewall Rules and Firewall Policies are evaluated.
     * Default value is `AFTER_CLASSIC_FIREWALL`.
     * Possible values are: `BEFORE_CLASSIC_FIREWALL`, `AFTER_CLASSIC_FIREWALL`.
     */
    public val networkFirewallPolicyEnforcementOrder: Output?
        get() = javaResource.networkFirewallPolicyEnforcementOrder().applyValue({ args0 ->
            args0.map({ args0 -> args0 }).orElse(null)
        })

    /**
     * The unique identifier for the resource. This identifier is defined by the server.
     */
    public val numericId: Output
        get() = javaResource.numericId().applyValue({ args0 -> args0 })

    /**
     * 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 network-wide routing mode to use. If set to `REGIONAL`, this
     * network's cloud routers will only advertise routes with subnetworks
     * of this network in the same region as the router. If set to `GLOBAL`,
     * this network's cloud routers will advertise routes with all
     * subnetworks of this network, across regions.
     * Possible values are: `REGIONAL`, `GLOBAL`.
     */
    public val routingMode: Output
        get() = javaResource.routingMode().applyValue({ args0 -> args0 })

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

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy