|
101 | 101 | `, context)
|
102 | 102 | }
|
103 | 103 |
|
| 104 | +func TestAccWorkflowsWorkflow_workflowTagsExample(t *testing.T) { |
| 105 | + t.Parallel() |
| 106 | + |
| 107 | + context := map[string]interface{}{ |
| 108 | + "random_suffix": acctest.RandString(t, 10), |
| 109 | + } |
| 110 | + |
| 111 | + acctest.VcrTest(t, resource.TestCase{ |
| 112 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 113 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 114 | + CheckDestroy: testAccCheckWorkflowsWorkflowDestroyProducer(t), |
| 115 | + Steps: []resource.TestStep{ |
| 116 | + { |
| 117 | + Config: testAccWorkflowsWorkflow_workflowTagsExample(context), |
| 118 | + }, |
| 119 | + }, |
| 120 | + }) |
| 121 | +} |
| 122 | + |
| 123 | +func testAccWorkflowsWorkflow_workflowTagsExample(context map[string]interface{}) string { |
| 124 | + return acctest.Nprintf(` |
| 125 | +data "google_project" "project" { |
| 126 | +} |
| 127 | +
|
| 128 | +resource "google_tags_tag_key" "tag_key" { |
| 129 | + parent = "projects/${data.google_project.project.number}" |
| 130 | + short_name = "tf_test_tag_key%{random_suffix}" |
| 131 | +} |
| 132 | +
|
| 133 | +resource "google_tags_tag_value" "tag_value" { |
| 134 | + parent = "tagKeys/${google_tags_tag_key.tag_key.name}" |
| 135 | + short_name = "tf_test_tag_value%{random_suffix}" |
| 136 | +} |
| 137 | +
|
| 138 | +resource "google_service_account" "test_account" { |
| 139 | + account_id = "tf-test-my-account%{random_suffix}" |
| 140 | + display_name = "Test Service Account" |
| 141 | +} |
| 142 | +
|
| 143 | +resource "google_workflows_workflow" "example" { |
| 144 | + name = "workflow%{random_suffix}" |
| 145 | + region = "us-central1" |
| 146 | + description = "Magic" |
| 147 | + service_account = google_service_account.test_account.id |
| 148 | + deletion_protection = false |
| 149 | + tags = { |
| 150 | + "${data.google_project.project.project_id}/${google_tags_tag_key.tag_key.short_name}" = "${google_tags_tag_value.tag_value.short_name}" |
| 151 | + } |
| 152 | + source_contents = <<-EOF |
| 153 | + # This is a sample workflow. You can replace it with your source code. |
| 154 | + # |
| 155 | + # This workflow does the following: |
| 156 | + # - reads current time and date information from an external API and stores |
| 157 | + # the response in currentTime variable |
| 158 | + # - retrieves a list of Wikipedia articles related to the day of the week |
| 159 | + # from currentTime |
| 160 | + # - returns the list of articles as an output of the workflow |
| 161 | + # |
| 162 | + # Note: In Terraform you need to escape the $$ or it will cause errors. |
| 163 | +
|
| 164 | + - getCurrentTime: |
| 165 | + call: http.get |
| 166 | + args: |
| 167 | + url: $${sys.get_env("url")} |
| 168 | + result: currentTime |
| 169 | + - readWikipedia: |
| 170 | + call: http.get |
| 171 | + args: |
| 172 | + url: https://en.wikipedia.org/w/api.php |
| 173 | + query: |
| 174 | + action: opensearch |
| 175 | + search: $${currentTime.body.dayOfWeek} |
| 176 | + result: wikiResult |
| 177 | + - returnOutput: |
| 178 | + return: $${wikiResult.body[1]} |
| 179 | +EOF |
| 180 | +} |
| 181 | +`, context) |
| 182 | +} |
| 183 | + |
104 | 184 | func testAccCheckWorkflowsWorkflowDestroyProducer(t *testing.T) func(s *terraform.State) error {
|
105 | 185 | return func(s *terraform.State) error {
|
106 | 186 | for name, rs := range s.RootModule().Resources {
|
|
0 commit comments