Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/dictionary/retail.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workflowexecutions
4 changes: 4 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"name": "ray",
"path": ".github/workflows/dictionary/ray.txt"
},
{
"name": "retail",
"path": ".github/workflows/dictionary/retail.txt"
},
{
"name": "shell",
"path": ".github/workflows/dictionary/shell.txt"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Retail use case based on the ComfyUI reference implementation
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025 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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2025 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 {
dataflow_job_name = "${local.unique_identifier_prefix}-retail-job"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2025 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 {
template_gcs_path = "gs://${google_storage_bucket.dataflow_staging_bucket.name}/templates/aggregate.template"
df_tmp_path = "gs://${google_storage_bucket.dataflow_staging_bucket.name}/tmp"
}

resource "google_dataflow_job" "batching_dataflow" {
name = local.dataflow_job_name
region = local.cluster_region
project = google_project_service.dataflow_googleapis_com.project

template_gcs_path = local.template_gcs_path
temp_gcs_location = local.df_tmp_path

enable_streaming_engine = true
on_delete = "cancel"

depends_on = [
google_project_iam_binding.pubsub_subscriber_role,
google_project_iam_binding.pubsub_publisher_role,
google_project_iam_binding.pubsub_viewer_role,
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2025 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.

resource "google_compute_firewall" "dataflow_ingress" {
name = "dataflow-ingress"
network = local.network_cluster_network_name
direction = "INGRESS"
project = data.google_project.cluster.project_id

allow {
protocol = "tcp"
ports = ["12345-12346"]
}

source_tags = ["dataflow"]
target_tags = ["dataflow"]
}

resource "google_compute_firewall" "dataflow_egress" {
name = "dataflow-egress"
network = local.network_cluster_network_name
direction = "EGRESS"
project = data.google_project.cluster.project_id

allow {
protocol = "tcp"
ports = ["12345-12346"]
}

destination_ranges = ["10.0.0.0/8"]
target_tags = ["dataflow"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2025 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.

data "google_project" "cluster" {
project_id = local.cluster_project_id
}

resource "google_project_service" "dataflow_googleapis_com" {
disable_dependent_services = false
disable_on_destroy = false
project = data.google_project.cluster.project_id
service = "dataflow.googleapis.com"
}

resource "google_project_service" "pubsub_googleapis_com" {
disable_dependent_services = false
disable_on_destroy = false
project = data.google_project.cluster.project_id
service = "pubsub.googleapis.com"
}

resource "google_project_service" "alloydb_googleapis_com" {
disable_dependent_services = false
disable_on_destroy = false
project = data.google_project.cluster.project_id
service = "alloydb.googleapis.com"
}

resource "google_project_service" "workflows_googleapis_com" {
disable_dependent_services = false
disable_on_destroy = false
project = data.google_project.cluster.project_id
service = "workflows.googleapis.com"
}

resource "google_project_service" "workflowexecutions_googleapis_com" {

Check warning on line 47 in platforms/gke/base/use-cases/inference-ref-arch/terraform/retail/project.tf

View workflow job for this annotation

GitHub Actions / checks

Unknown word (workflowexecutions)

Check warning on line 47 in platforms/gke/base/use-cases/inference-ref-arch/terraform/retail/project.tf

View workflow job for this annotation

GitHub Actions / checks

Unknown word (workflowexecutions)
disable_dependent_services = false
disable_on_destroy = false
project = data.google_project.cluster.project_id
service = "workflowexecutions.googleapis.com"

Check warning on line 51 in platforms/gke/base/use-cases/inference-ref-arch/terraform/retail/project.tf

View workflow job for this annotation

GitHub Actions / checks

Unknown word (workflowexecutions)

Check warning on line 51 in platforms/gke/base/use-cases/inference-ref-arch/terraform/retail/project.tf

View workflow job for this annotation

GitHub Actions / checks

Unknown word (workflowexecutions)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2025 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 {
incoming_pubsub_topic_name = "${local.unique_identifier_prefix_underscore}_incoming_retail_event"
}

resource "google_pubsub_topic" "incoming_pubsub_topic" {
name = local.incoming_pubsub_topic_name
project = google_project_service.pubsub_googleapis_com.project
}

resource "google_pubsub_topic_iam_binding" "publisher_binding" {
project = google_project_service.pubsub_googleapis_com.project
topic = google_pubsub_topic.incoming_pubsub_topic.name
role = "roles/pubsub.publisher"
members = [
local.publisher_sa,
]
}

resource "google_pubsub_topic" "incoming_pubsub_dlq" {
name = "incoming_images_dlq"
project = google_project_service.pubsub_googleapis_com.project
}

resource "google_pubsub_subscription" "incoming_pubsub_subscription" {
name = "incoming_subscription_ap"
topic = google_pubsub_topic.incoming_pubsub_topic.name
project = google_project_service.pubsub_googleapis_com.project
}

resource "google_pubsub_topic" "workflow1_pubsub_topic" {
name = "workflow1_pubsub_topic"
project = google_project_service.pubsub_googleapis_com.project
}

resource "google_pubsub_subscription" "incoming_dlq_subscription" {
name = "${google_pubsub_subscription.incoming_pubsub_subscription.name}_dlq"
topic = google_pubsub_topic.incoming_pubsub_dlq.id
project = google_project_service.pubsub_googleapis_com.project
expiration_policy {
ttl = ""
}
}

resource "google_pubsub_topic_iam_binding" "incoming_dlq_grant_publish" {
topic = google_pubsub_topic.incoming_pubsub_dlq.id
role = "roles/pubsub.publisher"
members = [
local.pubsub_sa_name,
]
project = google_project_service.pubsub_googleapis_com.project
}

resource "google_pubsub_subscription_iam_binding" "incoming_grant_subscribe" {
subscription = google_pubsub_subscription.incoming_pubsub_subscription.name
role = "roles/pubsub.subscriber"
members = [
local.pubsub_sa_name,
]
project = google_project_service.pubsub_googleapis_com.project
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2025 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 {
dataflow_staging_bucket = "${local.unique_identifier_prefix}-dataflow-staging"
batches_bucket = "${local.unique_identifier_prefix}-batches"
}

resource "google_storage_bucket" "batches_bucket" {
name = local.batches_bucket
location = local.cluster_region
project = data.google_project.cluster.project_id
public_access_prevention = "enforced"
uniform_bucket_level_access = true

lifecycle_rule {
action {
type = "Delete"
}
condition {
age = 7
}
}
}

resource "google_storage_bucket" "dataflow_staging_bucket" {
name = local.dataflow_staging_bucket
location = local.cluster_region
project = data.google_project.cluster.project_id
public_access_prevention = "enforced"
uniform_bucket_level_access = true

hierarchical_namespace {
enabled = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2025 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.

terraform {
required_version = ">= 1.5.7"

required_providers {
google = {
source = "hashicorp/google"
version = "6.49.2"
}
}

provider_meta "google" {
module_name = "cloud-solutions/retail_deploy-v1"
}
}
Loading