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

com.pulumi.gcp.cloudbuild.kotlin.WorkerPool.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.cloudbuild.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.cloudbuild.kotlin.outputs.WorkerPoolNetworkConfig
import com.pulumi.gcp.cloudbuild.kotlin.outputs.WorkerPoolWorkerConfig
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.Any
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.gcp.cloudbuild.kotlin.outputs.WorkerPoolNetworkConfig.Companion.toKotlin as workerPoolNetworkConfigToKotlin
import com.pulumi.gcp.cloudbuild.kotlin.outputs.WorkerPoolWorkerConfig.Companion.toKotlin as workerPoolWorkerConfigToKotlin

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

    public var args: WorkerPoolArgs = WorkerPoolArgs()

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

/**
 * Definition of custom Cloud Build WorkerPools for running jobs with custom configuration and custom networking.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const pool = new gcp.cloudbuild.WorkerPool("pool", {
 *     name: "my-pool",
 *     location: "europe-west1",
 *     workerConfig: {
 *         diskSizeGb: 100,
 *         machineType: "e2-standard-4",
 *         noExternalIp: false,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * pool = gcp.cloudbuild.WorkerPool("pool",
 *     name="my-pool",
 *     location="europe-west1",
 *     worker_config=gcp.cloudbuild.WorkerPoolWorkerConfigArgs(
 *         disk_size_gb=100,
 *         machine_type="e2-standard-4",
 *         no_external_ip=False,
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var pool = new Gcp.CloudBuild.WorkerPool("pool", new()
 *     {
 *         Name = "my-pool",
 *         Location = "europe-west1",
 *         WorkerConfig = new Gcp.CloudBuild.Inputs.WorkerPoolWorkerConfigArgs
 *         {
 *             DiskSizeGb = 100,
 *             MachineType = "e2-standard-4",
 *             NoExternalIp = false,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudbuild"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := cloudbuild.NewWorkerPool(ctx, "pool", &cloudbuild.WorkerPoolArgs{
 * 			Name:     pulumi.String("my-pool"),
 * 			Location: pulumi.String("europe-west1"),
 * 			WorkerConfig: &cloudbuild.WorkerPoolWorkerConfigArgs{
 * 				DiskSizeGb:   pulumi.Int(100),
 * 				MachineType:  pulumi.String("e2-standard-4"),
 * 				NoExternalIp: pulumi.Bool(false),
 * 			},
 * 		})
 * 		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.cloudbuild.WorkerPool;
 * import com.pulumi.gcp.cloudbuild.WorkerPoolArgs;
 * import com.pulumi.gcp.cloudbuild.inputs.WorkerPoolWorkerConfigArgs;
 * 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 pool = new WorkerPool("pool", WorkerPoolArgs.builder()
 *             .name("my-pool")
 *             .location("europe-west1")
 *             .workerConfig(WorkerPoolWorkerConfigArgs.builder()
 *                 .diskSizeGb(100)
 *                 .machineType("e2-standard-4")
 *                 .noExternalIp(false)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   pool:
 *     type: gcp:cloudbuild:WorkerPool
 *     properties:
 *       name: my-pool
 *       location: europe-west1
 *       workerConfig:
 *         diskSizeGb: 100
 *         machineType: e2-standard-4
 *         noExternalIp: false
 * ```
 * 
 * ### Network Config
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const servicenetworking = new gcp.projects.Service("servicenetworking", {
 *     service: "servicenetworking.googleapis.com",
 *     disableOnDestroy: false,
 * });
 * const network = new gcp.compute.Network("network", {
 *     name: "my-network",
 *     autoCreateSubnetworks: false,
 * });
 * const workerRange = new gcp.compute.GlobalAddress("worker_range", {
 *     name: "worker-pool-range",
 *     purpose: "VPC_PEERING",
 *     addressType: "INTERNAL",
 *     prefixLength: 16,
 *     network: network.id,
 * });
 * const workerPoolConn = new gcp.servicenetworking.Connection("worker_pool_conn", {
 *     network: network.id,
 *     service: "servicenetworking.googleapis.com",
 *     reservedPeeringRanges: [workerRange.name],
 * });
 * const pool = new gcp.cloudbuild.WorkerPool("pool", {
 *     name: "my-pool",
 *     location: "europe-west1",
 *     workerConfig: {
 *         diskSizeGb: 100,
 *         machineType: "e2-standard-4",
 *         noExternalIp: false,
 *     },
 *     networkConfig: {
 *         peeredNetwork: network.id,
 *         peeredNetworkIpRange: "/29",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * servicenetworking = gcp.projects.Service("servicenetworking",
 *     service="servicenetworking.googleapis.com",
 *     disable_on_destroy=False)
 * network = gcp.compute.Network("network",
 *     name="my-network",
 *     auto_create_subnetworks=False)
 * worker_range = gcp.compute.GlobalAddress("worker_range",
 *     name="worker-pool-range",
 *     purpose="VPC_PEERING",
 *     address_type="INTERNAL",
 *     prefix_length=16,
 *     network=network.id)
 * worker_pool_conn = gcp.servicenetworking.Connection("worker_pool_conn",
 *     network=network.id,
 *     service="servicenetworking.googleapis.com",
 *     reserved_peering_ranges=[worker_range.name])
 * pool = gcp.cloudbuild.WorkerPool("pool",
 *     name="my-pool",
 *     location="europe-west1",
 *     worker_config=gcp.cloudbuild.WorkerPoolWorkerConfigArgs(
 *         disk_size_gb=100,
 *         machine_type="e2-standard-4",
 *         no_external_ip=False,
 *     ),
 *     network_config=gcp.cloudbuild.WorkerPoolNetworkConfigArgs(
 *         peered_network=network.id,
 *         peered_network_ip_range="/29",
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var servicenetworking = new Gcp.Projects.Service("servicenetworking", new()
 *     {
 *         ServiceName = "servicenetworking.googleapis.com",
 *         DisableOnDestroy = false,
 *     });
 *     var network = new Gcp.Compute.Network("network", new()
 *     {
 *         Name = "my-network",
 *         AutoCreateSubnetworks = false,
 *     });
 *     var workerRange = new Gcp.Compute.GlobalAddress("worker_range", new()
 *     {
 *         Name = "worker-pool-range",
 *         Purpose = "VPC_PEERING",
 *         AddressType = "INTERNAL",
 *         PrefixLength = 16,
 *         Network = network.Id,
 *     });
 *     var workerPoolConn = new Gcp.ServiceNetworking.Connection("worker_pool_conn", new()
 *     {
 *         Network = network.Id,
 *         Service = "servicenetworking.googleapis.com",
 *         ReservedPeeringRanges = new[]
 *         {
 *             workerRange.Name,
 *         },
 *     });
 *     var pool = new Gcp.CloudBuild.WorkerPool("pool", new()
 *     {
 *         Name = "my-pool",
 *         Location = "europe-west1",
 *         WorkerConfig = new Gcp.CloudBuild.Inputs.WorkerPoolWorkerConfigArgs
 *         {
 *             DiskSizeGb = 100,
 *             MachineType = "e2-standard-4",
 *             NoExternalIp = false,
 *         },
 *         NetworkConfig = new Gcp.CloudBuild.Inputs.WorkerPoolNetworkConfigArgs
 *         {
 *             PeeredNetwork = network.Id,
 *             PeeredNetworkIpRange = "/29",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/cloudbuild"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := projects.NewService(ctx, "servicenetworking", &projects.ServiceArgs{
 * 			Service:          pulumi.String("servicenetworking.googleapis.com"),
 * 			DisableOnDestroy: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		network, err := compute.NewNetwork(ctx, "network", &compute.NetworkArgs{
 * 			Name:                  pulumi.String("my-network"),
 * 			AutoCreateSubnetworks: pulumi.Bool(false),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		workerRange, err := compute.NewGlobalAddress(ctx, "worker_range", &compute.GlobalAddressArgs{
 * 			Name:         pulumi.String("worker-pool-range"),
 * 			Purpose:      pulumi.String("VPC_PEERING"),
 * 			AddressType:  pulumi.String("INTERNAL"),
 * 			PrefixLength: pulumi.Int(16),
 * 			Network:      network.ID(),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = servicenetworking.NewConnection(ctx, "worker_pool_conn", &servicenetworking.ConnectionArgs{
 * 			Network: network.ID(),
 * 			Service: pulumi.String("servicenetworking.googleapis.com"),
 * 			ReservedPeeringRanges: pulumi.StringArray{
 * 				workerRange.Name,
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = cloudbuild.NewWorkerPool(ctx, "pool", &cloudbuild.WorkerPoolArgs{
 * 			Name:     pulumi.String("my-pool"),
 * 			Location: pulumi.String("europe-west1"),
 * 			WorkerConfig: &cloudbuild.WorkerPoolWorkerConfigArgs{
 * 				DiskSizeGb:   pulumi.Int(100),
 * 				MachineType:  pulumi.String("e2-standard-4"),
 * 				NoExternalIp: pulumi.Bool(false),
 * 			},
 * 			NetworkConfig: &cloudbuild.WorkerPoolNetworkConfigArgs{
 * 				PeeredNetwork:        network.ID(),
 * 				PeeredNetworkIpRange: pulumi.String("/29"),
 * 			},
 * 		})
 * 		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.projects.Service;
 * import com.pulumi.gcp.projects.ServiceArgs;
 * import com.pulumi.gcp.compute.Network;
 * import com.pulumi.gcp.compute.NetworkArgs;
 * import com.pulumi.gcp.compute.GlobalAddress;
 * import com.pulumi.gcp.compute.GlobalAddressArgs;
 * import com.pulumi.gcp.servicenetworking.Connection;
 * import com.pulumi.gcp.servicenetworking.ConnectionArgs;
 * import com.pulumi.gcp.cloudbuild.WorkerPool;
 * import com.pulumi.gcp.cloudbuild.WorkerPoolArgs;
 * import com.pulumi.gcp.cloudbuild.inputs.WorkerPoolWorkerConfigArgs;
 * import com.pulumi.gcp.cloudbuild.inputs.WorkerPoolNetworkConfigArgs;
 * 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 servicenetworking = new Service("servicenetworking", ServiceArgs.builder()
 *             .service("servicenetworking.googleapis.com")
 *             .disableOnDestroy(false)
 *             .build());
 *         var network = new Network("network", NetworkArgs.builder()
 *             .name("my-network")
 *             .autoCreateSubnetworks(false)
 *             .build());
 *         var workerRange = new GlobalAddress("workerRange", GlobalAddressArgs.builder()
 *             .name("worker-pool-range")
 *             .purpose("VPC_PEERING")
 *             .addressType("INTERNAL")
 *             .prefixLength(16)
 *             .network(network.id())
 *             .build());
 *         var workerPoolConn = new Connection("workerPoolConn", ConnectionArgs.builder()
 *             .network(network.id())
 *             .service("servicenetworking.googleapis.com")
 *             .reservedPeeringRanges(workerRange.name())
 *             .build());
 *         var pool = new WorkerPool("pool", WorkerPoolArgs.builder()
 *             .name("my-pool")
 *             .location("europe-west1")
 *             .workerConfig(WorkerPoolWorkerConfigArgs.builder()
 *                 .diskSizeGb(100)
 *                 .machineType("e2-standard-4")
 *                 .noExternalIp(false)
 *                 .build())
 *             .networkConfig(WorkerPoolNetworkConfigArgs.builder()
 *                 .peeredNetwork(network.id())
 *                 .peeredNetworkIpRange("/29")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   servicenetworking:
 *     type: gcp:projects:Service
 *     properties:
 *       service: servicenetworking.googleapis.com
 *       disableOnDestroy: false
 *   network:
 *     type: gcp:compute:Network
 *     properties:
 *       name: my-network
 *       autoCreateSubnetworks: false
 *   workerRange:
 *     type: gcp:compute:GlobalAddress
 *     name: worker_range
 *     properties:
 *       name: worker-pool-range
 *       purpose: VPC_PEERING
 *       addressType: INTERNAL
 *       prefixLength: 16
 *       network: ${network.id}
 *   workerPoolConn:
 *     type: gcp:servicenetworking:Connection
 *     name: worker_pool_conn
 *     properties:
 *       network: ${network.id}
 *       service: servicenetworking.googleapis.com
 *       reservedPeeringRanges:
 *         - ${workerRange.name}
 *   pool:
 *     type: gcp:cloudbuild:WorkerPool
 *     properties:
 *       name: my-pool
 *       location: europe-west1
 *       workerConfig:
 *         diskSizeGb: 100
 *         machineType: e2-standard-4
 *         noExternalIp: false
 *       networkConfig:
 *         peeredNetwork: ${network.id}
 *         peeredNetworkIpRange: /29
 * ```
 * 
 * ## Import
 * WorkerPool can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/{{location}}/workerPools/{{name}}`
 * * `{{project}}/{{location}}/{{name}}`
 * * `{{location}}/{{name}}`
 * When using the `pulumi import` command, WorkerPool can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:cloudbuild/workerPool:WorkerPool default projects/{{project}}/locations/{{location}}/workerPools/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:cloudbuild/workerPool:WorkerPool default {{project}}/{{location}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:cloudbuild/workerPool:WorkerPool default {{location}}/{{name}}
 * ```
 */
