Config Validator Policy Library

March 7, 2022 ยท View on GitHub

Constraint templates specify the logic to be used by constraints. This repository contains pre-defined constraint templates that you can implement or modify for your own needs.

Creating a constraint template

You can create and implement your own custom constraint templates. For instructions on how to write constraint templates, see How to write your own constraint templates.

Policy Bundles

In addition to browsing all Available Templates and Sample Constraints, you can explore these policy bundles:

Available Templates

TemplateSamples
GCPAllowedResourceTypesConstraintV1
GCPAllowedResourceTypesConstraintV2deny_some_resource_types
GCPAlwaysViolatesConstraintV1always_violates_all
GCPAppEngineServiceVersionsConstraintV1service_versions
GCPAppengineLocationConstraintV1allow_appengine_applications_in_australia_and_south_america
GCPBigQueryCMEKEncryptionConstraintV1gcp-bq-cmek-encryption-v1
GCPBigQueryDatasetLocationConstraintV1bq_dataset_allowed_locations
GCPBigQueryDatasetWorldReadableConstraintV1require_bq_table_iam
GCPBigQueryTableRetentionConstraintV1bq_table_minimum_maximum_retention
GCPCMEKRotationConstraintV1cmek_rotation, cmek_rotation_one_hundred_days
GCPCMEKSettingsConstraintV1cmek_rotation
GCPComputeAllowedNetworksConstraintV2allowed-networks
GCPComputeBlockSSHKeysConstraintV1compute_block_ssh_keys
GCPComputeDiskResourcePoliciesConstraintV1compute_disk_resource_policies_allowlist_one
GCPComputeExternalIpAccessConstraintV1
GCPComputeExternalIpAccessConstraintV2forbid_external_ip
GCPComputeIpForwardConstraintV1
GCPComputeIpForwardConstraintV2forbid_ip_forward
GCPComputeNetworkInterfaceWhitelistConstraintV1
GCPComputeRequireOSLoginConstraintV1compute-enable-oslogin-project
GCPComputeZoneConstraintV1compute_zone_allowlist_one
GCPDNSSECConstraintV1require_dnssec
GCPDNSSECPreventRSASHA1ConstraintV1dnssec_prevent_rsasha1_ksk, dnssec_prevent_rsasha1_zsk
GCPDataprocLocationConstraintV1allow_dataproc_clusters_in_asia
GCPEnforceLabelConstraintV1require_labels
GCPEnforceNamingConstraintV1enforce_naming_convention
GCPExternalIpAccessConstraintV1
GCPGKEAllowedNodeSAConstraintV1gke_allowed_node_service_account_scope_default
GCPGKEContainerOptimizedOSConstraintV1gke_container_optimized_os
GCPGKEDashboardConstraintV1disable_gke_dashboard
GCPGKEDisableDefaultServiceAccountConstraintV1disable_gke_default_service_account
GCPGKEDisableLegacyEndpointsConstraintV1disable_gke_legacy_endpoints
GCPGKEEnableAliasIPRangesConstraintV1enable_alias_ip_ranges
GCPGKEEnableBinAuthzConstraintV1gke-enable-binary-authorization
GCPGKEEnablePrivateEndpointConstraintV1gke_enable_private_endpoint
GCPGKEEnableShieldedNodesConstraintV1enable_gke_shielded_nodes
GCPGKEEnableStackdriverKubernetesEngineMonitoringV1enable_gke_stackdriver_kubernetes_engine_monitoring
GCPGKEEnableStackdriverLoggingConstraintV1enable_gke_stackdriver_logging
GCPGKEEnableStackdriverMonitoringConstraintV1enable_gke_stackdriver_monitoring
GCPGKEEnableWorkloadIdentityConstraintV1enable_gke_workload_identity
GCPGKELegacyAbacConstraintV1disable_gke_legacy_abac
GCPGKEMasterAuthorizedNetworksEnabledConstraintV1enable_gke_master_authorized_networks
GCPGKENodeAutoRepairConstraintV1enable_auto_repair
GCPGKENodeAutoUpgradeConstraintV1enable_auto_upgrade
GCPGKEPrivateClusterConstraintV1allow_only_private_cluster
GCPGKERestrictClientAuthenticationMethodsConstraintV1gke_restrict_client_auth_methods
GCPGKERestrictPodTrafficConstraintV1gke_restrict_pod_traffic
GCPGKERestrictPodTrafficConstraintV2gke_restrict_pod_traffic
GCPGLBExternalIpAccessConstraintV1glb_external_ip_allowlist
GCPIAMAllowedBindingsConstraintV1
GCPIAMAllowedBindingsConstraintV2
GCPIAMAllowedBindingsConstraintV3block_serviceaccount_token_creator, deny_allusers, deny_role, restrict-gmail-bigquery-dataset, restrict-googlegroups-bigquery-dataset, restrict_gmail, restrict_owner_role
GCPIAMAllowedPolicyMemberDomainsConstraintV1
GCPIAMAllowedPolicyMemberDomainsConstraintV2only_my_domain, service_accounts_only
GCPIAMAuditLogConstraintV1audit_log_all, audit_log_data_read_write
GCPIAMCustomRolePermissionsConstraintV1allowlist-custom-role-permissions
GCPIAMRequiredBindingsConstraintV1require_members_and_domains_owner
GCPIAMRestrictServiceAccountCreationConstraintV1iam_restrict_service_account_creation
GCPIAMRestrictServiceAccountKeyAgeConstraintV1iam-restrict-service-account-key-age-ninety-days, iam-restrict-service-account-key-age-one-hundred-days
GCPIAMRestrictServiceAccountKeyTypeConstraintV1iam_restrict_service_account_key_type
GCPLBAllowedForwardingRulesConstraintV2gcp_lb_forwarding_rule_allowlist
GCPNetworkEnableFirewallLogsConstraintV1enable-network-firewall-logs
GCPNetworkEnableFlowLogsConstraintV1enable_network_flow_logs
GCPNetworkEnablePrivateGoogleAccessConstraintV1enable_network_private_google_access
GCPNetworkRestrictDefaultV1network_restrict_default
GCPNetworkRoutingConstraintV1require_global_routing
GCPResourceValuePatternConstraintV1gke-cluster-enable-logging
GCPRestrictedFirewallRulesConstraintV1restrict-firewall-rule-allow-ingress-demo, restrict-firewall-rule-rdp-world-open, restrict-firewall-rule-ssh-world-open, restrict-firewall-rule-world-open, restrict-firewall-rule-world-open-tcp-udp-all-ports
GCPSQLAllowedAuthorizedNetworksConstraintV1sql_allowed_authorized_networks_allowlist
GCPSQLBackupConstraintV1gcp-sql-backup-no-exemptions, gcp-sql-backup-with-exemptions
GCPSQLInstanceTypeConstraintV1sql_type_deny_sqlserver
GCPSQLLocationConstraintV1allow_some_sql_location
GCPSQLMaintenanceWindowConstraintV1gcp-sql-maintenance-window-v1
GCPSQLPublicIpConstraintV1prevent-public-ip-cloudsql
GCPSQLSSLConstraintV1require_sql_ssl
GCPSQLWorldReadableConstraintV1sql-world-readable
GCPServiceUsageConstraintV1allow_basic_set_of_apis, deny_some_apis
GCPSpannerLocationConstraintV1allow_spanner_clusters_in_asia_and_europe
GCPStorageBucketPolicyOnlyConstraintV1require_bucket_policy_only
GCPStorageBucketRetentionConstraintV1storage_bucket_minimum_maximum_retention
GCPStorageBucketWorldReadableConstraintV1denylist_public_users
GCPStorageCMEKEncryptionConstraintV1storage_cmek_encryption
GCPStorageLocationConstraintV1allow_some_storage_location
GCPStorageLoggingConstraintV1storage_logging
GCPVPCSCAllowedRegionsConstraintV2vpc_sc_allowlist_regions
GCPVPCSCEnsureAccessLevelsConstraintV1vpc_sc_ensure_access_levels
GCPVPCSCEnsureProjectConstraintV1vpc_sc_ensure_project
GCPVPCSCEnsureServicesConstraintV1vpc_sc_ensure_services
GCPVPCSCIPRangeConstraintV1vpc_sc_ip_range
GCPVPCSCProjectPerimeterConstraintV1vpc_sc_project_perimeter_whitelist
GCPVPCSCProjectPerimeterConstraintV2
GCPVPCSCProjectPerimeterConstraintV3vpc_sc_project_perimeter_allowlist, vpc_sc_project_perimeter_denylist
GCPVPCSCWhitelistRegionsConstraintV1
GKEClusterLocationConstraintV1gke_cluster_location
GKEClusterLocationConstraintV2
GKEClusterVersionConstraintV1gke-cluster-version

