| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Workflows" |
| description: |- |
| Workflow program to be executed by Workflows. |
| --- |
| |
| # google\_workflows\_workflow |
| |
| Workflow program to be executed by Workflows. |
| |
| |
| To get more information about Workflow, see: |
| |
| * [API documentation](https://cloud.google.com/workflows/docs/reference/rest/v1/projects.locations.workflows) |
| * How-to Guides |
| * [Managing Workflows](https://cloud.google.com/workflows/docs/creating-updating-workflow) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=workflow_basic&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Workflow Basic |
| |
| |
| ```hcl |
| resource "google_service_account" "test_account" { |
| account_id = "my-account" |
| display_name = "Test Service Account" |
| } |
| |
| resource "google_workflows_workflow" "example" { |
| name = "workflow" |
| region = "us-central1" |
| description = "Magic" |
| service_account = google_service_account.test_account.id |
| call_log_level = "LOG_ERRORS_ONLY" |
| labels = { |
| env = "test" |
| } |
| user_env_vars = { |
| url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam" |
| } |
| source_contents = <<-EOF |
| # This is a sample workflow. You can replace it with your source code. |
| # |
| # This workflow does the following: |
| # - reads current time and date information from an external API and stores |
| # the response in currentTime variable |
| # - retrieves a list of Wikipedia articles related to the day of the week |
| # from currentTime |
| # - returns the list of articles as an output of the workflow |
| # |
| # Note: In Terraform you need to escape the $$ or it will cause errors. |
| |
| - getCurrentTime: |
| call: http.get |
| args: |
| url: $${sys.get_env("url")} |
| result: currentTime |
| - readWikipedia: |
| call: http.get |
| args: |
| url: https://en.wikipedia.org/w/api.php |
| query: |
| action: opensearch |
| search: $${currentTime.body.dayOfWeek} |
| result: wikiResult |
| - returnOutput: |
| return: $${wikiResult.body[1]} |
| EOF |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| |
| - - - |
| |
| |
| * `name` - |
| (Optional) |
| Name of the Workflow. |
| |
| * `description` - |
| (Optional) |
| Description of the workflow provided by the user. Must be at most 1000 unicode characters long. |
| |
| * `labels` - |
| (Optional) |
| A set of key/value label pairs to assign to this Workflow. |
| |
| **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. |
| Please refer to the field `effective_labels` for all of the labels present on the resource. |
| |
| * `service_account` - |
| (Optional) |
| Name of the service account associated with the latest workflow version. This service |
| account represents the identity of the workflow and determines what permissions the workflow has. |
| Format: projects/{project}/serviceAccounts/{account} or {account}. |
| Using - as a wildcard for the {project} or not providing one at all will infer the project from the account. |
| The {account} value can be the email address or the unique_id of the service account. |
| If not provided, workflow will use the project's default service account. |
| Modifying this field for an existing workflow results in a new workflow revision. |
| |
| * `source_contents` - |
| (Optional) |
| Workflow code to be executed. The size limit is 128KB. |
| |
| * `crypto_key_name` - |
| (Optional) |
| The KMS key used to encrypt workflow and execution data. |
| Format: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} |
| |
| * `call_log_level` - |
| (Optional) |
| Describes the level of platform logging to apply to calls and call responses during |
| executions of this workflow. If both the workflow and the execution specify a logging level, |
| the execution level takes precedence. |
| Possible values are: `CALL_LOG_LEVEL_UNSPECIFIED`, `LOG_ALL_CALLS`, `LOG_ERRORS_ONLY`, `LOG_NONE`. |
| |
| * `user_env_vars` - |
| (Optional) |
| User-defined environment variables associated with this workflow revision. This map has a maximum length of 20. Each string can take up to 4KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or “WORKFLOWS". |
| |
| * `region` - |
| (Optional) |
| The region of the workflow. |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| * `name_prefix` - (Optional) Creates a unique name beginning with the |
| specified prefix. If this and name are unspecified, a random value is chosen for the name. |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/locations/{{region}}/workflows/{{name}}` |
| |
| * `create_time` - |
| The timestamp of when the workflow was created in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. |
| |
| * `update_time` - |
| The timestamp of when the workflow was last updated in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. |
| |
| * `state` - |
| State of the workflow deployment. |
| |
| * `revision_id` - |
| The revision of the workflow. A new one is generated if the service account or source contents is changed. |
| |
| * `terraform_labels` - |
| The combination of labels configured directly on the resource |
| and default labels configured on the provider. |
| |
| * `effective_labels` - |
| All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. |
| |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| This resource does not support import. |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |