|
| 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 | +} |
0 commit comments