Skip to content

googleCloudbuildWorkerPool

Definition of custom Cloud Build WorkerPools for running jobs with custom configuration and custom networking.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.cloudbuildWorkerPool.CloudbuildWorkerPool(this, "pool", {
  location: "europe-west1",
  name: "my-pool",
  worker_config: [
    {
      disk_size_gb: 100,
      machine_type: "e2-standard-4",
      no_external_ip: false,
    },
  ],
});

Example Usage - Network Config

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleProjectServiceServicenetworking =
  new google.projectService.ProjectService(this, "servicenetworking", {
    disable_on_destroy: false,
    service: "servicenetworking.googleapis.com",
  });
const googleComputeNetworkNetwork = new google.computeNetwork.ComputeNetwork(
  this,
  "network",
  {
    auto_create_subnetworks: false,
    depends_on: [`\${${googleProjectServiceServicenetworking.fqn}}`],
    name: "my-network",
  }
);
const googleComputeGlobalAddressWorkerRange =
  new google.computeGlobalAddress.ComputeGlobalAddress(this, "worker_range", {
    address_type: "INTERNAL",
    name: "worker-pool-range",
    network: googleComputeNetworkNetwork.id,
    prefix_length: 16,
    purpose: "VPC_PEERING",
  });
const googleServiceNetworkingConnectionWorkerPoolConn =
  new google.serviceNetworkingConnection.ServiceNetworkingConnection(
    this,
    "worker_pool_conn",
    {
      depends_on: [`\${${googleProjectServiceServicenetworking.fqn}}`],
      network: googleComputeNetworkNetwork.id,
      reserved_peering_ranges: [googleComputeGlobalAddressWorkerRange.name],
      service: "servicenetworking.googleapis.com",
    }
  );
new google.cloudbuildWorkerPool.CloudbuildWorkerPool(this, "pool", {
  depends_on: [`\${${googleServiceNetworkingConnectionWorkerPoolConn.fqn}}`],
  location: "europe-west1",
  name: "my-pool",
  network_config: [
    {
      peered_network: googleComputeNetworkNetwork.id,
      peered_network_ip_range: "/29",
    },
  ],
  worker_config: [
    {
      disk_size_gb: 100,
      machine_type: "e2-standard-4",
      no_external_ip: false,
    },
  ],
});

Argument Reference

The following arguments are supported:

  • location - (Required) The location for the resource

  • name - (Required) User-defined name of the workerPool.


  • networkConfig - (Optional) Network configuration for the workerPool. Structure is documented below.

  • project - (Optional) The project for the resource

  • workerConfig - (Optional) Configuration to be used for a creating workers in the workerPool. Structure is documented below.

The networkConfig block supports:

  • peeredNetwork - (Required) Immutable. The network definition that the workers are peered to. If this section is left empty, the workers will be peered to workerPoolProjectId on the service producer network. Must be in the format projects/{project}/global/networks/{network}, where {project} is a project number, such as 12345, and {network} is the name of a VPC network in the project. See (https://cloud.google.com/cloud-build/docs/custom-workers/set-up-custom-worker-pool-environment#understanding_the_network_configuration_options)

  • peeredNetworkIpRange - (Optional) Immutable. Subnet IP range within the peered network. This is specified in CIDR notation with a slash and the subnet prefix size. You can optionally specify an IP address before the subnet prefix value. e.g. 19216800/29 would specify an IP range starting at 192.168.0.0 with a prefix size of 29 bits. /16 would specify a prefix size of 16 bits, with an automatically determined IP within the peered VPC. If unspecified, a value of /24 will be used.

The workerConfig block supports:

  • diskSizeGb - (Optional) Size of the disk attached to the worker, in GB. See (https://cloud.google.com/cloud-build/docs/custom-workers/worker-pool-config-file). Specify a value of up to 1000. If 0 is specified, Cloud Build will use a standard disk size.

  • machineType - (Optional) Machine type of a worker, such as n1Standard1. See (https://cloud.google.com/cloud-build/docs/custom-workers/worker-pool-config-file). If left blank, Cloud Build will use n1Standard1.

  • noExternalIp - (Optional) If true, workers are created without any public address, which prevents network egress to public IPs.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/locations/{{location}}/workerPools/{{name}}

  • createTime - Output only. Time at which the request to create the workerPool was received.

  • deleteTime - Output only. Time at which the request to delete the workerPool was received.

  • state - Output only. WorkerPool state. Possible values: STATE_UNSPECIFIED, PENDING, APPROVED, REJECTED, CANCELLED

  • updateTime - Output only. Time at which the request to update the workerPool was received.

Timeouts

This resource provides the following Timeouts configuration options: configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

WorkerPool can be imported using any of these accepted formats:

$ terraform import google_cloudbuild_worker_pool.default projects/{{project}}/locations/{{location}}/workerPools/{{name}}
$ terraform import google_cloudbuild_worker_pool.default {{project}}/{{location}}/{{name}}
$ terraform import google_cloudbuild_worker_pool.default {{location}}/{{name}}