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

com.pulumi.gcp.vpcaccess.kotlin.Connector.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.vpcaccess.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.vpcaccess.kotlin.outputs.ConnectorSubnet
import com.pulumi.gcp.vpcaccess.kotlin.outputs.ConnectorSubnet.Companion.toKotlin
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
import kotlin.collections.List

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

    public var args: ConnectorArgs = ConnectorArgs()

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

/**
 * Serverless VPC Access connector resource.
 * To get more information about Connector, see:
 * * [API documentation](https://cloud.google.com/vpc/docs/reference/vpcaccess/rest/v1/projects.locations.connectors)
 * * How-to Guides
 *     * [Configuring Serverless VPC Access](https://cloud.google.com/vpc/docs/configure-serverless-vpc-access)
 * ## Example Usage
 * ### Vpc Access Connector
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const connector = new gcp.vpcaccess.Connector("connector", {
 *     name: "vpc-con",
 *     ipCidrRange: "10.8.0.0/28",
 *     network: "default",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * connector = gcp.vpcaccess.Connector("connector",
 *     name="vpc-con",
 *     ip_cidr_range="10.8.0.0/28",
 *     network="default")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var connector = new Gcp.VpcAccess.Connector("connector", new()
 *     {
 *         Name = "vpc-con",
 *         IpCidrRange = "10.8.0.0/28",
 *         Network = "default",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/vpcaccess"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := vpcaccess.NewConnector(ctx, "connector", &vpcaccess.ConnectorArgs{
 * 			Name:        pulumi.String("vpc-con"),
 * 			IpCidrRange: pulumi.String("10.8.0.0/28"),
 * 			Network:     pulumi.String("default"),
 * 		})
 * 		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.vpcaccess.Connector;
 * import com.pulumi.gcp.vpcaccess.ConnectorArgs;
 * 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 connector = new Connector("connector", ConnectorArgs.builder()
 *             .name("vpc-con")
 *             .ipCidrRange("10.8.0.0/28")
 *             .network("default")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   connector:
 *     type: gcp:vpcaccess:Connector
 *     properties:
 *       name: vpc-con
 *       ipCidrRange: 10.8.0.0/28
 *       network: default
 * ```
 * 
 * ### Vpc Access Connector Shared Vpc
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const customTestNetwork = new gcp.compute.Network("custom_test", {
 *     name: "vpc-con",
 *     autoCreateSubnetworks: false,
 * });
 * const customTest = new gcp.compute.Subnetwork("custom_test", {
 *     name: "vpc-con",
 *     ipCidrRange: "10.2.0.0/28",
 *     region: "us-central1",
 *     network: customTestNetwork.id,
 * });
 * const connector = new gcp.vpcaccess.Connector("connector", {
 *     name: "vpc-con",
 *     subnet: {
 *         name: customTest.name,
 *     },
 *     machineType: "e2-standard-4",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * custom_test_network = gcp.compute.Network("custom_test",
 *     name="vpc-con",
 *     auto_create_subnetworks=False)
 * custom_test = gcp.compute.Subnetwork("custom_test",
 *     name="vpc-con",
 *     ip_cidr_range="10.2.0.0/28",
 *     region="us-central1",
 *     network=custom_test_network.id)
 * connector = gcp.vpcaccess.Connector("connector",
 *     name="vpc-con",
 *     subnet=gcp.vpcaccess.ConnectorSubnetArgs(
 *         name=custom_test.name,
 *     ),
 *     machine_type="e2-standard-4")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var customTestNetwork = new Gcp.Compute.Network("custom_test", new()
 *     {
 *         Name = "vpc-con",
 *         AutoCreateSubnetworks = false,
 *     });
 *     var customTest = new Gcp.Compute.Subnetwork("custom_test", new()
 *     {
 *         Name = "vpc-con",
 *         IpCidrRange = "10.2.0.0/28",
 *         Region = "us-central1",
 *         Network = customTestNetwork.Id,
 *     });
 *     var connector = new Gcp.VpcAccess.Connector("connector", new()
 *     {
 *         Name = "vpc-con",
 *         Subnet = new Gcp.VpcAccess.Inputs.ConnectorSubnetArgs
 *         {
 *             Name = customTest.Name,
 *         },
 *         MachineType = "e2-standard-4",
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/vpcaccess"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		customTestNetwork, err := compute.NewNetwork(ctx, "custom_test", &compute.NetworkArgs{
 * 			Name:                  pulumi.String("vpc-con"),
 * 			AutoCreateSubnetworks: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		customTest, err := compute.NewSubnetwork(ctx, "custom_test", &compute.SubnetworkArgs{
 * 			Name:        pulumi.String("vpc-con"),
 * 			IpCidrRange: pulumi.String("10.2.0.0/28"),
 * 			Region:      pulumi.String("us-central1"),
 * 			Network:     customTestNetwork.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = vpcaccess.NewConnector(ctx, "connector", &vpcaccess.ConnectorArgs{
 * 			Name: pulumi.String("vpc-con"),
 * 			Subnet: &vpcaccess.ConnectorSubnetArgs{
 * 				Name: customTest.Name,
 * 			},
 * 			MachineType: pulumi.String("e2-standard-4"),
 * 		})
 * 		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.vpcaccess.Connector;
 * import com.pulumi.gcp.vpcaccess.ConnectorArgs;
 * import com.pulumi.gcp.vpcaccess.inputs.ConnectorSubnetArgs;
 * 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 customTestNetwork = new Network("customTestNetwork", NetworkArgs.builder()
 *             .name("vpc-con")
 *             .autoCreateSubnetworks(false)
 *             .build());
 *         var customTest = new Subnetwork("customTest", SubnetworkArgs.builder()
 *             .name("vpc-con")
 *             .ipCidrRange("10.2.0.0/28")
 *             .region("us-central1")
 *             .network(customTestNetwork.id())
 *             .build());
 *         var connector = new Connector("connector", ConnectorArgs.builder()
 *             .name("vpc-con")
 *             .subnet(ConnectorSubnetArgs.builder()
 *                 .name(customTest.name())
 *                 .build())
 *             .machineType("e2-standard-4")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   connector:
 *     type: gcp:vpcaccess:Connector
 *     properties:
 *       name: vpc-con
 *       subnet:
 *         name: ${customTest.name}
 *       machineType: e2-standard-4
 *   customTest:
 *     type: gcp:compute:Subnetwork
 *     name: custom_test
 *     properties:
 *       name: vpc-con
 *       ipCidrRange: 10.2.0.0/28
 *       region: us-central1
 *       network: ${customTestNetwork.id}
 *   customTestNetwork:
 *     type: gcp:compute:Network
 *     name: custom_test
 *     properties:
 *       name: vpc-con
 *       autoCreateSubnetworks: false
 * ```
 * 
 * ## Import
 * Connector can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{region}}/connectors/{{name}}`
 * * `{{project}}/{{region}}/{{name}}`
 * * `{{region}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Connector can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:vpcaccess/connector:Connector default projects/{{project}}/locations/{{region}}/connectors/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:vpcaccess/connector:Connector default {{project}}/{{region}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:vpcaccess/connector:Connector default {{region}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:vpcaccess/connector:Connector default {{name}}
 * ```
 */
