#@ load("/constraints.lib.star", "build_constraint")
#@ constraint = build_constraint("cloudsqlAllowedBackupLocations")

#@ def condition(locations):
#@   return 'resource.settings.backupConfiguration.location in ' +  str(locations) + " == false"
#@ end

#@ if constraint.to_generate():
name: #@ constraint.constraint_name()
resourceTypes:
- sqladmin.googleapis.com/Instance
methodTypes:
- CREATE
- UPDATE
condition: #@  condition(constraint.params().locations)
actionType: DENY
display_name: Require Cloud SQL instances to use only allowed backup locations
description: Ensure that Cloud SQL instance is configured with allowed backup locations
#@ end
