Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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'

# 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 |
|------|-------------|
| workflow\_id | The id of the workflow. |
| workflow\_region | The id of the workflow. |
| workflow\_revision\_id | The revision\_id of the workflow. |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
51 changes: 51 additions & 0 deletions examples/simple_workflow/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* 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"
region = "us-central1"
service_account_email = module.service_account.email
service_account_create = true

Choose a reason for hiding this comment

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

I think this test/example should be renamed to something like with_service_account_auto_create and we should add more test to cover other scenarios related to service_account input.
Tests can be added later also.

Copy link
Member Author

Choose a reason for hiding this comment

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

as we have removed autocreate SA logic, this will be not required

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 "workflow_region" {
description = "The id of the workflow."
value = module.standalone_workflow.workflow_region
}

output "workflow_revision_id" {
description = "The revision_id of the workflow."
value = module.standalone_workflow.workflow_revision_id
}
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