agent-starter-pack 0.0.1b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agent-starter-pack might be problematic. Click here for more details.

Files changed (162) hide show
  1. agent_starter_pack-0.0.1b0.dist-info/METADATA +143 -0
  2. agent_starter_pack-0.0.1b0.dist-info/RECORD +162 -0
  3. agent_starter_pack-0.0.1b0.dist-info/WHEEL +4 -0
  4. agent_starter_pack-0.0.1b0.dist-info/entry_points.txt +2 -0
  5. agent_starter_pack-0.0.1b0.dist-info/licenses/LICENSE +201 -0
  6. agents/agentic_rag_vertexai_search/README.md +22 -0
  7. agents/agentic_rag_vertexai_search/app/agent.py +145 -0
  8. agents/agentic_rag_vertexai_search/app/retrievers.py +79 -0
  9. agents/agentic_rag_vertexai_search/app/templates.py +53 -0
  10. agents/agentic_rag_vertexai_search/notebooks/evaluating_langgraph_agent.ipynb +1561 -0
  11. agents/agentic_rag_vertexai_search/template/.templateconfig.yaml +14 -0
  12. agents/agentic_rag_vertexai_search/tests/integration/test_agent.py +57 -0
  13. agents/crewai_coding_crew/README.md +34 -0
  14. agents/crewai_coding_crew/app/agent.py +86 -0
  15. agents/crewai_coding_crew/app/crew/config/agents.yaml +39 -0
  16. agents/crewai_coding_crew/app/crew/config/tasks.yaml +37 -0
  17. agents/crewai_coding_crew/app/crew/crew.py +71 -0
  18. agents/crewai_coding_crew/notebooks/evaluating_crewai_agent.ipynb +1571 -0
  19. agents/crewai_coding_crew/notebooks/evaluating_langgraph_agent.ipynb +1561 -0
  20. agents/crewai_coding_crew/template/.templateconfig.yaml +12 -0
  21. agents/crewai_coding_crew/tests/integration/test_agent.py +47 -0
  22. agents/langgraph_base_react/README.md +9 -0
  23. agents/langgraph_base_react/app/agent.py +73 -0
  24. agents/langgraph_base_react/notebooks/evaluating_langgraph_agent.ipynb +1561 -0
  25. agents/langgraph_base_react/template/.templateconfig.yaml +13 -0
  26. agents/langgraph_base_react/tests/integration/test_agent.py +48 -0
  27. agents/multimodal_live_api/README.md +50 -0
  28. agents/multimodal_live_api/app/agent.py +86 -0
  29. agents/multimodal_live_api/app/server.py +193 -0
  30. agents/multimodal_live_api/app/templates.py +51 -0
  31. agents/multimodal_live_api/app/vector_store.py +55 -0
  32. agents/multimodal_live_api/template/.templateconfig.yaml +15 -0
  33. agents/multimodal_live_api/tests/integration/test_server_e2e.py +254 -0
  34. agents/multimodal_live_api/tests/load_test/load_test.py +40 -0
  35. agents/multimodal_live_api/tests/unit/test_server.py +143 -0
  36. src/base_template/.gitignore +197 -0
  37. src/base_template/Makefile +37 -0
  38. src/base_template/README.md +91 -0
  39. src/base_template/app/utils/tracing.py +143 -0
  40. src/base_template/app/utils/typing.py +115 -0
  41. src/base_template/deployment/README.md +123 -0
  42. src/base_template/deployment/cd/deploy-to-prod.yaml +98 -0
  43. src/base_template/deployment/cd/staging.yaml +215 -0
  44. src/base_template/deployment/ci/pr_checks.yaml +51 -0
  45. src/base_template/deployment/terraform/apis.tf +34 -0
  46. src/base_template/deployment/terraform/build_triggers.tf +122 -0
  47. src/base_template/deployment/terraform/dev/apis.tf +42 -0
  48. src/base_template/deployment/terraform/dev/iam.tf +90 -0
  49. src/base_template/deployment/terraform/dev/log_sinks.tf +66 -0
  50. src/base_template/deployment/terraform/dev/providers.tf +29 -0
  51. src/base_template/deployment/terraform/dev/storage.tf +76 -0
  52. src/base_template/deployment/terraform/dev/variables.tf +126 -0
  53. src/base_template/deployment/terraform/dev/vars/env.tfvars +21 -0
  54. src/base_template/deployment/terraform/iam.tf +130 -0
  55. src/base_template/deployment/terraform/locals.tf +50 -0
  56. src/base_template/deployment/terraform/log_sinks.tf +72 -0
  57. src/base_template/deployment/terraform/providers.tf +35 -0
  58. src/base_template/deployment/terraform/service_accounts.tf +42 -0
  59. src/base_template/deployment/terraform/storage.tf +100 -0
  60. src/base_template/deployment/terraform/variables.tf +202 -0
  61. src/base_template/deployment/terraform/vars/env.tfvars +43 -0
  62. src/base_template/pyproject.toml +113 -0
  63. src/base_template/tests/unit/test_utils/test_tracing_exporter.py +140 -0
  64. src/cli/commands/create.py +534 -0
  65. src/cli/commands/setup_cicd.py +730 -0
  66. src/cli/main.py +35 -0
  67. src/cli/utils/__init__.py +35 -0
  68. src/cli/utils/cicd.py +662 -0
  69. src/cli/utils/gcp.py +120 -0
  70. src/cli/utils/logging.py +51 -0
  71. src/cli/utils/template.py +644 -0
  72. src/data_ingestion/README.md +79 -0
  73. src/data_ingestion/data_ingestion_pipeline/components/ingest_data.py +175 -0
  74. src/data_ingestion/data_ingestion_pipeline/components/process_data.py +321 -0
  75. src/data_ingestion/data_ingestion_pipeline/pipeline.py +58 -0
  76. src/data_ingestion/data_ingestion_pipeline/submit_pipeline.py +184 -0
  77. src/data_ingestion/pyproject.toml +17 -0
  78. src/data_ingestion/uv.lock +999 -0
  79. src/deployment_targets/agent_engine/app/agent_engine_app.py +238 -0
  80. src/deployment_targets/agent_engine/app/utils/gcs.py +42 -0
  81. src/deployment_targets/agent_engine/deployment_metadata.json +4 -0
  82. src/deployment_targets/agent_engine/notebooks/intro_reasoning_engine.ipynb +869 -0
  83. src/deployment_targets/agent_engine/tests/integration/test_agent_engine_app.py +120 -0
  84. src/deployment_targets/agent_engine/tests/load_test/.results/.placeholder +0 -0
  85. src/deployment_targets/agent_engine/tests/load_test/.results/report.html +264 -0
  86. src/deployment_targets/agent_engine/tests/load_test/.results/results_exceptions.csv +1 -0
  87. src/deployment_targets/agent_engine/tests/load_test/.results/results_failures.csv +1 -0
  88. src/deployment_targets/agent_engine/tests/load_test/.results/results_stats.csv +3 -0
  89. src/deployment_targets/agent_engine/tests/load_test/.results/results_stats_history.csv +22 -0
  90. src/deployment_targets/agent_engine/tests/load_test/README.md +42 -0
  91. src/deployment_targets/agent_engine/tests/load_test/load_test.py +100 -0
  92. src/deployment_targets/agent_engine/tests/unit/test_dummy.py +22 -0
  93. src/deployment_targets/cloud_run/Dockerfile +29 -0
  94. src/deployment_targets/cloud_run/app/server.py +128 -0
  95. src/deployment_targets/cloud_run/deployment/terraform/artifact_registry.tf +22 -0
  96. src/deployment_targets/cloud_run/deployment/terraform/dev/service_accounts.tf +20 -0
  97. src/deployment_targets/cloud_run/tests/integration/test_server_e2e.py +192 -0
  98. src/deployment_targets/cloud_run/tests/load_test/.results/.placeholder +0 -0
  99. src/deployment_targets/cloud_run/tests/load_test/README.md +79 -0
  100. src/deployment_targets/cloud_run/tests/load_test/load_test.py +85 -0
  101. src/deployment_targets/cloud_run/tests/unit/test_server.py +142 -0
  102. src/deployment_targets/cloud_run/uv.lock +6952 -0
  103. src/frontends/live_api_react/frontend/package-lock.json +19405 -0
  104. src/frontends/live_api_react/frontend/package.json +56 -0
  105. src/frontends/live_api_react/frontend/public/favicon.ico +0 -0
  106. src/frontends/live_api_react/frontend/public/index.html +62 -0
  107. src/frontends/live_api_react/frontend/public/robots.txt +3 -0
  108. src/frontends/live_api_react/frontend/src/App.scss +189 -0
  109. src/frontends/live_api_react/frontend/src/App.test.tsx +25 -0
  110. src/frontends/live_api_react/frontend/src/App.tsx +205 -0
  111. src/frontends/live_api_react/frontend/src/components/audio-pulse/AudioPulse.tsx +64 -0
  112. src/frontends/live_api_react/frontend/src/components/audio-pulse/audio-pulse.scss +68 -0
  113. src/frontends/live_api_react/frontend/src/components/control-tray/ControlTray.tsx +217 -0
  114. src/frontends/live_api_react/frontend/src/components/control-tray/control-tray.scss +201 -0
  115. src/frontends/live_api_react/frontend/src/components/logger/Logger.tsx +241 -0
  116. src/frontends/live_api_react/frontend/src/components/logger/logger.scss +133 -0
  117. src/frontends/live_api_react/frontend/src/components/logger/mock-logs.ts +151 -0
  118. src/frontends/live_api_react/frontend/src/components/side-panel/SidePanel.tsx +161 -0
  119. src/frontends/live_api_react/frontend/src/components/side-panel/side-panel.scss +285 -0
  120. src/frontends/live_api_react/frontend/src/contexts/LiveAPIContext.tsx +48 -0
  121. src/frontends/live_api_react/frontend/src/hooks/use-live-api.ts +115 -0
  122. src/frontends/live_api_react/frontend/src/hooks/use-media-stream-mux.ts +23 -0
  123. src/frontends/live_api_react/frontend/src/hooks/use-screen-capture.ts +72 -0
  124. src/frontends/live_api_react/frontend/src/hooks/use-webcam.ts +69 -0
  125. src/frontends/live_api_react/frontend/src/index.css +28 -0
  126. src/frontends/live_api_react/frontend/src/index.tsx +35 -0
  127. src/frontends/live_api_react/frontend/src/multimodal-live-types.ts +242 -0
  128. src/frontends/live_api_react/frontend/src/react-app-env.d.ts +17 -0
  129. src/frontends/live_api_react/frontend/src/reportWebVitals.ts +31 -0
  130. src/frontends/live_api_react/frontend/src/setupTests.ts +21 -0
  131. src/frontends/live_api_react/frontend/src/utils/audio-recorder.ts +111 -0
  132. src/frontends/live_api_react/frontend/src/utils/audio-streamer.ts +270 -0
  133. src/frontends/live_api_react/frontend/src/utils/audioworklet-registry.ts +43 -0
  134. src/frontends/live_api_react/frontend/src/utils/multimodal-live-client.ts +329 -0
  135. src/frontends/live_api_react/frontend/src/utils/store-logger.ts +64 -0
  136. src/frontends/live_api_react/frontend/src/utils/utils.ts +86 -0
  137. src/frontends/live_api_react/frontend/src/utils/worklets/audio-processing.ts +73 -0
  138. src/frontends/live_api_react/frontend/src/utils/worklets/vol-meter.ts +65 -0
  139. src/frontends/live_api_react/frontend/tsconfig.json +25 -0
  140. src/frontends/streamlit/frontend/side_bar.py +213 -0
  141. src/frontends/streamlit/frontend/streamlit_app.py +263 -0
  142. src/frontends/streamlit/frontend/style/app_markdown.py +37 -0
  143. src/frontends/streamlit/frontend/utils/chat_utils.py +67 -0
  144. src/frontends/streamlit/frontend/utils/local_chat_history.py +125 -0
  145. src/frontends/streamlit/frontend/utils/message_editing.py +59 -0
  146. src/frontends/streamlit/frontend/utils/multimodal_utils.py +217 -0
  147. src/frontends/streamlit/frontend/utils/stream_handler.py +282 -0
  148. src/frontends/streamlit/frontend/utils/title_summary.py +77 -0
  149. src/resources/containers/data_processing/Dockerfile +25 -0
  150. src/resources/locks/uv-agentic_rag_vertexai_search-agent_engine.lock +4684 -0
  151. src/resources/locks/uv-agentic_rag_vertexai_search-cloud_run.lock +5799 -0
  152. src/resources/locks/uv-crewai_coding_crew-agent_engine.lock +5509 -0
  153. src/resources/locks/uv-crewai_coding_crew-cloud_run.lock +6688 -0
  154. src/resources/locks/uv-langgraph_base_react-agent_engine.lock +4595 -0
  155. src/resources/locks/uv-langgraph_base_react-cloud_run.lock +5710 -0
  156. src/resources/locks/uv-multimodal_live_api-cloud_run.lock +5665 -0
  157. src/resources/setup_cicd/cicd_variables.tf +36 -0
  158. src/resources/setup_cicd/github.tf +85 -0
  159. src/resources/setup_cicd/providers.tf +39 -0
  160. src/utils/generate_locks.py +135 -0
  161. src/utils/lock_utils.py +82 -0
  162. src/utils/watch_and_rebuild.py +190 -0
