Restrict access to AI developer tools

When AI developer tools are enabled, users with a Gemini Enterprise license can access these tools if you grant them the Gemini Enterprise User (roles/discoveryengine.agentspaceUser) role.

To restrict access to AI developer tools while keeping other Gemini Enterprise features available, choose one of the following options:

Option How it works Trade-offs
Use the predefined role with an IAM deny policy (recommended) Grant the predefined Gemini Enterprise User role and attach an IAM deny policy that blocks AI developer tools permissions. Users automatically receive new permissions and features added to the predefined role, including permissions not supported in custom roles. Requires the Deny Admin (roles/iam.denyAdmin) role on the organization to manage deny policies.
Create a custom IAM role Copy the Gemini Enterprise User role into a custom role and remove permissions starting with businessaicode.. Doesn't require deny policies, but Google doesn't automatically update custom roles when adding new permissions to predefined roles, and copying a predefined role omits permissions not supported in custom roles.

Use the predefined role with an IAM deny policy (recommended)

Google recommends granting the predefined Gemini Enterprise User (roles/discoveryengine.agentspaceUser) role and using an IAM deny policy to block AI developer tools permissions for the target principals or groups.

Google manages predefined roles and automatically updates them when adding new permissions or features. IAM evaluates deny policies before allow policies, so blocked principals can't use AI developer tools even when they hold the predefined role.

Before you begin

  • Verify that you have the Deny Admin (roles/iam.denyAdmin) role on the organization. For more information, see Deny access to resources.
  • Grant the target users or groups the predefined Gemini Enterprise User (roles/discoveryengine.agentspaceUser) role.

Create and attach the deny policy

  1. Create a JSON file named deny-ai-developer-tools.json with the following content. Replace GROUP_EMAIL with the Google Group email address of the users you want to restrict:

    {
      "displayName": "Deny Gemini Enterprise AI developer tools",
      "rules": [
        {
          "description": "Block AI developer tools while keeping other Gemini Enterprise features available through the predefined Gemini Enterprise User role.",
          "denyRule": {
            "deniedPrincipals": [
              "principalSet://goog/group/GROUP_EMAIL"
            ],
            "deniedPermissions": [
              "businessaicode.googleapis.com/*.*"
            ]
          }
        }
      ]
    }
    

    Optional: To block AI developer tools for all principals except specific groups, replace deniedPrincipals in the denyRule with the following fields:

    "deniedPrincipals": [
      "principalSet://goog/public:all"
    ],
    "exceptionPrincipals": [
      "principalSet://goog/group/EXEMPT_GROUP_EMAIL"
    ],
    

    Replace EXEMPT_GROUP_EMAIL with the Google Group email address of the users who should keep access. For supported principal identifier formats, see Principal identifiers for deny policies.

  2. Attach the deny policy to your project using the Google Cloud CLI:

    gcloud iam policies create POLICY_ID \
      --attachment-point="cloudresourcemanager.googleapis.com/projects/PROJECT_ID" \
      --kind=denypolicies \
      --policy-file=deny-ai-developer-tools.json
    

    Replace the following:

    • POLICY_ID: an identifier for the deny policy, such as deny-ai-dev-tools.
    • PROJECT_ID: the ID of your project.
  3. Optional: Verify that the deny policy is attached to your project:

    gcloud iam policies list \
      --attachment-point="cloudresourcemanager.googleapis.com/projects/PROJECT_ID" \
      --kind=denypolicies
    

Create a custom IAM role

To create a custom IAM role that restricts access to AI developer tools, follow these instructions:

  1. In the Google Cloud console, go to the Roles page.

    Go to Roles

  2. Click Create role.

  3. Enter the role details:

    • Title: Give your role a name. For example, Custom Gemini Enterprise User.
    • ID: The Google Cloud console automatically generates the ID, but you can edit it.
    • Role launch stage: Set this to General Availability.
  4. Click Add permissions.

  5. In the panel, search for and select the Gemini Enterprise User (roles/discoveryengine.agentspaceUser) role.

  6. Remove all permissions starting with businessaicode. from the Gemini Enterprise User role to ensure users assigned this custom role can't access the AI developer tools feature.

  7. Click Create.

Add users to the custom role

To add users to the custom role you created, follow these steps:

  1. In the Google Cloud console, go to the IAM page.

    Go to IAM

  2. Click Grant access at the top of the page.

  3. In the New principals field, enter the email addresses of the users or groups you want to add.

  4. Assign the role:

    • Click Assign roles and search for the Title of the custom role you created in the previous section.
    • Select the role.
  5. Click Save.