Sample Constraints

The repo also contains a number of sample constraints:

SampleTemplateDescription
allow_appengine_applications_in_australia_and_south_americaLinkRestrict locations (regions) where App Engine applications are deployed.
allow_basic_set_of_apisLinkOnly a basic set of APIS
allow_dataproc_clusters_in_asiaLinkChecks that Dataproc clusters are in correct regions.
allow_only_private_clusterLinkVerifies all GKE clusters are Private Clusters.
allow_some_sql_locationLinkChecks Cloud SQL instance locations against allowed or disallowed locations.
allow_some_storage_locationLinkChecks Cloud Storage bucket locations against allowed or disallowed locations.
allow_spanner_clusters_in_asia_and_europeLinkChecks Cloud Spanner locations.
allowed-networksLinkChecks all VM network interfaces are attached to certain VPC networks.
allowlist-custom-role-permissionsLinkCustom BigQuery role must only have specific permissions
always_violates_allLinkTesting policy, will always violate.
audit_log_allLinkChecks that all services have all types of audit logs enabled.
audit_log_data_read_writeLinkChecks that the defined services have audit logs enabled (ADMIN_READ, DATA_READ, DATA_WRITE).
block_serviceaccount_token_creatorLinkBan any users from being granted Service Account Token Creator access
bq_dataset_allowed_locationsLinkChecks in which locations BigQuery datasets exist.
bq_table_minimum_maximum_retentionLinkChecks if a BigQuery table violates retention policy.
cmek_rotationLinkChecks multiple CMEK key settings (protection level, algorithm, purpose, rotation period).
cmek_rotationLinkChecks that CMEK rotation policy is in place and is sufficiently short.
cmek_rotation_one_hundred_daysLinkChecks that CMEK rotation policy is in place and is sufficiently short.
compute-enable-oslogin-projectLinkVerifies that all VMs in a project have OS login enabled.
compute_block_ssh_keysLinkChecks if "Block Project-wide SSH keys" is enabled for VM instances
compute_disk_resource_policies_allowlist_oneLinkChecks that Persistent Disks have correct resource policies (eg. snapshot schedules) attached to them.
compute_zone_allowlist_oneLinkChecks the instances and Persistent Disks are in desired zones.
deny_allusersLinkPrevent public users from having access to resources via IAM
deny_roleLinkBan any users from being granted Service Account User access
deny_some_apisLinkDeny a set of APIS
deny_some_resource_typesLinkRestricts kind of resources that are allowed in your projects.
denylist_public_usersLinkPrevent public users from having access to resources via IAM
disable_gke_dashboardLinkEnsure Kubernetes web UI / Dashboard is disabled
disable_gke_default_service_accountLinkEnsure default Service account is not used for Project access in Kubernetes Clusters
disable_gke_legacy_abacLinkEnsure Legacy Authorization is set to Disabled on Kubernetes Engine Clusters
disable_gke_legacy_endpointsLinkChecks that legacy metadata endpoints are disabled (disabled by default since GKE 1.12+).
dnssec_prevent_rsasha1_kskLinkEnsure that RSASHA1 is not used for key-signing key in Cloud DNS
dnssec_prevent_rsasha1_zskLinkEnsure that RSASHA1 is not used for zone-signing key in Cloud DNS
enable-network-firewall-logsLinkEnsure Firewall logs is enabled for every firewall in VPC Network
enable_alias_ip_rangesLinkEnsure Kubernetes Cluster is created with Alias IP ranges enabled
enable_auto_repairLinkEnsure automatic node repair is enabled on all node pools in a GKE cluster
enable_auto_upgradeLinkEnsure Automatic node upgrades is enabled on Kubernetes Engine Clusters nodes
enable_gke_master_authorized_networksLinkEnsure Master authorized networks is set to Enabled on Kubernetes Engine Clusters
enable_gke_shielded_nodesLinkChecks that GKE is using Shielded nodes (secure boot).
enable_gke_stackdriver_kubernetes_engine_monitoringLinkEnsure Stackdriver Kubernetes Engine Monitoring is enabled
enable_gke_stackdriver_loggingLinkEnsure stackdriver logging is enabled on a GKE cluster
enable_gke_stackdriver_monitoringLinkEnsure stackdriver monitoring is enabled on a GKE cluster
enable_gke_workload_identityLinkEnsure Workload Identity is enabled on a GKE cluster
enable_network_flow_logsLinkEnsure VPC Flow logs is enabled for every subnet in VPC Network
enable_network_private_google_accessLinkEnsure Private Google Access is enabled for all subnetworks in VPC
enforce_naming_conventionLinkChecks defined resources that are supported by Cloud Asset Inventory are named according to regular expression pattern.
forbid_external_ipLinkChecks if Compute Engine instances have public IPs.
forbid_ip_forwardLinkChecks if a VM has IP forwarding turned on.
gcp-bq-cmek-encryption-v1LinkChecks if BigQuery datasets have a CMEK key set.
gcp-sql-backup-no-exemptionsLinkChecks that Cloud SQL backups are enabled.
gcp-sql-backup-with-exemptionsLinkChecks that Cloud SQL backups are enabled.
gcp-sql-maintenance-window-v1LinkChecks that every Cloud SQL instance has a specified maintenance window set.
gcp_lb_forwarding_rule_allowlistLinkVerifies load balancer forwarding rules against allowed values.
gke-cluster-allowed-locationsChecks which zones are allowed/disallowed for GKE clusters.
gke-cluster-enable-loggingLinkEnsure Kubernetes Clusters have logging enabled.
gke-cluster-versionLinkChecks if a GKE cluster is using a master version type other than 1.12.10-gke.17.
gke-enable-binary-authorizationLink
gke_allowed_node_service_account_scope_defaultLinkChecks that certain service account scopes are not assigned to nodes.
gke_cluster_locationLink
gke_container_optimized_osLinkEnsure Container-Optimized OS (cos) is used for Kubernetes Engine Clusters
gke_enable_private_endpointLinkEnable a private endpoint for the cluster to be accessible from an internal network only.
gke_restrict_client_auth_methodsLinkChecks that client certificate and password authentication methods are disabled for GKE clusters.
gke_restrict_pod_trafficLinkChecks that GKE clusters have a Network Policy installed.
gke_restrict_pod_trafficLinkChecks that GKE clusters have a Network Policy installed.
glb_external_ip_allowlistLinkChecks if Global Load Balancers have external IPs.
iam-restrict-service-account-key-age-ninety-daysLinkChecks if service account keys are older than 90 days.
iam-restrict-service-account-key-age-one-hundred-daysLinkChecks if service account keys are older than 100 days.
iam_allow_rolesOnly the roles in this list are allowed. All other roles trigger violation.
iam_ban_rolesOnly the roles in this list trigger violation. All other roles allowed.
iam_restrict_service_account_creationLinkChecks if any service accounts have been created.
iam_restrict_service_account_key_typeLinkChecks if any service accounts have user created keys.
network_restrict_defaultLinkRestrict default networks with open firewall rules
only_my_domainLinkOnly allow members from my domain to be added to IAM roles
prevent-public-ip-cloudsqlLinkPrevents a public IP from being assigned to a Cloud SQL instance.
require_bq_table_iamLinkChecks if BigQuery datasets are publicly readable or allAuthenticatedUsers.
require_bucket_policy_onlyLinkChecks if Cloud Storage buckets have Bucket Only Policy turned on.
require_dnssecLinkChecks that DNSSEC is enabled for a Cloud DNS managed zone.
require_global_routingLinkChecks that every VPC is in global routing mode.
require_labelsLinkChecks that labels are set for all resources (or a subset of resources) and that they match a certain regular expression pattern.
require_members_and_domains_ownerLinkTrigger violations if the following members and domains are absent in roles/owner
require_sql_sslLinkChecks if Cloud SQL instances have SSL turned on.
restrict-firewall-rule-allow-ingress-demoLinkChecks that every firewall rule matches certain settings.
restrict-firewall-rule-rdp-world-openLinkChecks for open firewall rules allowing RDP from the internet.
restrict-firewall-rule-ssh-world-openLinkChecks for open firewall rules allowing SSH from the internet.
restrict-firewall-rule-world-openLinkChecks for open firewall rules allowing ingress from the internet.
restrict-firewall-rule-world-open-tcp-udp-all-portsLinkChecks for open firewall rules allowing TCP/UDP from the internet.
restrict-gmail-bigquery-datasetLinkEnforce corporate domain by banning gmail.com addresses access to BigQuery datasets
restrict-googlegroups-bigquery-datasetLinkEnforce corporate domain by banning googlegroups.com addresses access to BigQuery datasets
restrict_gmailLinkEnforce corporate domain by banning gmail.com addresses
restrict_owner_roleLinkOnly my domain members are allowed to have the Owner role on projects
service_accounts_onlyLinkChecks that members that have been granted IAM roles belong to allowlisted domains.
service_versionsLinkLimit the number App Engine application versions simultaneously running. installed.
sql-world-readableLinkChecks if Cloud SQL instances are world readable.
sql_allowed_authorized_networks_allowlistLinkChecks Cloud SQL master authorized networks list against a allowlist.
sql_type_deny_sqlserverLinkChecks for allowed or disallowed Cloud SQL instance types.
storage_bucket_minimum_maximum_retentionLink
storage_cmek_encryptionLinkChecks if Cloud Storage buckets have CMEK turned on.
storage_loggingLinkEnsure storage logs are delivered to a separate bucket
vpc_sc_allowlist_regionsLinkChecks that only allowed geographical regions are allowed in VPC Service Controls perimeters.
vpc_sc_ensure_access_levelsLinkChecks if a VPC Service Controls perimeter has desired access levels set.
vpc_sc_ensure_projectLinkChecks if a VPC Service Controls perimeter has correct projects in them.
vpc_sc_ensure_servicesLinkChecks is a VPC Service Controls perimeter has correct services set.
vpc_sc_ip_rangeLinkChecks the CIDR notation size in VPC Service Controls access levels.
vpc_sc_project_perimeter_allowlistLinkChecks that only allowed VPC Service Controls perimeters exists.
vpc_sc_project_perimeter_denylistLinkOlder, deprecated version of above policy.
vpc_sc_project_perimeter_whitelistLink