@@ -0,0 +1,76 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ resource "google_storage_bucket" "logs_data_bucket" {
16
+ name = "${var.dev_project_id}-logs-data"
17
+ location = var.region
18
+ project = var.dev_project_id
19
+ uniform_bucket_level_access = true
20
+
21
+ lifecycle {
22
+ prevent_destroy = false
23
+ ignore_changes = all
24
+ }
25
+
26
+ # Use this block to create the bucket only if it doesn't exist
27
+ count = length(data.google_storage_bucket.existing_bucket) > 0 ? 0 : 1
28
+ depends_on = [resource.google_project_service.services]
29
+ }
30
+
31
+ data "google_storage_bucket" "existing_bucket" {
32
+ name = "${var.dev_project_id}-logs-data"
33
+ project = var.dev_project_id
34
+
35
+ # Capture the error if the bucket doesn't exist
36
+ count = can(data.google_storage_bucket.existing_bucket[0]) ? 1 : 0
37
+ depends_on = [resource.google_project_service.services]
38
+ }
39
+
40
+ {%- if cookiecutter.data_ingestion %}
41
+ resource "google_storage_bucket" "data_ingestion_PIPELINE_GCS_ROOT" {
42
+ name = "${var.dev_project_id}-pipeline-artifacts"
43
+ location = var.region
44
+ project = var.dev_project_id
45
+ uniform_bucket_level_access = true
46
+ force_destroy = true
47
+
48
+ depends_on = [resource.google_project_service.services]
49
+ }
50
+
51
+ resource "google_discovery_engine_data_store" "data_store_dev" {
52
+ location = var.data_store_region
53
+ project = var.dev_project_id
54
+ data_store_id = "${var.datastore_name}"
55
+ display_name = "${var.datastore_name}"
56
+ industry_vertical = "GENERIC"
57
+ content_config = "NO_CONTENT"
58
+ solution_types = ["SOLUTION_TYPE_SEARCH"]
59
+ create_advanced_site_search = false
60
+ provider = google.dev_billing_override
61
+ depends_on = [resource.google_project_service.services]
62
+ }
63
+
64
+ resource "google_discovery_engine_search_engine" "search_engine_dev" {
65
+ project = var.dev_project_id
66
+ engine_id = "${var.search_engine_name}"
67
+ collection_id = "default_collection"
68
+ location = google_discovery_engine_data_store.data_store_dev.location
69
+ display_name = "Search Engine App Staging"
70
+ data_store_ids = [google_discovery_engine_data_store.data_store_dev.data_store_id]
71
+ search_engine_config {
72
+ search_tier = "SEARCH_TIER_ENTERPRISE"
73
+ }
74
+ provider = google.dev_billing_override
75
+ }
76
+ {%- endif %}
@@ -0,0 +1,126 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ variable "dev_project_id" {
16
+ type = string
17
+ description = "**Dev** Google Cloud Project ID for resource deployment."
18
+ }
19
+
20
+ variable "region" {
21
+ type = string
22
+ description = "Google Cloud region for resource deployment."
23
+ default = "us-central1"
24
+ }
25
+
26
+ variable "telemetry_bigquery_dataset_id" {
27
+ type = string
28
+ description = "BigQuery dataset ID for telemetry data export."
29
+ default = "telemetry_genai_app_sample_sink"
30
+ }
31
+
32
+ variable "feedback_bigquery_dataset_id" {
33
+ type = string
34
+ description = "BigQuery dataset ID for feedback data export."
35
+ default = "feedback_genai_app_sample_sink"
36
+ }
37
+
38
+ variable "telemetry_logs_filter" {
39
+ type = string
40
+ description = "Log Sink filter for capturing telemetry data. Captures logs with the `traceloop.association.properties.log_type` attribute set to `tracing`."
41
+ default = "jsonPayload.attributes.\"traceloop.association.properties.log_type\"=\"tracing\" jsonPayload.resource.attributes.\"service.name\"=\"Sample Chatbot Application\""
42
+ }
43
+
44
+ variable "feedback_logs_filter" {
45
+ type = string
46
+ description = "Log Sink filter for capturing feedback data. Captures logs where the `log_type` field is `feedback`."
47
+ default = "jsonPayload.log_type=\"feedback\""
48
+ }
49
+
50
+ variable "telemetry_sink_name" {
51
+ type = string
52
+ description = "Name of the telemetry data Log Sink."
53
+ default = "telemetry_logs_genai_app_sample"
54
+ }
55
+
56
+ variable "feedback_sink_name" {
57
+ type = string
58
+ description = "Name of the feedback data Log Sink."
59
+ default = "feedback_logs_genai_app_sample"
60
+ }
61
+ {%- if cookiecutter.deployment_target == 'cloud_run' %}
62
+ variable "cloud_run_app_sa_name" {
63
+ description = "Service account name to be used for the Cloud Run service"
64
+ type = string
65
+ default = "{{cookiecutter.project_name}}-cr"
66
+ }
67
+
68
+ variable "cloud_run_app_roles" {
69
+ description = "List of roles to assign to the Cloud Run app service account"
70
+ {%- elif cookiecutter.deployment_target == 'agent_engine' %}
71
+ variable "agentengine_sa_roles" {
72
+ description = "List of roles to assign to the Agent Engine app service account"
73
+ {%- endif %}
74
+ type = list(string)
75
+ default = [
76
+ "roles/aiplatform.user",
77
+ "roles/discoveryengine.editor",
78
+ "roles/logging.logWriter",
79
+ "roles/cloudtrace.agent",
80
+ "roles/storage.admin"
81
+ ]
82
+ }
83
+
84
+ {%- if cookiecutter.data_ingestion %}
85
+ variable "vertexai_pipeline_sa_name" {
86
+ description = "Service account name to be used for the Vertex AI service"
87
+ type = string
88
+ default = "data-ingestion-vertexai-sa"
89
+ }
90
+
91
+ variable "data_store_region" {
92
+ type = string
93
+ description = "Google Cloud region for resource deployment."
94
+ default = "us"
95
+ }
96
+
97
+ variable "pipelines_roles" {
98
+ description = "List of roles to assign to the Vertex AI runner service account"
99
+ type = list(string)
100
+ default = [
101
+ "roles/storage.admin",
102
+ "roles/run.invoker",
103
+ "roles/aiplatform.user",
104
+ "roles/discoveryengine.admin",
105
+ "roles/logging.logWriter",
106
+ "roles/artifactregistry.writer",
107
+ "roles/bigquery.dataEditor",
108
+ "roles/bigquery.jobUser",
109
+ "roles/bigquery.readSessionUser",
110
+ "roles/bigquery.connectionAdmin",
111
+ "roles/resourcemanager.projectIamAdmin"
112
+ ]
113
+ }
114
+
115
+ variable "datastore_name" {
116
+ description = "The name of the datastore"
117
+ type = string
118
+ default = "my-datastore"
119
+ }
120
+
121
+ variable "search_engine_name" {
122
+ description = "The name of the search engine"
123
+ type = string
124
+ default = "my-search-engine"
125
+ }
126
+ {%- endif %}
@@ -0,0 +1,21 @@
1
+ # Your Dev Google Cloud project id
2
+ dev_project_id = "your-dev-project-id"
3
+
4
+ # The Google Cloud region you will use to deploy the infrastructure
5
+ region = "us-central1"
6
+
7
+ telemetry_bigquery_dataset_id = "telemetry_genai_app_sample_sink"
8
+ telemetry_sink_name = "telemetry_logs_genai_app_sample"
9
+ telemetry_logs_filter = "jsonPayload.attributes.\"traceloop.association.properties.log_type\"=\"tracing\" jsonPayload.resource.attributes.\"service.name\"=\"Sample Chatbot Application\""
10
+
11
+ feedback_bigquery_dataset_id = "feedback_genai_app_sample_sink"
12
+ feedback_sink_name = "feedback_logs_genai_app_sample"
13
+ feedback_logs_filter = "jsonPayload.log_type=\"feedback\""
14
+ {%- if cookiecutter.data_ingestion %}
15
+ search_engine_name = "sample-search-engine"
16
+ datastore_name = "sample-datastore"
17
+ vertexai_pipeline_sa_name = "vertexai-pipelines-sa"
18
+
19
+ #The value can only be one of "global", "us" and "eu".
20
+ data_store_region = "us"
21
+ {%- endif %}
@@ -0,0 +1,130 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Data source to get project numbers
16
+ data "google_project" "projects" {
17
+ for_each = local.deploy_project_ids
18
+ project_id = each.value
19
+ }
20
+
21
+ # 1. Assign roles for the CICD project
22
+ resource "google_project_iam_member" "cicd_project_roles" {
23
+ for_each = toset(var.cicd_roles)
24
+
25
+ project = var.cicd_runner_project_id
26
+ role = each.value
27
+ member = "serviceAccount:${resource.google_service_account.cicd_runner_sa.email}"
28
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
29
+
30
+ }
31
+
32
+ # 2. Assign roles for the other two projects (prod and staging)
33
+ resource "google_project_iam_member" "other_projects_roles" {
34
+ for_each = {
35
+ for pair in setproduct(keys(local.deploy_project_ids), var.cicd_sa_deployment_required_roles) :
36
+ "${pair[0]}-${pair[1]}" => {
37
+ project_id = local.deploy_project_ids[pair[0]]
38
+ role = pair[1]
39
+ }
40
+ }
41
+
42
+ project = each.value.project_id
43
+ role = each.value.role
44
+ member = "serviceAccount:${resource.google_service_account.cicd_runner_sa.email}"
45
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
46
+ }
47
+ {%- if cookiecutter.deployment_target == 'cloud_run' %}
48
+ # 3. Allow Cloud Run service SA to pull containers stored in the CICD project
49
+ resource "google_project_iam_member" "cicd_run_invoker_artifact_registry_reader" {
50
+ for_each = local.deploy_project_ids
51
+ project = var.cicd_runner_project_id
52
+
53
+ role = "roles/artifactregistry.reader"
54
+ member = "serviceAccount:service-${data.google_project.projects[each.key].number}@serverless-robot-prod.iam.gserviceaccount.com"
55
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
56
+
57
+ }
58
+
59
+ # 4. Grant Cloud Run SA the required permissions to run the application
60
+ resource "google_project_iam_member" "cloud_run_app_sa_roles" {
61
+ for_each = {
62
+ for pair in setproduct(keys(local.deploy_project_ids), var.cloud_run_app_roles) :
63
+ join(",", pair) => {
64
+ project = local.deploy_project_ids[pair[0]]
65
+ role = pair[1]
66
+ }
67
+ }
68
+
69
+ project = each.value.project
70
+ role = each.value.role
71
+ member = "serviceAccount:${google_service_account.cloud_run_app_sa[split(",", each.key)[0]].email}"
72
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
73
+ }
74
+ {%- elif cookiecutter.deployment_target == 'agent_engine' %}
75
+ resource "google_project_service_identity" "vertex_sa" {
76
+ for_each = local.deploy_project_ids
77
+ provider = google-beta
78
+ project = each.value
79
+ service = "aiplatform.googleapis.com"
80
+ }
81
+
82
+ # 3. Grant required permissions to Vertex AI Service Agent SA
83
+ resource "google_project_iam_member" "vertex_ai_sa_permissions" {
84
+ for_each = {
85
+ for pair in setproduct(keys(local.deploy_project_ids), var.agentengine_sa_roles) :
86
+ "${pair[0]}_${pair[1]}" => {
87
+ project = local.deploy_project_ids[pair[0]]
88
+ role = pair[1]
89
+ }
90
+ }
91
+
92
+ project = each.value.project
93
+ role = each.value.role
94
+ member = "serviceAccount:service-${data.google_project.projects[split("_", each.key)[0]].number}@gcp-sa-aiplatform-re.iam.gserviceaccount.com"
95
+ depends_on = [resource.google_project_service.shared_services, resource.google_project_service_identity.vertex_sa]
96
+ }
97
+ {%- endif %}
98
+
99
+ # Special assignment: Allow the CICD SA to create tokens
100
+ resource "google_service_account_iam_member" "cicd_run_invoker_token_creator" {
101
+ service_account_id = google_service_account.cicd_runner_sa.name
102
+ role = "roles/iam.serviceAccountTokenCreator"
103
+ member = "serviceAccount:${resource.google_service_account.cicd_runner_sa.email}"
104
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
105
+ }
106
+ # Special assignment: Allow the CICD SA to impersonate himself for trigger creation
107
+ resource "google_service_account_iam_member" "cicd_run_invoker_account_user" {
108
+ service_account_id = google_service_account.cicd_runner_sa.name
109
+ role = "roles/iam.serviceAccountUser"
110
+ member = "serviceAccount:${resource.google_service_account.cicd_runner_sa.email}"
111
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
112
+ }
113
+
114
+ {%- if cookiecutter.data_ingestion %}
115
+ # Grant Vertex AI SA the required permissions to run the ingestion
116
+ resource "google_project_iam_member" "vertexai_pipeline_sa_roles" {
117
+ for_each = {
118
+ for pair in setproduct(keys(local.deploy_project_ids), var.pipelines_roles) :
119
+ join(",", pair) => {
120
+ project = local.deploy_project_ids[pair[0]]
121
+ role = pair[1]
122
+ }
123
+ }
124
+
125
+ project = each.value.project
126
+ role = each.value.role
127
+ member = "serviceAccount:${google_service_account.vertexai_pipeline_app_sa[split(",", each.key)[0]].email}"
128
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
129
+ }
130
+ {%- endif %}
@@ -0,0 +1,50 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ locals {
16
+ cicd_services = [
17
+ "cloudbuild.googleapis.com",
18
+ "discoveryengine.googleapis.com",
19
+ "aiplatform.googleapis.com",
20
+ "serviceusage.googleapis.com",
21
+ "bigquery.googleapis.com",
22
+ "cloudresourcemanager.googleapis.com",
23
+ "cloudtrace.googleapis.com"
24
+ ]
25
+
26
+ shared_services = [
27
+ "aiplatform.googleapis.com",
28
+ "run.googleapis.com",
29
+ "discoveryengine.googleapis.com",
30
+ "cloudresourcemanager.googleapis.com",
31
+ "iam.googleapis.com",
32
+ "bigquery.googleapis.com",
33
+ "serviceusage.googleapis.com",
34
+ "logging.googleapis.com",
35
+ "cloudtrace.googleapis.com"
36
+ ]
37
+
38
+ deploy_project_ids = {
39
+ prod = var.prod_project_id
40
+ staging = var.staging_project_id
41
+ }
42
+
43
+ all_project_ids = [
44
+ var.cicd_runner_project_id,
45
+ var.prod_project_id,
46
+ var.staging_project_id
47
+ ]
48
+
49
+ }
50
+
@@ -0,0 +1,72 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ resource "google_project_iam_member" "bigquery_data_editor" {
16
+ for_each = local.deploy_project_ids
17
+
18
+ project = each.value
19
+ role = "roles/bigquery.dataEditor"
20
+ member = module.log_export_to_bigquery[each.key].writer_identity
21
+ }
22
+
23
+ module "log_export_to_bigquery" {
24
+ for_each = local.deploy_project_ids
25
+
26
+ source = "terraform-google-modules/log-export/google"
27
+ version = "10.0.0"
28
+
29
+ log_sink_name = var.telemetry_sink_name
30
+ parent_resource_type = "project"
31
+ parent_resource_id = each.value
32
+ destination_uri = "bigquery.googleapis.com/projects/${each.value}/datasets/${var.telemetry_bigquery_dataset_id}"
33
+ filter = var.telemetry_logs_filter
34
+ bigquery_options = { use_partitioned_tables = true }
35
+ unique_writer_identity = true
36
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
37
+
38
+ }
39
+
40
+ resource "google_bigquery_dataset" "feedback_dataset" {
41
+ for_each = local.deploy_project_ids
42
+ project = each.value
43
+ dataset_id = var.feedback_bigquery_dataset_id
44
+ friendly_name = var.feedback_bigquery_dataset_id
45
+ location = var.region
46
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
47
+
48
+ }
49
+
50
+ module "feedback_export_to_bigquery" {
51
+ for_each = local.deploy_project_ids
52
+
53
+ source = "terraform-google-modules/log-export/google"
54
+ version = "10.0.0"
55
+ log_sink_name = var.feedback_sink_name
56
+ parent_resource_type = "project"
57
+ parent_resource_id = each.value
58
+ destination_uri = "bigquery.googleapis.com/projects/${each.value}/datasets/${var.feedback_bigquery_dataset_id}"
59
+ filter = var.feedback_logs_filter
60
+ bigquery_options = { use_partitioned_tables = true }
61
+ unique_writer_identity = true
62
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services, google_bigquery_dataset.feedback_dataset]
63
+ }
64
+
65
+ resource "google_bigquery_dataset" "telemetry_logs_dataset" {
66
+ depends_on = [module.log_export_to_bigquery, module.feedback_export_to_bigquery, resource.google_project_service.shared_services]
67
+ for_each = local.deploy_project_ids
68
+ project = each.value
69
+ dataset_id = var.telemetry_bigquery_dataset_id
70
+ friendly_name = var.telemetry_bigquery_dataset_id
71
+ location = var.region
72
+ }
@@ -0,0 +1,35 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ terraform {
16
+ required_version = ">= 1.0.0"
17
+ required_providers {
18
+ google = {
19
+ source = "hashicorp/google"
20
+ version = "< 7.0.0"
21
+ }
22
+ }
23
+ }
24
+
25
+ provider "google" {
26
+ alias = "staging_billing_override"
27
+ billing_project = var.staging_project_id
28
+ user_project_override = true
29
+ }
30
+
31
+ provider "google" {
32
+ alias = "prod_billing_override"
33
+ billing_project = var.prod_project_id
34
+ user_project_override = true
35
+ }
@@ -0,0 +1,42 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ resource "google_service_account" "cicd_runner_sa" {
16
+ account_id = var.cicd_runner_sa_name
17
+ display_name = "CICD Runner SA"
18
+ project = var.cicd_runner_project_id
19
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
20
+ }
21
+ {%- if cookiecutter.deployment_target == 'cloud_run' %}
22
+ resource "google_service_account" "cloud_run_app_sa" {
23
+ for_each = local.deploy_project_ids
24
+
25
+ account_id = var.cloud_run_app_sa_name
26
+ display_name = "Cloud Run Generative AI app SA"
27
+ project = each.value
28
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
29
+ }
30
+ {%- endif %}
31
+
32
+ {%- if cookiecutter.data_ingestion %}
33
+ # Service account to run Vertex AI pipeline
34
+ resource "google_service_account" "vertexai_pipeline_app_sa" {
35
+ for_each = local.deploy_project_ids
36
+
37
+ account_id = var.vertexai_pipeline_sa_name
38
+ display_name = "Vertex AI Pipeline app SA"
39
+ project = each.value
40
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
41
+ }
42
+ {%- endif %}
@@ -0,0 +1,100 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ resource "google_storage_bucket" "bucket_load_test_results" {
16
+ name = "${var.cicd_runner_project_id}-${var.suffix_bucket_name_load_test_results}"
17
+ location = var.region
18
+ project = var.cicd_runner_project_id
19
+ uniform_bucket_level_access = true
20
+ force_destroy = true
21
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
22
+ }
23
+
24
+ resource "google_storage_bucket" "logs_data_bucket" {
25
+ for_each = toset(local.all_project_ids)
26
+ name = "${each.value}-logs-data"
27
+ location = var.region
28
+ project = each.value
29
+ uniform_bucket_level_access = true
30
+ force_destroy = true
31
+
32
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
33
+ }
34
+
35
+ {%- if cookiecutter.data_ingestion %}
36
+ resource "google_storage_bucket" "data_ingestion_pipeline_gcs_root" {
37
+ for_each = local.deploy_project_ids
38
+ name = "${each.value}-pipeline-artifacts"
39
+ location = var.region
40
+ project = each.value
41
+ uniform_bucket_level_access = true
42
+ force_destroy = true
43
+
44
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
45
+ }
46
+
47
+ resource "google_discovery_engine_data_store" "data_store_staging" {
48
+ location = var.data_store_region
49
+ project = var.staging_project_id
50
+ data_store_id = "${var.datastore_name}"
51
+ display_name = "${var.datastore_name}"
52
+ industry_vertical = "GENERIC"
53
+ content_config = "NO_CONTENT"
54
+ solution_types = ["SOLUTION_TYPE_SEARCH"]
55
+ create_advanced_site_search = false
56
+ provider = google.staging_billing_override
57
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
58
+ }
59
+
60
+ resource "google_discovery_engine_search_engine" "search_engine_staging" {
61
+ project = var.staging_project_id
62
+ engine_id = "${var.search_engine_name}"
63
+ collection_id = "default_collection"
64
+ location = google_discovery_engine_data_store.data_store_staging.location
65
+ display_name = "Search Engine App Staging"
66
+ data_store_ids = [google_discovery_engine_data_store.data_store_staging.data_store_id]
67
+ search_engine_config {
68
+ search_tier = "SEARCH_TIER_ENTERPRISE"
69
+ }
70
+ provider = google.staging_billing_override
71
+ }
72
+
73
+ resource "google_discovery_engine_data_store" "data_store_prod" {
74
+ location = var.data_store_region
75
+ project = var.prod_project_id
76
+ data_store_id = "${var.datastore_name}"
77
+ display_name = "${var.datastore_name}"
78
+ industry_vertical = "GENERIC"
79
+ content_config = "NO_CONTENT"
80
+ solution_types = ["SOLUTION_TYPE_SEARCH"]
81
+ create_advanced_site_search = false
82
+ provider = google.prod_billing_override
83
+ depends_on = [resource.google_project_service.cicd_services, resource.google_project_service.shared_services]
84
+ }
85
+
86
+ resource "google_discovery_engine_search_engine" "search_engine_prod" {
87
+ project = var.prod_project_id
88
+ engine_id = "${var.search_engine_name}"
89
+ collection_id = "default_collection"
90
+ location = google_discovery_engine_data_store.data_store_prod.location
91
+ display_name = "Search Engine App Prod"
92
+ data_store_ids = [google_discovery_engine_data_store.data_store_prod.data_store_id]
93
+ search_engine_config {
94
+ search_tier = "SEARCH_TIER_ENTERPRISE"
95
+ }
96
+ provider = google.prod_billing_override
97
+ }
98
+ {%- endif %}
99
+
100
+