Skip to content

Commit

Permalink
fix: use service_networking_connection peering output for routes conf…
Browse files Browse the repository at this point in the history
…ig (#98)
  • Loading branch information
gtsorbo authored May 26, 2023
1 parent 5c90246 commit 7a03911
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
REGISTRY=$(grep "REGISTRY_URL := " $MAKEFILE | cut -d\ -f3)
echo dev-tools=${REGISTRY}/${IMAGE}:${VERSION} >> "$GITHUB_OUTPUT"
fi
- run: docker run --rm -v ${{ github.workspace }}:/workspace ${{ steps.variables.outputs.dev-tools }} module-swapper
- run: docker run --rm -e ENABLE_BPMETADATA -v ${{ github.workspace }}:/workspace ${{ steps.variables.outputs.dev-tools }} /usr/local/bin/test_lint.sh
env:
ENABLE_BPMETADATA: 1

5 changes: 3 additions & 2 deletions examples/standalone_single_project/cicd.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ module "cloudbuild_private_pool" {
worker_pool_name = "cloudbuild-workerpool"
machine_type = var.cloudbuild_private_pool_machine_type

worker_address = "10.39.0.0"
worker_range_name = "cloudbuild-worker-range"
worker_address = "10.39.0.0"
worker_address_prefix_length = "24"
worker_range_name = "cloudbuild-worker-range"

labels = var.labels
}
3 changes: 2 additions & 1 deletion modules/cloudbuild-private-pool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ module "cloudbuild_private_pool" {
| network\_project\_id | Project ID for Cloud Build network. | `string` | n/a | yes |
| private\_pool\_vpc\_name | Set the name of the private pool VPC | `string` | `"cloudbuild-vpc"` | no |
| project\_id | Project ID for Cloud Build Private Worker Pool | `string` | n/a | yes |
| worker\_address | Choose an address range for the Cloud Build Private Pool workers. example: 10.37.0.0. Do not include a prefix, as it must be /16 | `string` | `"10.37.0.0"` | no |
| worker\_address | Choose an address range for the Cloud Build Private Pool workers. example: 10.37.0.0. Do not include a prefix length. | `string` | `"10.37.0.0"` | no |
| worker\_address\_prefix\_length | Prefix length, such as 24 for /24 or 16 for /16. Must be 24 or lower. | `string` | `"16"` | no |
| worker\_pool\_name | Name of Cloud Build Worker Pool | `string` | `"cloudbuild-private-worker-pool"` | no |
| worker\_pool\_no\_external\_ip | Whether to disable external IP on the Cloud Build Worker Pool | `bool` | `false` | no |
| worker\_range\_name | Name of Cloud Build Worker IP address range | `string` | `"worker-pool-range"` | no |
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudbuild-private-pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ resource "google_compute_global_address" "worker_range" {
purpose = "VPC_PEERING"
address_type = "INTERNAL"
address = var.worker_address
prefix_length = 16
prefix_length = var.worker_address_prefix_length
network = var.create_cloudbuild_network ? google_compute_network.private_pool_vpc[0].id : data.google_compute_network.workerpool_vpc[0].id
}

Expand All @@ -70,7 +70,7 @@ resource "google_service_networking_connection" "worker_pool_connection" {

resource "google_compute_network_peering_routes_config" "service_networking_peering_config" {
project = var.network_project_id
peering = "servicenetworking-googleapis-com"
peering = google_service_networking_connection.worker_pool_connection.peering
network = var.private_pool_vpc_name

export_custom_routes = true
Expand Down
8 changes: 7 additions & 1 deletion modules/cloudbuild-private-pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ variable "private_pool_vpc_name" {

variable "worker_address" {
type = string
description = "Choose an address range for the Cloud Build Private Pool workers. example: 10.37.0.0. Do not include a prefix, as it must be /16"
description = "Choose an address range for the Cloud Build Private Pool workers. example: 10.37.0.0. Do not include a prefix length."
default = "10.37.0.0"
}

variable "worker_address_prefix_length" {
type = string
description = "Prefix length, such as 24 for /24 or 16 for /16. Must be 24 or lower."
default = "16"
}

variable "worker_pool_name" {
type = string
description = "Name of Cloud Build Worker Pool"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func TestStandaloneSingleProjectExample(t *testing.T) {
gitAppRun("config", "user.name", "Secure CICD Robot")
gitAppRun("config", "--global", "credential.https://source.developers.google.com.helper", "gcloud.sh")
gitAppRun("config", "--global", "init.defaultBranch", "main")
gitAppRun("config", "--global", "http.postBuffer", "157286400")
gitAppRun("checkout", "-b", "main")
err2 := cp.Copy("../../../build/cloudbuild-ci.yaml", fmt.Sprintf("%s/cloudbuild-ci.yaml", tmpDirApp))
fmt.Println(err2)
Expand Down

0 comments on commit 7a03911

Please sign in to comment.