public class WorkerPool internal constructor(
    override val javaResource: com.pulumi.gcp.cloudbuild.WorkerPool,
) : KotlinCustomResource(javaResource, WorkerPoolMapper) {
    /**
     * User specified annotations. See https://google.aip.dev/128#annotations for more details such as format and size
     * limitations. **Note**: This field is non-authoritative, and will only manage the annotations present in your
     * configuration. Please refer to the field `effective_annotations` for all of the annotations present on the resource.
     */
    public val annotations: Output>?
        get() = javaResource.annotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Output only. Time at which the request to create the `WorkerPool` was received.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * Output only. Time at which the request to delete the `WorkerPool` was received.
     */
    public val deleteTime: Output
        get() = javaResource.deleteTime().applyValue({ args0 -> args0 })

    /**
     * A user-specified, human-readable name for the `WorkerPool`. If provided, this value must be 1-63 characters.
     */
    public val displayName: Output?
        get() = javaResource.displayName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    public val effectiveAnnotations: Output>
        get() = javaResource.effectiveAnnotations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The location for the resource
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * User-defined name of the `WorkerPool`.
     * - - -
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Network configuration for the `WorkerPool`. Structure is documented below.
     */
    public val networkConfig: Output?
        get() = javaResource.networkConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> workerPoolNetworkConfigToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The project for the resource
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * Output only. WorkerPool state. Possible values: STATE_UNSPECIFIED, PENDING, APPROVED, REJECTED, CANCELLED
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })

    /**
     * Output only. A unique identifier for the `WorkerPool`.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })

    /**
     * Output only. Time at which the request to update the `WorkerPool` was received.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })

    /**
     * Configuration to be used for a creating workers in the `WorkerPool`. Structure is documented below.
     */
    public val workerConfig: Output
        get() = javaResource.workerConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                workerPoolWorkerConfigToKotlin(args0)
            })
        })
}

public object WorkerPoolMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.cloudbuild.WorkerPool::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy