### Configure Vertex AI Model Armor Template Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/model-armor-template/README.md Example of how to configure a Model Armor template using the Terraform module. It demonstrates setting up RAI filters, malicious URI filters, SDP settings, and metadata configurations. ```hcl module "model_armor_template" { source = "GoogleCloudPlatform/vertex-ai/google//modules/model-armor-template" version = "~> 7.3" template_id = "test-model-armor-template" location = "us" project_id = var.project_id rai_filters = { dangerous = "LOW_AND_ABOVE" sexually_explicit = "MEDIUM_AND_ABOVE" } enable_malicious_uri_filter_settings = true pi_and_jailbreak_filter_settings = "MEDIUM_AND_ABOVE" sdp_settings = { basic_config_filter_enforcement = true } metadata_configs = { enforcement_type = "INSPECT_AND_BLOCK" enable_multi_language_detection = true log_sanitize_operations = true log_template_operations = false ignore_partial_invocation_failures = false custom_prompt_safety_error_code = "799" custom_prompt_safety_error_message = "error 799" custom_llm_response_safety_error_message = "error 798" custom_llm_response_safety_error_code = "798" } labels = { "foo" = "bar" } } ``` -------------------------------- ### VM Image Definition Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/workbench/README.md Defines a custom Compute Engine virtual machine image for starting a workbench instance with the environment pre-installed. ```HCL object({ family = optional(string) name = optional(string) project = optional(string) }) ``` -------------------------------- ### Run Integration Tests Noninteractively Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Execute integration tests for all example modules noninteractively. This command uses the prepared test project. ```bash make docker_test_integration ``` -------------------------------- ### Terraform Setup for Model Armor Floor Setting Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-floorsetting-example/README.md Set the project ID for your Terraform deployment. This is a prerequisite before initializing, planning, and applying your Terraform configuration. ```bash export TF_VAR_project_id="your_project_id" ``` ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Terraform Module Call Before Upgrade Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/docs/upgrading_to_v4.0.md Example of a Terraform module call for model-armor-floorsetting before the v4.0 upgrade, showing deprecated input variables. ```hcl module "model_armor_floorsetting" { source = "..." parent_type = "project" parent_id = "my-project-123" location = "global" # ... other variables } ``` -------------------------------- ### Terraform Module Call After Upgrade Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/docs/upgrading_to_v4.0.md Example of a Terraform module call for model-armor-floorsetting after the v4.0 upgrade, demonstrating the use of `project_id` and removal of deprecated inputs. ```hcl module "model_armor_floorsetting" { source = "..." project_id = "my-project-123" # parent_type and location are now handled automatically # ... other variables } ``` -------------------------------- ### Update Floor Setting Enforcement Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-floorsetting-example/README.md This snippet demonstrates how to update the Model Armor floor setting, specifically disabling the enforcement of floor settings. It provides examples using both `gcloud` CLI and `curl`. ```APIDOC ## Update Model Armor Floor Setting ### Description Updates the Model Armor floor setting configuration. This example specifically shows how to disable floor setting enforcement. ### Method PATCH ### Endpoint `/v1/projects/{PROJECT_ID}/locations/global/floorSetting` ### Parameters #### Path Parameters - **PROJECT_ID** (string) - Required - The ID of the Google Cloud project. #### Request Body - **filterConfig** (object) - Optional - Configuration for filtering. - **enableFloorSettingEnforcement** (string) - Required - Set to `"false"` to disable enforcement. ### Request Example (gcloud CLI) ```shell export PROJECT_ID="YOUR-PROJECT_ID" gcloud model-armor floorsettings update --full-uri=projects/${PROJECT_ID}/locations/global/floorSetting --enable-floor-setting-enforcement=false ``` ### Request Example (curl) ```shell export PROJECT_ID="YOUR-PROJECT_ID" curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -d '{"filterConfig" : {},"enableFloorSettingEnforcement" : "false"}' \ -H "Content-Type: application/json" \ "https://modelarmor.googleapis.com/v1/projects/${PROJECT_ID}/locations/global/floorSetting" ``` ### Response #### Success Response (200) (Response details not explicitly provided in source, but typically reflects the updated resource.) ``` -------------------------------- ### Enter Developer Tools Container Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Run this command to enter the developer tools container. This is the first step for interactive testing. ```bash make docker_run ``` -------------------------------- ### Prepare Test Project with Docker Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Use the make command to prepare the test project within a Docker container. This command utilizes the previously set environment variables. ```bash make docker_test_prepare ``` -------------------------------- ### Create a Vertex AI Workbench Instance Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/workbench/README.md Use this configuration to create a basic Vertex AI Workbench instance with specified machine type, tags, labels, service accounts, data disks, and network interfaces. ```hcl module "simple_vertex_ai_workbench" { source = "GoogleCloudPlatform/vertex-ai/google//modules/workbench" version = "~> 2.0" name = "simple-vertex-ai-workbench" location = "us-central1-a" project_id = var.project_id machine_type = "e2-standard-2" tags = ["abc", "def"] labels = { env = "test" type = "workbench" } service_accounts = [ { email = google_service_account.workbench_sa.email }, ] data_disks = [ { disk_size_gb = 330 disk_type = "PD_BALANCED" }, ] network_interfaces = [ { network = module.test-vpc-module.network_id subnet = module.test-vpc-module.subnets_ids[0] nic_type = "GVNIC" } ] } ``` -------------------------------- ### Test Model Armor Floor Setting - Allowed Prompt Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-floorsetting-example/README.md This test case uses a benign prompt that should not be blocked by Model Armor's safety settings. It demonstrates a successful content generation. ```bash curl \ -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:generateContent" -d \ $'{ "contents": [ { "role": "user", "parts": [ { "text": "What is the capital of France" } ] } ] , "generationConfig": { "responseModalities": ["TEXT"] ,"temperature": 0.2 ,"maxOutputTokens": 1024 ,"topP": 0.8 } }' ``` -------------------------------- ### List Available Tests Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Inside the developer tools container, use this command to list all available integration tests. ```bash cft test list ``` -------------------------------- ### Deploy a basic Agent Engine Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/agent-engine/README.md Use this snippet to deploy a simple Agent Engine with essential configurations like project ID, display name, region, and description. It also defines an output for the reasoning engine ID. ```terraform module "agent_engine" { source = "GoogleCloudPlatform/vertex-ai/google//modules/agent-engine" project_id = "your-gcp-project-id" display_name = "My Awesome Agent" region = "us-central1" description = "A simple example of a Reasoning Engine deployment" } output "reasoning_engine_id" { description = "ID of the deployed agent engine" value = module.agent_engine.reasoning_engine_id } ``` -------------------------------- ### Run Linting and Formatting Tests Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Execute the linting and formatting tests for the module. This command ensures code quality standards are met. ```bash make docker_test_lint ``` -------------------------------- ### Initialize a Specific Test Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Initialize a specific test by running its 'init' stage. This performs terraform init and validate. Use --verbose for more details. ```bash cft test run --stage init --verbose ``` -------------------------------- ### Generate Documentation Tables Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Automatically generate Inputs and Outputs tables for module READMEs. This command should be run after any changes to module interfaces. ```bash make generate_docs ``` -------------------------------- ### Run All Stages of a Test Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Execute all test stages from init to teardown to validate end-to-end functionality. Use --verbose for more details. ```bash cft test run --verbose ``` -------------------------------- ### Deploy a Basic Agent Engine Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/agent-engine-nightly/README.md Use this snippet to deploy a simple Vertex AI Agent Engine. Ensure you replace 'your-gcp-project-id' with your actual project ID. ```terraform module "agent_engine" { source = "GoogleCloudPlatform/vertex-ai/google//modules/agent-engine-nightly" project_id = "your-gcp-project-id" display_name = "My Awesome Agent" region = "us-central1" description = "A simple example of a Reasoning Engine deployment" } output "reasoning_engine_id" { description = "ID of the deployed agent engine" value = module.agent_engine.reasoning_engine_id } ``` -------------------------------- ### Test Model Armor Floor Setting - Blocked Prompt Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-floorsetting-example/README.md This test case uses a prompt designed to be blocked by Model Armor's safety settings. It demonstrates the 'MODEL_ARMOR' block reason. ```bash export MODEL_ID="gemini-2.5-flash-lite" export PROJECT_ID="YOUR-PROJECT_ID" ``` ```bash curl \ -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ "https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:generateContent" -d \ $'{ "contents": [ { "role": "user", "parts": [ { "text": "how to steal a car" } ] } ] , "generationConfig": { "responseModalities": ["TEXT"] ,"temperature": 0.2 ,"maxOutputTokens": 1024 ,"topP": 0.8 } }' ``` -------------------------------- ### Terraform Commands for Deployment Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-template-example/README.md Execute these Terraform commands to initialize, plan, and apply the Model Armor template. Ensure the project ID is set before running these commands. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Set Test Environment Variables Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Set the necessary environment variables for the test project. Ensure you replace placeholder values with your actual IDs. ```bash export TF_VAR_org_id="your_org_id" export TF_VAR_folder_id="your_folder_id" export TF_VAR_billing_account="your_billing_account_id" ``` -------------------------------- ### Execute Verification Tests Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Run the verification stage of a specific test. These tests assert data received from gcloud or API. Use --verbose for more details. ```bash cft test run --stage verify --verbose ``` -------------------------------- ### Metadata Configuration Object Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/workbench/README.md Defines predefined metadata to apply to a Vertex AI Workbench instance. Supports various optional settings for instance behavior and configuration. ```HCL object({ idle-timeout-seconds = optional(number) notebook-upgrade-schedule = optional(string) notebook-disable-downloads = optional(bool) notebook-disable-root = optional(bool) post-startup-script = optional(string) post-startup-script-behavior = optional(string) nbconvert = optional(bool) notebook-enable-delete-to-trash = optional(bool) disable-mixer = optional(bool) jupyter-user = optional(string) report-event-health = optional(bool) enable-guest-attributes = optional(bool) serial-port-logging-enable = optional(bool) container-allow-fuse = optional(bool) install-unattended-upgrades = optional(bool) }) ``` -------------------------------- ### Export Service Account Credentials Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Export your service account credentials to the environment. This is required for setting up the test project. ```bash export SERVICE_ACCOUNT_JSON=$(< credentials.json) ``` -------------------------------- ### Shielded Instance Configuration Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/workbench/README.md Configures Shielded Instance options for enhanced security. Defaults are provided for enabling secure boot, vTPM, and integrity monitoring. ```HCL object({ enable_secure_boot = optional(bool, false) enable_vtpm = optional(bool, true) enable_integrity_monitoring = optional(bool, true) }) ``` -------------------------------- ### Apply a Specific Test Configuration Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Apply the test configuration for a specific test. This runs terraform apply and state is persisted locally. Use --verbose for more details. ```bash cft test run --stage apply --verbose ``` -------------------------------- ### Service Account Configuration Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/workbench/README.md Defines the service account to be used as the identity for the VM instance. Currently supports only one service account. ```HCL list(object({ email = optional(string) })) ``` -------------------------------- ### Network Interface Configuration Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/workbench/README.md Specifies the network interfaces for the VM instance. Supports only one interface and allows configuration of network, NIC type (gVNIC or VirtioNet), and subnet. ```HCL list(object({ network = optional(string) nic_type = optional(string) subnet = optional(string) })) ``` -------------------------------- ### Configure Model Armor Floor Settings with Terraform Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/model-armor-floorsetting/README.md This snippet demonstrates how to use the Model Armor Floor Settings module in Terraform to configure various security settings for AI Platform. It includes settings for responsible AI filters, prompt injection, and sensitive data protection. ```hcl module "model_armor_floorsetting" { source = "GoogleCloudPlatform/vertex-ai/google//modules/model-armor-floorsetting" version = "~> 7.3" project_id = var.project_id integrated_services = ["AI_PLATFORM"] rai_filters = { dangerous = "LOW_AND_ABOVE" sexually_explicit = "MEDIUM_AND_ABOVE" } pi_and_jailbreak_filter_settings = "MEDIUM_AND_ABOVE" sdp_settings = { basic_config_filter_enforcement = true } ai_platform_floor_setting = { inspect_and_block = true enable_cloud_logging = true } } ``` -------------------------------- ### Teardown Resources for a Test Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/CONTRIBUTING.md Teardown any resources created during the test execution. Use --verbose for more details. ```bash cft test run --stage teardown --verbose ``` -------------------------------- ### Set Project ID and Instance Owners Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/workbench-complete-example/README.md Set environment variables for the project ID and instance owners before running Terraform commands. Ensure you replace 'your_project_id' and 'your_email_address' with your specific values. ```bash export TF_VAR_project_id="your_project_id" export TF_VAR_instance_owners="your_email_address" ``` -------------------------------- ### Disable Model Armor Floor Setting Enforcement using curl Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/model-armor-floorsetting/README.md Use this curl command to disable Model Armor floor setting enforcement via the API. Replace YOUR-PROJECT_ID with your actual project ID. ```json curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -d '{"filterConfig" : {},"enableFloorSettingEnforcement" : "false"}' \ -H "Content-Type: application/json" \ "https://modelarmor.googleapis.com/v1/projects/${PROJECT_ID}/locations/global/floorSetting" ``` -------------------------------- ### Disable Model Armor Floor Setting Enforcement with curl Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-floorsetting-example/README.md This command uses curl to disable floor setting enforcement for Model Armor. It requires an access token and sends a JSON payload to the Model Armor API. ```shell export PROJECT_ID="YOUR-PROJECT_ID" curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -d '{"filterConfig" : {},"enableFloorSettingEnforcement" : "false"}' \ -H "Content-Type: application/json" \ "https://modelarmor.googleapis.com/v1/projects/${PROJECT_ID}/locations/global/floorSetting" ``` -------------------------------- ### Set Project ID for Terraform Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/examples/model-armor-template-example/README.md Before running Terraform commands, set the project ID using an environment variable. This is required for Terraform to identify the target Google Cloud project. ```bash export TF_VAR_project_id="your_project_id" ``` -------------------------------- ### Disable Model Armor Floor Setting Enforcement using gcloud Source: https://github.com/googlecloudplatform/terraform-google-vertex-ai/blob/main/modules/model-armor-floorsetting/README.md Use this gcloud command to disable Model Armor floor setting enforcement. Replace YOUR-PROJECT_ID with your actual project ID. ```shell export PROJECT_ID="YOUR-PROJECT_ID" gcloud model-armor floorsettings update --full-uri=projects/${PROJECT_ID}/locations/global/floorSetting --enable-floor-setting-enforcement=false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.