Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.25
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down Expand Up @@ -77,9 +77,10 @@ docker_test_lint:
.PHONY: docker_generate_docs
docker_generate_docs:
docker run --rm -it \
-e ENABLE_BPMETADATA=1 \
-v "$(CURDIR)":/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display --per-module-requirements'

# Alias for backwards compatibility
.PHONY: generate_docs
Expand Down
16 changes: 16 additions & 0 deletions examples/simple_workflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| project\_id | The ID of the project in which to provision resources. | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| project\_id | Google Cloud project in which the workflow is deployed |
| revision\_id | The revision\_id of the workflow. |
| workflow\_id | The id of the workflow. |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
50 changes: 50 additions & 0 deletions examples/simple_workflow/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* 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.
*/

module "service_account" {
source = "terraform-google-modules/service-accounts/google"
version = "~> 4.1.1"
project_id = var.project_id
prefix = "simple-workflow"
names = ["simple"]
project_roles = ["${var.project_id}=>roles/workflows.invoker"]
}

module "standalone_workflow" {
source = "../../modules/simple_workflow"

project_id = var.project_id
workflow_name = "standalone-workflow"
location = "us-central1"
service_account_email = module.service_account.email
workflow_source = <<-EOF
# This is a sample workflow that simply reads wikipedia
# Note that $$ is needed for Terraform

main:
steps:
- readWikipedia:
call: http.get
args:
url: https://en.wikipedia.org/w/api.php
query:
action: opensearch
search: GoogleCloudPlatform
result: wikiResult
- returnOutput:
return: $${wikiResult.body[1]}
EOF
}
30 changes: 30 additions & 0 deletions examples/simple_workflow/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* 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.
*/

output "workflow_id" {
description = "The id of the workflow."
value = module.standalone_workflow.workflow_id
}

output "revision_id" {
description = "The revision_id of the workflow."
value = module.standalone_workflow.revision_id
}

output "project_id" {
description = "Google Cloud project in which the workflow is deployed"
value = var.project_id
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is for use in test, lets use GetTFSetupStringOutput("project_id") to retrieve it rather than redirecting inputs as outputs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is for use in test, lets use GetTFSetupStringOutput("project_id") to retrieve it rather than redirecting inputs as outputs

updated to use GetTFSetupStringOutput

20 changes: 20 additions & 0 deletions examples/simple_workflow/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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.
*/

variable "project_id" {
description = "The ID of the project in which to provision resources."
type = string
}
25 changes: 25 additions & 0 deletions examples/simple_workflow/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can omit this for examples

required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.0"
}
}
required_version = ">= 0.13"
}
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ resource "google_cloud_scheduler_job" "workflow" {
count = local.enable_scheduler
project = var.project_id
name = var.workflow_trigger.cloud_scheduler.name
description = "Cloud Scheduler for Workflow Jpb"
description = "Cloud Scheduler for Workflow Job"
schedule = var.workflow_trigger.cloud_scheduler.cron
time_zone = var.workflow_trigger.cloud_scheduler.time_zone
attempt_deadline = var.workflow_trigger.cloud_scheduler.deadline
Expand Down
56 changes: 56 additions & 0 deletions metadata.display.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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.

apiVersion: blueprints.cloud.google.com/v1alpha1
kind: BlueprintMetadata
metadata:
name: terraform-google-cloud-workflow-display
annotations:
config.kubernetes.io/local-config: "true"
spec:
info:
title: terraform-google-cloud-workflow
source:
repo: https://github.com/GoogleCloudPlatform/terraform-google-cloud-workflows.git
sourceType: git
ui:
input:
variables:
project_id:
name: project_id
title: Project Id
region:
name: region
title: Region
service_account_create:
name: service_account_create
title: Service Account Create
service_account_email:
name: service_account_email
title: Service Account Email
workflow_description:
name: workflow_description
title: Workflow Description
workflow_labels:
name: workflow_labels
title: Workflow Labels
workflow_name:
name: workflow_name
title: Workflow Name
workflow_source:
name: workflow_source
title: Workflow Source
workflow_trigger:
name: workflow_trigger
title: Workflow Trigger
Loading