-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added shared_vpc_access submodule to enable GKE and Dataproc Se…
…rvice Account access. (#434) BREAKING CHANGE: This change requires that you use the `shared_vpc` submodule to manage service account access. See the upgrade guide for details.
- Loading branch information
Showing
14 changed files
with
360 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# Upgrading to Project Factory v9.0 | ||
|
||
The v9.0 release of Project Factory is a backwards incompatible release for | ||
service projects created with [shared_vpc](../modules/shared_vpc) module that | ||
also have `container.googleapis.com` and/or `dataproc.googleapis.com` API's | ||
enabled. If you don't have these API's enabled on your service projects or you | ||
are creating new projects then there is no action required on your end. | ||
|
||
## Migration Instructions | ||
|
||
If your service projects have the `container.googleapis.com` API enabled then | ||
follow instructions in [GKE API already enabled](#gke-api-already-enabled). | ||
|
||
If your service projects have the `dataproc.googleapis.com` API enabled then | ||
follow instructions in [Dataproc API already enabled](#dataproc-api-already-enabled). | ||
|
||
### GKE API already enabled | ||
|
||
If you have the `container.googleapis.com` API enabled you will see in your | ||
terraform plan that `google_compute_subnetwork_iam_member` | ||
and `google_compute_subnetwork_iam_member` resources will be recreated. This is | ||
a safe operation and you can apply the changes. Example plan can look like this: | ||
```diff | ||
# module.example.module.service-project.module.project-factory.google_compute_subnetwork_iam_member.gke_shared_vpc_subnets[0] will be destroyed | ||
- resource "google_compute_subnetwork_iam_member" "gke_shared_vpc_subnets" { | ||
- etag = "BwWrwEtp6B4=" -> null | ||
- id = "projects/pf-ci-shared2-host-0004-29fd/regions/us-west1/subnetworks/shared-network-subnet-01/roles/compute.networkUser/serviceaccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" -> null | ||
- member = "serviceAccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" -> null | ||
- project = "pf-ci-shared2-host-0004-29fd" -> null | ||
- region = "us-west1" -> null | ||
- role = "roles/compute.networkUser" -> null | ||
- subnetwork = "projects/pf-ci-shared2-host-0004-29fd/regions/us-west1/subnetworks/shared-network-subnet-01" -> null | ||
} | ||
|
||
# module.example.module.service-project.module.project-factory.google_compute_subnetwork_iam_member.gke_shared_vpc_subnets[1] will be destroyed | ||
- resource "google_compute_subnetwork_iam_member" "gke_shared_vpc_subnets" { | ||
- etag = "BwWrwEtrwLA=" -> null | ||
- id = "projects/pf-ci-shared2-host-0004-29fd/regions/us-west1/subnetworks/shared-network-subnet-02/roles/compute.networkUser/serviceaccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" -> null | ||
- member = "serviceAccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" -> null | ||
- project = "pf-ci-shared2-host-0004-29fd" -> null | ||
- region = "us-west1" -> null | ||
- role = "roles/compute.networkUser" -> null | ||
- subnetwork = "projects/pf-ci-shared2-host-0004-29fd/regions/us-west1/subnetworks/shared-network-subnet-02" -> null | ||
} | ||
|
||
# module.example.module.service-project.module.project-factory.google_project_iam_member.gke_host_agent[0] will be destroyed | ||
- resource "google_project_iam_member" "gke_host_agent" { | ||
- etag = "BwWrwEtQfSY=" -> null | ||
- id = "pf-ci-shared2-host-0004-29fd/roles/container.hostServiceAgentUser/serviceaccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" -> null | ||
- member = "serviceAccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" -> null | ||
- project = "pf-ci-shared2-host-0004-29fd" -> null | ||
- role = "roles/container.hostServiceAgentUser" -> null | ||
} | ||
|
||
# module.example.module.service-project.module.shared_vpc_access.google_compute_subnetwork_iam_member.gke_shared_vpc_subnets[0] will be created | ||
+ resource "google_compute_subnetwork_iam_member" "gke_shared_vpc_subnets" { | ||
+ etag = (known after apply) | ||
+ id = (known after apply) | ||
+ member = "serviceAccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" | ||
+ project = "pf-ci-shared2-host-0004-29fd" | ||
+ region = "us-west1" | ||
+ role = "roles/compute.networkUser" | ||
+ subnetwork = "shared-network-subnet-01" | ||
} | ||
|
||
# module.example.module.service-project.module.shared_vpc_access.google_compute_subnetwork_iam_member.gke_shared_vpc_subnets[1] will be created | ||
+ resource "google_compute_subnetwork_iam_member" "gke_shared_vpc_subnets" { | ||
+ etag = (known after apply) | ||
+ id = (known after apply) | ||
+ member = "serviceAccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" | ||
+ project = "pf-ci-shared2-host-0004-29fd" | ||
+ region = "us-west1" | ||
+ role = "roles/compute.networkUser" | ||
+ subnetwork = "shared-network-subnet-02" | ||
} | ||
|
||
# module.example.module.service-project.module.shared_vpc_access.google_project_iam_member.gke_host_agent[0] will be created | ||
+ resource "google_project_iam_member" "gke_host_agent" { | ||
+ etag = (known after apply) | ||
+ id = (known after apply) | ||
+ member = "serviceAccount:service-740499050292@container-engine-robot.iam.gserviceaccount.com" | ||
+ project = "pf-ci-shared2-host-0004-29fd" | ||
+ role = "roles/container.hostServiceAgentUser" | ||
} | ||
``` | ||
|
||
### Dataproc API already enabled | ||
If you have `dataproc.googleapis.com` API enabled on your projects then terraform | ||
plan will try to bind `roles/compute.networkUser` to | ||
`service-<PROJECT_NUMBER>@dataproc-accounts.iam.gserviceaccount.com` at the | ||
project level. Example: | ||
```diff | ||
# module.example.module.service-project.module.shared_vpc_access.google_project_iam_member.dataproc_shared_vpc_network_user[0] will be created | ||
+ resource "google_project_iam_member" "dataproc_shared_vpc_network_user" { | ||
+ etag = (known after apply) | ||
+ id = (known after apply) | ||
+ member = "serviceAccount:service-740499050292@dataproc-accounts.iam.gserviceaccount.com" | ||
+ project = "pf-ci-shared2-host-0004-29fd" | ||
+ role = "roles/compute.networkUser" | ||
} | ||
``` | ||
|
||
If you have already binded the `roles/compute.networkUser` to | ||
`service-<PROJECT_NUMBER>@dataproc-accounts.iam.gserviceaccount.com` at the | ||
project level then please remove that binding before running `terraform apply`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Shared VPC Access | ||
|
||
This module grants IAM permissions on host project and subnets to appropriate API service accounts based on activated | ||
APIs. For now only GKE and Dataproc APIs are supported. | ||
|
||
## Example Usage | ||
```hcl | ||
module "shared_vpc_access" { | ||
source = "terraform-google-modules/project-factory/google//modules/shared_vpc_access" | ||
host_project_id = var.shared_vpc | ||
service_project_id = var.service_project | ||
active_apis = [ | ||
"compute.googleapis.com", | ||
"container.googleapis.com", | ||
"dataproc.googleapis.com", | ||
] | ||
shared_vpc_subnets = [ | ||
"projects/pf-ci-shared2/regions/us-west1/subnetworks/shared-network-subnet-01", | ||
"projects/pf-ci-shared2/regions/us-west1/subnetworks/shared-network-subnet-02", | ||
] | ||
} | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|:----:|:-----:|:-----:| | ||
| active\_apis | The list of active apis on the service project. If api is not active this module will not try to activate it | list(string) | `<list>` | no | | ||
| host\_project\_id | The ID of the host project which hosts the shared VPC | string | n/a | yes | | ||
| service\_project\_id | The ID of the service project | string | n/a | yes | | ||
| shared\_vpc\_subnets | List of subnets fully qualified subnet IDs (ie. projects/$project_id/regions/$region/subnetworks/$subnet_id) | list(string) | `<list>` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| active\_api\_service\_accounts | List of active API service accounts in the service project. | | ||
| project\_id | Service project ID. | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
Oops, something went wrong.