Files
hunfabric/modules/agent-engine/main.tf
Hemanand eaa420534b Add agent engine BYOC support (#3885)
* feat(agent-engine): add support for container and custom image specs

- Add container_config to deployment_files.
- Add image_spec with build_args to source_config.
- Make agent_framework optional and document supported values.
- Implement dynamic specs for container and source deployments.
- Add examples and automated tests for new deployment types.

* chore: update Google provider version to 7.28.0 across modules

Mechanical update of versions.tf and versions.tofu files using tools/versions.py.

* feat(agent-engine): refactor for container deployments and API alignment

- Group deployment settings under 'deployment_config' (renamed from 'deployment_files').
- Support container-based deployments via 'container_config' and 'image_spec'.
- Refactor 'source_files_config' (renamed from 'source_config') to include mutually exclusive 'python_spec' and 'image_spec'.
- Support 'developer_connect_config' as a source code type.
- Group engine settings (framework, env, secrets) under 'agent_engine_config'.
- Add support for 'memory_bank_config' persistent memory.
- Overhaul reasoning engine resources with dynamic blocks to match provider schema.
- Update all documentation examples, add TOC, and refresh test inventories.

* Update dynamic python_spec block and related example yamls

* Ignore changes setting for developer_connect_source under lifecycle management

* fixing review comments for `try` and default path for `source_path`

---------

Co-authored-by: Hemanand <hemr@google.com>
Co-authored-by: Julio Castillo <jccb@google.com>
2026-04-21 17:46:20 +00:00

113 lines
3.5 KiB
HCL

/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
locals {
_ctx_p = "$"
_resource = (
var.managed
? try(google_vertex_ai_reasoning_engine.managed[0], null)
: try(google_vertex_ai_reasoning_engine.unmanaged[0], null)
)
bucket_name = (
var.deployment_config.package_config != null && var.bucket_config.create
? google_storage_bucket.default[0].name
: coalesce(var.bucket_config.name, var.name)
)
ctx = {
for k, v in var.context : k => {
for kk, vv in v : "${local._ctx_p}${k}:${kk}" => vv
} if k != "condition_vars"
}
location = lookup(
local.ctx.locations, var.region, var.region
)
project_id = lookup(
local.ctx.project_ids, var.project_id, var.project_id
)
resource = {
id = local._resource.id
object = local._resource
}
}
# TODO: fix once eventual consistency issue is solved.
# AE doesn't retry the deployment (yet) if bindings are still not active.
resource "time_sleep" "wait_5_minutes" {
create_duration = "5m"
depends_on = [
google_project_iam_member.default
]
}
resource "google_storage_bucket" "default" {
count = (
var.bucket_config.create
&& var.deployment_config.package_config != null
? 1 : 0
)
name = coalesce(var.bucket_config.name, var.name)
project = local.project_id
location = local.location
uniform_bucket_level_access = var.bucket_config.uniform_bucket_level_access
force_destroy = !var.bucket_config.deletion_protection
}
resource "google_storage_bucket_object" "dependencies" {
count = (
var.deployment_config.package_config != null
&& var.deployment_config.package_config.are_paths_local ? 1 : 0
)
name = "dependencies.tar.gz"
bucket = local.bucket_name
source = try(var.deployment_config.package_config.dependencies_path, null)
source_md5hash = (
try(var.deployment_config.package_config.dependencies_path, null) == null
? null
: filemd5(var.deployment_config.package_config.dependencies_path)
)
}
resource "google_storage_bucket_object" "pickle" {
count = (
var.deployment_config.package_config != null
&& var.deployment_config.package_config.are_paths_local ? 1 : 0
)
name = "pickle.pkl"
bucket = local.bucket_name
source = try(var.deployment_config.package_config.pickle_path, null)
source_md5hash = (
try(var.deployment_config.package_config.pickle_path, null) == null
? null
: filemd5(var.deployment_config.package_config.pickle_path)
)
}
resource "google_storage_bucket_object" "requirements" {
count = (
var.deployment_config.package_config != null
&& var.deployment_config.package_config.are_paths_local ? 1 : 0
)
name = "requirements.txt"
bucket = local.bucket_name
source = try(var.deployment_config.package_config.requirements_path, null)
source_md5hash = (
try(var.deployment_config.package_config.requirements_path, null) == null
? null
: filemd5(var.deployment_config.package_config.requirements_path)
)
}