public class Connector internal constructor(
    override val javaResource: com.pulumi.gcp.vpcaccess.Connector,
) : KotlinCustomResource(javaResource, ConnectorMapper) {
    /**
     * List of projects using the connector.
     */
    public val connectedProjects: Output>
        get() = javaResource.connectedProjects().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The range of internal addresses that follows RFC 4632 notation. Example: `10.132.0.0/28`.
     */
    public val ipCidrRange: Output?
        get() = javaResource.ipCidrRange().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Machine type of VM Instance underlying connector. Default is e2-micro
     */
    public val machineType: Output?
        get() = javaResource.machineType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Maximum value of instances in autoscaling group underlying the connector. Value must be between 3 and 10, inclusive. Must be
     * higher than the value specified by min_instances.
     */
    public val maxInstances: Output
        get() = javaResource.maxInstances().applyValue({ args0 -> args0 })

    /**
     * Maximum throughput of the connector in Mbps, must be greater than `min_throughput`. Default is 300. Refers to the expected throughput
     * when using an e2-micro machine type. Value must be a multiple of 100 from 300 through 1000. Must be higher than the value specified by
     * min_throughput. If both max_throughput and max_instances are provided, max_instances takes precedence over max_throughput. The use of
     * max_throughput is discouraged in favor of max_instances.
     */
    public val maxThroughput: Output?
        get() = javaResource.maxThroughput().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Minimum value of instances in autoscaling group underlying the connector. Value must be between 2 and 9, inclusive. Must be
     * lower than the value specified by max_instances.
     */
    public val minInstances: Output
        get() = javaResource.minInstances().applyValue({ args0 -> args0 })

    /**
     * Minimum throughput of the connector in Mbps. Default and min is 200. Refers to the expected throughput when using an e2-micro machine type.
     * Value must be a multiple of 100 from 200 through 900. Must be lower than the value specified by max_throughput. If both min_throughput and
     * min_instances are provided, min_instances takes precedence over min_throughput. The use of min_throughput is discouraged in favor of min_instances.
     */
    public val minThroughput: Output?
        get() = javaResource.minThroughput().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The name of the resource (Max 25 characters).
     * - - -
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Name or self_link of the VPC network. Required if `ip_cidr_range` is set.
     */
    public val network: Output
        get() = javaResource.network().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 })

    /**
     * Region where the VPC Access connector resides. If it is not provided, the provider region is used.
     */
    public val region: Output
        get() = javaResource.region().applyValue({ args0 -> args0 })

    /**
     * The fully qualified name of this VPC connector
     */
    public val selfLink: Output
        get() = javaResource.selfLink().applyValue({ args0 -> args0 })

    /**
     * State of the VPC access connector.
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * The subnet in which to house the connector
     * Structure is documented below.
     */
    public val subnet: Output?
        get() = javaResource.subnet().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            }).orElse(null)
        })
}

public object ConnectorMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.vpcaccess.Connector::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy