Skip to content

Commit 3b177bf

Browse files
committed
chore: Adding Submodule for Standalone Workflow for ADC
- Added Submodule for Standalone workflow - Added Validations and metadata.display.yaml file for making submodule ADC compliant - Added relevant examples and test
1 parent f8b2ca4 commit 3b177bf

File tree

21 files changed

+968
-108
lines changed

21 files changed

+968
-108
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Make will use bash instead of sh
1919
SHELL := /usr/bin/env bash
2020

21-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.25
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

@@ -77,9 +77,10 @@ docker_test_lint:
7777
.PHONY: docker_generate_docs
7878
docker_generate_docs:
7979
docker run --rm -it \
80+
-e ENABLE_BPMETADATA=1 \
8081
-v "$(CURDIR)":/workspace \
8182
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
82-
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
83+
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display'
8384

8485
# Alias for backwards compatibility
8586
.PHONY: generate_docs

examples/simple_workflow/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2+
## Inputs
3+
4+
| Name | Description | Type | Default | Required |
5+
|------|-------------|------|---------|:--------:|
6+
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |
7+
8+
## Outputs
9+
10+
| Name | Description |
11+
|------|-------------|
12+
| gcs\_bucket | Name of GCS Bucket. |
13+
| workflow\_id | The id of the workflow. |
14+
| workflow\_region | The id of the workflow. |
15+
| workflow\_revision\_id | The revision\_id of the workflow. |
16+
17+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/simple_workflow/main.tf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
data "google_compute_default_service_account" "default" {
18+
project = var.project_id
19+
}
20+
21+
resource "random_string" "string" {
22+
length = 8
23+
lower = true
24+
upper = false
25+
special = false
26+
numeric = false
27+
}
28+
29+
module "gcs_buckets" {
30+
source = "terraform-google-modules/cloud-storage/google"
31+
version = "~> 3.4.0"
32+
location = "us-central1"
33+
project_id = var.project_id
34+
names = ["wf-bucket"]
35+
prefix = random_string.string.result
36+
set_admin_roles = true
37+
admins = ["serviceAccount:${data.google_compute_default_service_account.default.email}"]
38+
force_destroy = { wf-bucket = true }
39+
}
40+
41+
module "standalone_workflow" {
42+
source = "../../modules/simple_workflow"
43+
44+
project_id = var.project_id
45+
workflow_name = "standalone-workflow"
46+
region = "us-central1"
47+
service_account_email = data.google_compute_default_service_account.default.email
48+
service_account_create = true
49+
workflow_source = <<-EOF
50+
# This is a sample workflow that simply reads wikipedia
51+
# Note that $$ is needed for Terraform
52+
53+
main:
54+
steps:
55+
- readWikipedia:
56+
call: http.get
57+
args:
58+
url: https://en.wikipedia.org/w/api.php
59+
query:
60+
action: opensearch
61+
search: GoogleCloudPlatform
62+
result: wikiResult
63+
- returnOutput:
64+
return: $${wikiResult.body[1]}
65+
EOF
66+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "gcs_bucket" {
18+
description = "Name of GCS Bucket."
19+
value = module.gcs_buckets.bucket.name
20+
}
21+
22+
output "workflow_id" {
23+
description = "The id of the workflow."
24+
value = module.standalone_workflow.workflow_id
25+
}
26+
27+
output "workflow_region" {
28+
description = "The id of the workflow."
29+
value = module.standalone_workflow.workflow_region
30+
}
31+
32+
output "workflow_revision_id" {
33+
description = "The revision_id of the workflow."
34+
value = module.standalone_workflow.workflow_revision_id
35+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "project_id" {
18+
description = "The ID of the project in which to provision resources."
19+
type = string
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
terraform {
18+
required_providers {
19+
google = {
20+
source = "hashicorp/google"
21+
version = "~> 4.0"
22+
}
23+
24+
random = {
25+
version = "~> 3.4.3"
26+
}
27+
}
28+
required_version = ">= 0.13"
29+
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ resource "google_cloud_scheduler_job" "workflow" {
7272
count = local.enable_scheduler
7373
project = var.project_id
7474
name = var.workflow_trigger.cloud_scheduler.name
75-
description = "Cloud Scheduler for Workflow Jpb"
75+
description = "Cloud Scheduler for Workflow Job"
7676
schedule = var.workflow_trigger.cloud_scheduler.cron
7777
time_zone = var.workflow_trigger.cloud_scheduler.time_zone
7878
attempt_deadline = var.workflow_trigger.cloud_scheduler.deadline

metadata.display.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
apiVersion: blueprints.cloud.google.com/v1alpha1
16+
kind: BlueprintMetadata
17+
metadata:
18+
name: terraform-google-cloud-workflow-display
19+
annotations:
20+
config.kubernetes.io/local-config: "true"
21+
spec:
22+
info:
23+
title: terraform-google-cloud-workflow
24+
source:
25+
repo: https://github.com/GoogleCloudPlatform/terraform-google-cloud-workflows.git
26+
sourceType: git
27+
ui:
28+
input:
29+
variables:
30+
project_id:
31+
name: project_id
32+
title: Project Id
33+
region:
34+
name: region
35+
title: Region
36+
service_account_create:
37+
name: service_account_create
38+
title: Service Account Create
39+
service_account_email:
40+
name: service_account_email
41+
title: Service Account Email
42+
workflow_description:
43+
name: workflow_description
44+
title: Workflow Description
45+
workflow_labels:
46+
name: workflow_labels
47+
title: Workflow Labels
48+
workflow_name:
49+
name: workflow_name
50+
title: Workflow Name
51+
workflow_source:
52+
name: workflow_source
53+
title: Workflow Source
54+
workflow_trigger:
55+
name: workflow_trigger
56+
title: Workflow Trigger

0 commit comments

Comments
 (0)