diff --git a/mmv1/products/workflows/Workflow.yaml b/mmv1/products/workflows/Workflow.yaml index e6f5600c6f68..49d731e2ac92 100644 --- a/mmv1/products/workflows/Workflow.yaml +++ b/mmv1/products/workflows/Workflow.yaml @@ -41,14 +41,6 @@ examples: name: 'workflow' account_id: 'my-account' skip_import_test: true - - !ruby/object:Provider::Terraform::Examples - name: 'workflow_beta' - primary_resource_id: 'example_beta' - vars: - name: 'workflow_beta' - account_id: 'my-account' - skip_import_test: true - min_version: 'beta' custom_code: !ruby/object:Provider::Terraform::CustomCode extra_schema_entry: templates/terraform/extra_schema_entry/workflow.erb encoder: templates/terraform/encoders/workflow.go.erb @@ -118,6 +110,5 @@ properties: Format: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey} - !ruby/object:Api::Type::KeyValuePairs name: 'userEnvVars' - min_version: beta description: | User-defined environment variables associated with this workflow revision. This map has a maximum length of 20. Each string can take up to 40KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or “WORKFLOWS". diff --git a/mmv1/templates/terraform/examples/workflow_basic.tf.erb b/mmv1/templates/terraform/examples/workflow_basic.tf.erb index 1ec0cc3b67ca..8ed99e697d2f 100644 --- a/mmv1/templates/terraform/examples/workflow_basic.tf.erb +++ b/mmv1/templates/terraform/examples/workflow_basic.tf.erb @@ -11,6 +11,9 @@ resource "google_workflows_workflow" "<%= ctx[:primary_resource_id] %>" { 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. # @@ -26,7 +29,7 @@ resource "google_workflows_workflow" "<%= ctx[:primary_resource_id] %>" { - getCurrentTime: call: http.get args: - url: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam + url: $${sys.get_env("url")} result: currentTime - readWikipedia: call: http.get diff --git a/mmv1/templates/terraform/examples/workflow_beta.tf.erb b/mmv1/templates/terraform/examples/workflow_beta.tf.erb deleted file mode 100644 index 76a1fdcc3da9..000000000000 --- a/mmv1/templates/terraform/examples/workflow_beta.tf.erb +++ /dev/null @@ -1,47 +0,0 @@ -resource "google_service_account" "test_account" { - provider = google-beta - account_id = "<%= ctx[:vars]['account_id'] %>" - display_name = "Test Service Account" -} - -resource "google_workflows_workflow" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta - name = "<%= ctx[:vars]['name'] %>" - region = "us-central1" - description = "Magic" - service_account = google_service_account.test_account.id - labels = { - env = "test" - } - user_env_vars = { - foo = "BAR" - } - 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: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam - 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 -} diff --git a/mmv1/third_party/terraform/services/workflows/resource_workflows_workflow_test.go.erb b/mmv1/third_party/terraform/services/workflows/resource_workflows_workflow_test.go.erb index 47330729fb86..c3a58e4a2bbc 100644 --- a/mmv1/third_party/terraform/services/workflows/resource_workflows_workflow_test.go.erb +++ b/mmv1/third_party/terraform/services/workflows/resource_workflows_workflow_test.go.erb @@ -40,6 +40,9 @@ resource "google_workflows_workflow" "example" { name = "%s" region = "us-central1" description = "Magic" + user_env_vars = { + url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam" + } source_contents = <<-EOF # This is a sample workflow, feel free to replace it with your source code # @@ -54,7 +57,7 @@ resource "google_workflows_workflow" "example" { - getCurrentTime: call: http.get args: - url: https://us-central1-workflowsample.cloudfunctions.net/datetime + url: $${sys.get_env("url")} result: CurrentDateTime - readWikipedia: call: http.get @@ -77,6 +80,9 @@ resource "google_workflows_workflow" "example" { name = "%s" region = "us-central1" description = "Magic" + user_env_vars = { + url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam" + } source_contents = <<-EOF # This is a sample workflow, feel free to replace it with your source code # @@ -91,7 +97,7 @@ resource "google_workflows_workflow" "example" { - getCurrentTime: call: http.get args: - url: https://us-central1-workflowsample.cloudfunctions.net/datetime + url: $${sys.get_env("url")} result: CurrentDateTime - readWikipedia: call: http.get @@ -213,132 +219,3 @@ EOF `, workflowName, kmsKeyName) } -<% unless version == 'ga' -%> -func TestAccWorkflowsWorkflowBeta_update(t *testing.T) { - // custom test to test updating - t.Parallel() - - context := map[string]interface{}{ - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckWorkflowsWorkflowDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccWorkflowsWorkflowBeta_full(context), - }, - { - Config: testAccWorkflowsWorkflowBeta_update(context), - }, - }, - }) -} - - -func testAccWorkflowsWorkflowBeta_full(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_service_account" "test_account" { - provider = google-beta - account_id = "tf-test-my-account%{random_suffix}" - display_name = "Test Service Account" -} - -resource "google_workflows_workflow" "example_beta" { - provider = google-beta - name = "tf_test_workflow_beta%{random_suffix}" - region = "us-central1" - description = "Magic" - service_account = google_service_account.test_account.id - labels = { - env = "test" - } - user_env_vars = { - foo = "BAR" - } - 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: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam - 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 -} -`, context) -} - -func testAccWorkflowsWorkflowBeta_update(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_service_account" "test_account" { - provider = google-beta - account_id = "tf-test-my-account%{random_suffix}" - display_name = "Test Service Account" -} - -resource "google_workflows_workflow" "example_beta" { - provider = google-beta - name = "tf_test_workflow_beta%{random_suffix}" - region = "us-central1" - description = "Magic" - service_account = google_service_account.test_account.id - labels = { - env = "dev" - } - user_env_vars = { - bar = "FOO" - } - 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: https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam - 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 -} -`, context) -} -<% end -%>