# Google Cloud Secure Web Proxy This module allows creation and management of [Secure Web Proxy](https://cloud.google.com/secure-web-proxy/docs/overview), and its URL lists and policy rules. It also allows to deploy SWP as a Private Service Connect service. This means that a single SWP deployment can be used from across different VPCs, regardless of whether they are interconnected. A [Proxy-only subnet](https://cloud.google.com/load-balancing/docs/proxy-only-subnets) must exist in the VPC where SWP is deployed. When deploying SWP, the required ad-hoc [Cloud Router](https://cloud.google.com/network-connectivity/docs/router) is also created. - [Minimal Secure Web Proxy](#minimal-secure-web-proxy) - [PSC service attachments](#psc-service-attachments) - [Secure Web Proxy with rules](#secure-web-proxy-with-rules) - [Secure Web Proxy with TLS inspection](#secure-web-proxy-with-tls-inspection) - [Secure Web Proxy as transparent proxy](#secure-web-proxy-as-transparent-proxy) - [Factories](#factories) - [Variables](#variables) - [Outputs](#outputs) ## Minimal Secure Web Proxy (Note that this will not allow any request to pass.) ```hcl module "secure-web-proxy" { source = "./fabric/modules/net-swp" project_id = "my-project" region = "europe-west4" name = "secure-web-proxy" network = "projects/my-project/global/networks/my-network" subnetwork = "projects/my-project/regions/europe-west4/subnetworks/my-subnetwork" certificates = [ "projects/my-project/locations/europe-west4/certificates/secure-web-proxy-cert" ] gateway_config = { addresses = ["10.142.68.3"] labels = { example = "value" } } } # tftest modules=1 resources=2 inventory=basic.yaml ``` ## PSC service attachments The optional `service_attachment` variable allows [deploying SWP as a Private Service Connect service attachment](https://cloud.google.com/secure-web-proxy/docs/deploy-service-attachment) ```hcl module "secure-web-proxy" { source = "./fabric/modules/net-swp" project_id = "my-project" region = "europe-west4" name = "secure-web-proxy" network = "projects/my-project/global/networks/my-network" subnetwork = "projects/my-project/regions/europe-west4/subnetworks/my-subnetwork" certificates = [ "projects/my-project/locations/europe-west4/certificates/secure-web-proxy-cert" ] gateway_config = { addresses = ["10.142.68.3"] labels = { example = "value" } } service_attachment = { nat_subnets = ["projects/my-project/regions/europe-west4/subnetworks/my-psc-subnetwork"] consumer_accept_lists = { "my-autoaccept-project-1" = 1, "my-autoaccept-project-2" = 1 } } } # tftest modules=1 resources=3 inventory=psc.yaml ``` ## Secure Web Proxy with rules This example shows different ways of defining policy rules, including how to leverage substitution for internally generated URL maps, or externally defined resources. ```hcl module "secure-web-proxy" { source = "./fabric/modules/net-swp" project_id = "my-project" region = "europe-west4" name = "secure-web-proxy" network = "projects/my-project/global/networks/my-network" subnetwork = "projects/my-project/regions/europe-west4/subnetworks/my-subnetwork" certificates = [ "projects/my-project/locations/europe-west4/certificates/secure-web-proxy-cert" ] gateway_config = { addresses = ["10.142.68.3"] ports = [80, 443] labels = { example = "value" } } policy_rules = { host-0 = { priority = 1000 allow = false session_matcher = "host() == 'google.com'" } secure-tag-0 = { priority = 1001 session_matcher = < ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| | [gateway_config](variables.tf#L40) | Optional Secure Web Gateway configuration. | object({…}) | ✓ | | | [name](variables.tf#L53) | Name of the Secure Web Proxy resource. | string | ✓ | | | [network](variables.tf#L58) | Name of the network the Secure Web Proxy is deployed into. | string | ✓ | | | [project_id](variables.tf#L108) | Project id of the project that holds the network. | string | ✓ | | | [region](variables.tf#L113) | Region where resources will be created. | string | ✓ | | | [subnetwork](variables.tf#L133) | Name of the subnetwork the Secure Web Proxy is deployed into. | string | ✓ | | | [certificates](variables.tf#L17) | List of certificates to be used for Secure Web Proxy. | list(string) | | [] | | [description](variables.tf#L24) | Optional description for the created resources. | string | | "Managed by Terraform." | | [factories_config](variables.tf#L30) | Path to folder with YAML resource description data files. | object({…}) | | {} | | [policy_rules](variables.tf#L63) | Policy rules definitions. Merged with policy rules defined via the factory. | map(object({…})) | | {} | | [policy_rules_contexts](variables.tf#L97) | Replacement contexts for policy rules matcher arguments. | object({…}) | | {} | | [service_attachment](variables.tf#L118) | PSC service attachment configuration. | object({…}) | | null | | [tls_inspection_config](variables.tf#L138) | TLS inspection configuration. | object({…}) | | {} | | [url_lists](variables.tf#L159) | URL lists. | map(object({…})) | | {} | ## Outputs | name | description | sensitive | |---|---|:---:| | [gateway](outputs.tf#L17) | The gateway resource. | | | [gateway_security_policy](outputs.tf#L22) | The gateway security policy resource. | | | [id](outputs.tf#L27) | ID of the gateway resource. | | | [service_attachment](outputs.tf#L32) | ID of the service attachment resource, if created. | |