The only resolution I can find is to add the Editor role before adding the connector, with its 8963 excess permissions.
The error message Error code 7, message: Operation failed: Google APIs Service Agent (<PROJECT_NUMBER>@cloudservices.gserviceaccount.com) needs editor role in the project.
is surprising as basic roles are not even allowed in some organization policies. You would think a more specific role should be sufficient to create a VPC serverless connector.
You can't add conditions like Expiry to a basic role so don't forget to close this security hole before the SecOps team comes after you.
If your VPC is in the service project of a Shared VPC then you will need to add this role to the host project before creating the connector. That's not clear in the message. Giving a service account from a service project Editor role on the network host project might raise a few eyebrows in SecOps if they haven't already blocked such a path. That would force you to put the connector in the host project instead.
You will also need to apply the "roles/compute.networkUser" to a bunch of service accounts on the host project's subnet that this connector sits on. Don't apply these bindings to the project but directly to the subnet (which may be on the host project),
This is not a definitive list of service accounts as it depends on what's using the connector. App engine default service account for the first, cloud functions for the second) :
- "serviceAccount:${var.project_id}@appspot.gserviceaccount.com"
- "serviceAccount:service-${var.project_number}@gcf-admin-robot.iam.gserviceaccount.com"
- "serviceAccount:${var.project_number}@cloudservices.gserviceaccount.com"
- "serviceAccount:service-${var.project_number}@gcp-sa-- vpcaccess.iam.gserviceaccount.com"
You can't see subnet IAM bindings on the console, but gcloud can show them
gcloud compute networks subnets get-iam-policy projects/VPC_HOST_PROJECT/regions/REGION/subnetworks/my-subnet
If any of the permissions are not set, the VPC will be created but left in a bad state. You need Serverless VPC Access Admin
role to delete it (or Editor role), but even that won't help if one of your services is actively using the connector and you get a resource in use
error.
Good luck [re]creating one.