From 6837cd510adc46e08be47a6bec1a0dad4ccfe10a Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Tue, 22 Jun 2021 20:58:54 +0000 Subject: [PATCH] Cloudbuild worker pools (#4877) * Adding cloudbuild worker pool * Test * Fix test, update yaml * Fix base paths, tests work * Fixing base paths * Finish base path fixes * Remove from ga provider * Fix check destroy * Add markdown file * Add example to markdown * PR feedback * Remove comments referencing old override * PR feedback Signed-off-by: Modular Magician --- .changelog/4877.txt | 3 + .../resource_cloudbuild_worker_pool_test.go | 1 + .../r/cloudbuild_worker_pool.html.markdown | 163 ++++++++++++++++++ website/google.erb | 4 + 4 files changed, 171 insertions(+) create mode 100644 .changelog/4877.txt create mode 100644 google/resource_cloudbuild_worker_pool_test.go create mode 100644 website/docs/r/cloudbuild_worker_pool.html.markdown diff --git a/.changelog/4877.txt b/.changelog/4877.txt new file mode 100644 index 00000000000..c0f089d800d --- /dev/null +++ b/.changelog/4877.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +google_cloudbuild_worker_pool +``` diff --git a/google/resource_cloudbuild_worker_pool_test.go b/google/resource_cloudbuild_worker_pool_test.go new file mode 100644 index 00000000000..71664db3c87 --- /dev/null +++ b/google/resource_cloudbuild_worker_pool_test.go @@ -0,0 +1 @@ +package google diff --git a/website/docs/r/cloudbuild_worker_pool.html.markdown b/website/docs/r/cloudbuild_worker_pool.html.markdown new file mode 100644 index 00000000000..6616d4ef8b0 --- /dev/null +++ b/website/docs/r/cloudbuild_worker_pool.html.markdown @@ -0,0 +1,163 @@ +--- +subcategory: "Cloud Build" +layout: "google" +page_title: "Google: google_cloudbuild_worker_pool" +sidebar_current: "docs-google-cloudbuild-worker-pool" +description: |- + Configuration for custom WorkerPool to run builds +--- + +# google\_cloudbuild\_worker\_pool + +Definition of custom Cloud Build WorkerPools for running jobs with custom configuration and custom networking. + +-> This resource is not currently public, and requires allow-listing of projects prior to use. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + + +## Example Usage + +```hcl +resource "google_cloudbuild_worker_pool" "pool" { + name = "my-pool" + location = "europe-west1" + worker_config { + disk_size_gb = 100 + machine_type = "e2-standard-4" + no_external_ip = false + } +} +``` + +## Example Usage - Network Config + +```hcl +resource "google_project_service" "servicenetworking" { + service = "servicenetworking.googleapis.com" + disable_on_destroy = false +} + +resource "google_compute_network" "network" { + name = "my-network" + auto_create_subnetworks = false + depends_on = [google_project_service.servicenetworking] +} + +resource "google_compute_global_address" "worker_range" { + name = "worker-pool-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = google_compute_network.network.id +} + +resource "google_service_networking_connection" "worker_pool_conn" { + network = google_compute_network.network.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.worker_range.name] + depends_on = [google_project_service.servicenetworking] +} + +resource "google_cloudbuild_worker_pool" "pool" { + name = "my-pool" + location = "europe-west1" + worker_config { + disk_size_gb = 100 + machine_type = "e2-standard-4" + no_external_ip = false + } + network_config { + peered_network = google_compute_network.network.id + } + depends_on = [google_service_networking_connection.worker_pool_conn] +} +``` + +## Argument Reference + +The following arguments are supported: + +* `location` - + (Required) + The location for the resource + +* `name` - + (Required) + User-defined name of the `WorkerPool`. + + +- - - + +* `network_config` - + (Optional) + Network configuration for the `WorkerPool`. + +* `project` - + (Optional) + The project for the resource + +* `worker_config` - + (Optional) + Configuration to be used for a creating workers in the `WorkerPool`. + + + +The `network_config` block supports: + +* `peered_network` - + (Required) + Immutable. The network definition that the workers are peered to. If this section is left empty, the workers will be peered to `WorkerPool.project_id` 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) + +The `worker_config` block supports: + +* `disk_size_gb` - + (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. + +* `machine_type` - + (Optional) + Machine type of a worker, such as `n1-standard-1`. See (https://cloud.google.com/cloud-build/docs/custom-workers/worker-pool-config-file). If left blank, Cloud Build will use `n1-standard-1`. + +* `no_external_ip` - + (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}}` + +* `create_time` - + Output only. Time at which the request to create the `WorkerPool` was received. + +* `delete_time` - + 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 + +* `update_time` - + Output only. Time at which the request to update the `WorkerPool` was received. + +## Timeouts + +This resource provides the following +[Timeouts](/docs/configuration/resources.html#timeouts) configuration options: + +- `create` - Default is 10 minutes. +- `update` - Default is 10 minutes. +- `delete` - Default is 10 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}} +``` + diff --git a/website/google.erb b/website/google.erb index 2bfb0b41560..7b5908fc1d2 100644 --- a/website/google.erb +++ b/website/google.erb @@ -670,6 +670,10 @@ google_cloudbuild_trigger +
  • + google_cloudbuild_worker_pool +
  • +