|
| 1 | +# Private Service Connect |
| 2 | + |
| 3 | +This module enables the usage of [Private Service Connect](https://cloud.google.com/vpc/docs/private-service-connect) for a specific subnetwork. |
| 4 | + |
| 5 | +The resources created/managed by this module are: |
| 6 | + |
| 7 | +- Private DNS zone to configure `private.googleapis.com.` |
| 8 | +- Private DNS zone to configure `gcr.io.` |
| 9 | +- Private DNS zone to configure `pdk.dev.` |
| 10 | +- Global Address resource to configure `Private Service Connect` endpoint |
| 11 | +- Global Forwarding Rule resource to forward traffic to respective HTTP(S) load balancing |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +Basic usage of this module is as follows: |
| 16 | + |
| 17 | +```hcl |
| 18 | +module "private_service_connect" { |
| 19 | + source = "terraform-google-modules/network/google//modules/private_service_connect" |
| 20 | +
|
| 21 | + project_id = "<PROJECT_ID>" |
| 22 | + network_self_link = "<NETWORK_SELF_LINK>" |
| 23 | + private_service_connect_ip = "10.3.0.5" |
| 24 | + forwarding_rule_target = "all-apis" |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +Private Service Connect IP must fulfill requirements detailed [here](https://cloud.google.com/vpc/docs/configure-private-service-connect-apis#ip-address-requirements). |
| 29 | + |
| 30 | +Target subnetwork must have Private Google Access enabled. |
| 31 | + |
| 32 | +**Note:** All egress traffic is allowed from VPC internal networks by default. |
| 33 | + |
| 34 | +If you have a firewall rule blocking egress traffic, you will need to configure a [new egress rule](https://cloud.google.com/vpc/docs/using-firewalls#creating_firewall_rules) with following attributes: |
| 35 | + |
| 36 | +- Direction: Egress |
| 37 | +- Priority: Higher than blocking egress rule |
| 38 | +- Target tags: <FIREWALL_RULE_TAG> |
| 39 | +- Destination filters: |
| 40 | + - IP ranges: <PRIVATE_SERVICE_CONNECT_IP> |
| 41 | + - Protocols and ports: tcp:443 |
| 42 | + |
| 43 | +## Requirements |
| 44 | + |
| 45 | +- Cloud DNS API must be enabled. |
| 46 | +- Service Account running Terraform must have `dns.managedZones.*` permissions. You can add them by assigning `DNS Admin` default role to the Service Account. |
| 47 | + |
| 48 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 49 | +## Inputs |
| 50 | + |
| 51 | +| Name | Description | Type | Default | Required | |
| 52 | +|------|-------------|------|---------|:--------:| |
| 53 | +| dns\_code | Code to identify DNS resources in the form of `{dns_code}-{dns_type}` | `string` | `"dz"` | no | |
| 54 | +| forwarding\_rule\_name | Forwarding rule resource name. The forwarding rule name for PSC Google APIs must be an 1-20 characters string with lowercase letters and numbers and must start with a letter. Defaults to `globalrule` | `string` | `"globalrule"` | no | |
| 55 | +| forwarding\_rule\_target | Target resource to receive the matched traffic. Only `all-apis` and `vpc-sc` are valid. | `string` | n/a | yes | |
| 56 | +| network\_self\_link | Network self link for Private Service Connect. | `string` | n/a | yes | |
| 57 | +| private\_service\_connect\_ip | The internal IP to be used for the private service connect. | `string` | n/a | yes | |
| 58 | +| private\_service\_connect\_name | Private Service Connect endpoint name. Defaults to `global-psconnect-ip` | `string` | `"global-psconnect-ip"` | no | |
| 59 | +| project\_id | Project ID for Private Service Connect. | `string` | n/a | yes | |
| 60 | + |
| 61 | +## Outputs |
| 62 | + |
| 63 | +| Name | Description | |
| 64 | +|------|-------------| |
| 65 | +| dns\_zone\_gcr\_name | Name for Managed DNS zone for GCR | |
| 66 | +| dns\_zone\_googleapis\_name | Name for Managed DNS zone for GoogleAPIs | |
| 67 | +| dns\_zone\_pkg\_dev\_name | Name for Managed DNS zone for PKG\_DEV | |
| 68 | +| forwarding\_rule\_name | Forwarding rule resource name. | |
| 69 | +| forwarding\_rule\_target | Target resource to receive the matched traffic. Only `all-apis` and `vpc-sc` are valid. | |
| 70 | +| global\_address\_id | An identifier for the global address created for the private service connect with format `projects/{{project}}/global/addresses/{{name}}` | |
| 71 | +| private\_service\_connect\_ip | Private service connect ip | |
| 72 | +| private\_service\_connect\_name | Private service connect name | |
| 73 | + |
| 74 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
0 commit comments