|
| 1 | +# Google Cloud Shared VPC Access Configuration |
| 2 | + |
| 3 | +This module allows configuring service project access to a Shared VPC, created with the top-level network module. Two configuration modes for each service project are supported: |
| 4 | + |
| 5 | +- VPC access, where service projects are granted IAM roles at the host project level, and can use any of the VPC subnets |
| 6 | +- subnetwork access, where service projects are granted IAM roles at the subnet level, and can then only use specific subnets |
| 7 | + |
| 8 | +Full details on service project configuration can be found in the Google Cloud documentation on [provisioning Shared VPC](https://cloud.google.com/vpc/docs/provisioning-shared-vpc), and on [setting up clusters with Shared VPC](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-shared-vpc). |
| 9 | + |
| 10 | +The resources created/managed by this module are: |
| 11 | + |
| 12 | +- one `google_compute_shared_vpc_service_project` resource for each project where full VPC access is needed |
| 13 | +- one `google_compute_subnetwork_iam_binding` for each subnetwork where individual subnetwork access is needed |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +Basic usage of this module is as follows: |
| 18 | + |
| 19 | +```hcl |
| 20 | +module "net-shared-vpc-access" { |
| 21 | + source = "terraform-google-modules/terraform-google-network/google//modules/fabric-net-svpc-access" |
| 22 | + host_project_id = "my-host-project-id" |
| 23 | + service_project_num = 1 |
| 24 | + service_project_ids = ["my-service-project-id"] |
| 25 | + host_subnets = ["my-subnet-1", "my-subnet-2"] |
| 26 | + host_subnet_regions = ["europe-west1", "europe-west1] |
| 27 | + host_subnet_users = [ |
| 28 | + "serviceAccount:${module.project-foo.gce_service_account}", |
| 29 | + "serviceAccount:${module.project-spam.gce_service_account},group:[email protected]" |
| 30 | + ] |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +[^]: (autogen_docs_start) |
| 35 | + |
| 36 | +## Inputs |
| 37 | + |
| 38 | +| Name | Description | Type | Default | Required | |
| 39 | +|------|-------------|:----:|:-----:|:-----:| |
| 40 | +| host\_project\_id | Project id of the shared VPC host project. | string | n/a | yes | |
| 41 | +| host\_subnet\_regions | List of subnet regions, one per subnet. | list | `<list>` | no | |
| 42 | +| host\_subnet\_users | Map of comma-delimited IAM-style members, one per subnet. | map | `<map>` | no | |
| 43 | +| host\_subnets | List of subnet names on which to grant access. | list | `<list>` | no | |
| 44 | +| service\_project\_ids | Ids of the service projects that will be granted access to all subnetworks. | list | n/a | yes | |
| 45 | +| service\_project\_num | Number of service projects that will be granted access to all subnetworks. | string | `"0"` | no | |
| 46 | + |
| 47 | +## Outputs |
| 48 | + |
| 49 | +| Name | Description | |
| 50 | +|------|-------------| |
| 51 | +| service\_projects | Project ids of the services with access to all subnets. | |
| 52 | + |
| 53 | +[^]: (autogen_docs_end) |
0 commit comments