How do you govern with mandatory tags in GCP

Hello,

We are migrating some workload from Azure to GCP and we have mandatory requirement to have both Product tag (list of predefined values) and contact tag (which shall end @company.com) which works perfectly in Azure via Azure Policy.

I’m having hard time to make it happen in Google, it looks like that dynamic values for tags are not supported (unless I’m doing something wrong).

Environment

  • Tag key (PII Removed by Staff): predefined values, e.g. DevOps
  • Tag key (PII Removed by Staff)/contact (tagKeys/(PII Removed by Staff): dynamic values, allowedValuesRegex: ^[A-Za-z0-9._%+-]+@company[.]com$

Constraint

name: organizations/(PII Removed by Staff)/customConstraints/custom.requireProductAndContactTags
resourceTypes: [compute.googleapis.com/Instance]
methodTypes: [GOVERN_TAGS]
condition: resource.hasDirectTagKey (PII Removed by Staff) && resource.hasDirectTagKey (PII Removed by Staff)
actionType: ALLOW

Steps to reproduce
gcloud compute instances create tag-test --project (PII Removed by Staff) --zone us-east1-b --machine-type e2-micro --resource-manager-tags="(PII Removed by Staff)/Product=DevOps,(PII Removed by Staff)/contact=user@company.com"

Actual result

FAILED_PRECONDITION: Operation disallowed by Organization Policy constraint due to missing or incorrect Tags
customConstraints/custom.requireProductAndContactTags ... Allows governed GCP resource create and update requests only when Product and contact tags are directly attached.