|
| 1 | +data "google_project" "project" { |
| 2 | +} |
| 3 | + |
| 4 | +resource "google_tags_tag_key" "tag_key" { |
| 5 | + parent = "projects/${data.google_project.project.number}" |
| 6 | + short_name = "{{index $.Vars "tag_key"}}" |
| 7 | +} |
| 8 | + |
| 9 | +resource "google_tags_tag_value" "tag_value" { |
| 10 | + parent = "tagKeys/${google_tags_tag_key.tag_key.name}" |
| 11 | + short_name = "{{index $.Vars "tag_value"}}" |
| 12 | +} |
| 13 | + |
| 14 | +resource "google_service_account" "test_account" { |
| 15 | + account_id = "{{index $.Vars "account_id"}}" |
| 16 | + display_name = "Test Service Account" |
| 17 | +} |
| 18 | + |
| 19 | +resource "google_workflows_workflow" "{{$.PrimaryResourceId}}" { |
| 20 | + name = "{{index $.Vars "name"}}" |
| 21 | + region = "us-central1" |
| 22 | + description = "Magic" |
| 23 | + service_account = google_service_account.test_account.id |
| 24 | + deletion_protection = false |
| 25 | + tags = { |
| 26 | + "${data.google_project.project.project_id}/${google_tags_tag_key.tag_key.short_name}" = "${google_tags_tag_value.tag_value.short_name}" |
| 27 | + } |
| 28 | + source_contents = <<-EOF |
| 29 | + # This is a sample workflow. You can replace it with your source code. |
| 30 | + # |
| 31 | + # This workflow does the following: |
| 32 | + # - reads current time and date information from an external API and stores |
| 33 | + # the response in currentTime variable |
| 34 | + # - retrieves a list of Wikipedia articles related to the day of the week |
| 35 | + # from currentTime |
| 36 | + # - returns the list of articles as an output of the workflow |
| 37 | + # |
| 38 | + # Note: In Terraform you need to escape the $$ or it will cause errors. |
| 39 | + |
| 40 | + - getCurrentTime: |
| 41 | + call: http.get |
| 42 | + args: |
| 43 | + url: $${sys.get_env("url")} |
| 44 | + result: currentTime |
| 45 | + - readWikipedia: |
| 46 | + call: http.get |
| 47 | + args: |
| 48 | + url: https://en.wikipedia.org/w/api.php |
| 49 | + query: |
| 50 | + action: opensearch |
| 51 | + search: $${currentTime.body.dayOfWeek} |
| 52 | + result: wikiResult |
| 53 | + - returnOutput: |
| 54 | + return: $${wikiResult.body[1]} |
| 55 | +EOF |
| 56 | +} |
0 commit comments