diff --git a/products/notebooks/api.yaml b/products/notebooks/api.yaml index 8a15a0c00f73..f65944db16fa 100644 --- a/products/notebooks/api.yaml +++ b/products/notebooks/api.yaml @@ -18,6 +18,9 @@ versions: - !ruby/object:Api::Product::Version name: beta base_url: https://notebooks.googleapis.com/v1beta1/ + - !ruby/object:Api::Product::Version + name: ga + base_url: https://notebooks.googleapis.com/v1/ scopes: - https://www.googleapis.com/auth/cloud-platform apis_required: @@ -47,7 +50,6 @@ objects: name: 'Environment' description: | A Cloud AI Platform Notebook environment. - min_version: beta base_url: projects/{{project}}/locations/{{location}}/environments create_url: projects/{{project}}/locations/{{location}}/environments?environmentId={{name}} self_link: projects/{{project}}/locations/{{location}}/environments/{{name}} @@ -136,7 +138,6 @@ objects: name: 'Instance' description: | A Cloud AI Platform Notebook instance. - min_version: beta base_url: projects/{{project}}/locations/{{location}}/instances create_url: projects/{{project}}/locations/{{location}}/instances?instanceId={{name}} self_link: projects/{{project}}/locations/{{location}}/instances/{{name}} diff --git a/products/notebooks/terraform.yaml b/products/notebooks/terraform.yaml index fe9e3745150a..c81e4556cbf2 100644 --- a/products/notebooks/terraform.yaml +++ b/products/notebooks/terraform.yaml @@ -21,7 +21,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb examples: - !ruby/object:Provider::Terraform::Examples - min_version: beta name: "notebook_environment_basic" primary_resource_id: "environment" vars: @@ -34,27 +33,31 @@ overrides: !ruby/object:Overrides::ResourceOverrides autogen_async: true examples: - !ruby/object:Provider::Terraform::Examples - min_version: beta name: "notebook_instance_basic" primary_resource_id: "instance" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])" + region_override: "us-west1-a" vars: instance_name: "notebooks-instance" - !ruby/object:Provider::Terraform::Examples - min_version: beta name: "notebook_instance_basic_container" primary_resource_id: "instance" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])" + region_override: "us-west1-a" vars: instance_name: "notebooks-instance" - !ruby/object:Provider::Terraform::Examples - min_version: beta name: "notebook_instance_basic_gpu" primary_resource_id: "instance" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])" + region_override: "us-west1-a" vars: instance_name: "notebooks-instance" - !ruby/object:Provider::Terraform::Examples - min_version: beta name: "notebook_instance_full" primary_resource_id: "instance" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])" + region_override: "us-west1-a" vars: instance_name: "notebooks-instance" test_env_vars: @@ -90,11 +93,11 @@ overrides: !ruby/object:Overrides::ResourceOverrides # but it gets merged with metadata that the server sets. This prevents us # from detecting drift. ignore_read: true - name: !ruby/object:Overrides::Terraform::PropertyOverride + name: !ruby/object:Overrides::Terraform::PropertyOverride custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb' network: !ruby/object:Overrides::Terraform::PropertyOverride diff_suppress_func: compareSelfLinkOrResourceName - default_from_api: true + default_from_api: true serviceAccount: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true subnet: !ruby/object:Overrides::Terraform::PropertyOverride diff --git a/provider/terraform/examples.rb b/provider/terraform/examples.rb index be8c6c379740..5a94b57c4318 100644 --- a/provider/terraform/examples.rb +++ b/provider/terraform/examples.rb @@ -120,6 +120,11 @@ class Examples < Api::Object # a reference to the primary resource to create IAM policies for attr_reader :primary_resource_name + # The name of the location/region override for use in IAM tests. IAM + # tests may need this if the location is not inherited on the resource + # for one reason or another + attr_reader :region_override + # The path to this example's Terraform config. # Defaults to `templates/terraform/examples/{{name}}.tf.erb` attr_reader :config_path diff --git a/templates/terraform/examples/base_configs/iam_test_file.go.erb b/templates/terraform/examples/base_configs/iam_test_file.go.erb index e4a212b7abea..028765eb3387 100644 --- a/templates/terraform/examples/base_configs/iam_test_file.go.erb +++ b/templates/terraform/examples/base_configs/iam_test_file.go.erb @@ -47,7 +47,11 @@ import_url = import_format.gsub(/({{)(\w+)(}})/, '%s').gsub(object.__product.bas <% elsif param == 'zone' -%> <% import_qualifiers.push('getTestZoneFromEnv()') -%> <% elsif param == 'region' || param == 'location' -%> - <% import_qualifiers.push('getTestRegionFromEnv()') -%> + <% if example.region_override.nil? -%> + <% import_qualifiers.push('getTestRegionFromEnv()') -%> + <% else -%> + <% import_qualifiers.push("\"#{example.region_override}\"") -%> + <% end -%> <% end -%> <% end -%> func TestAcc<%= resource_name -%>IamBindingGenerated(t *testing.T) { @@ -404,7 +408,7 @@ func testAcc<%= resource_name -%>IamBinding_basicGenerated(context map[string]in <%= example.config_test_body(pwd) -%> resource "<%= resource_ns_iam -%>_binding" "foo" { -<% unless object.min_version.name == "ga" -%> +<% unless object.min_version.name == "ga" -%> provider = google-beta <% end -%> <%= lines(compile(pwd + '/' + object.iam_policy.example_config_body)) -%> diff --git a/templates/terraform/examples/notebook_instance_basic.tf.erb b/templates/terraform/examples/notebook_instance_basic.tf.erb index 944f86df474d..6586b33cf4ea 100644 --- a/templates/terraform/examples/notebook_instance_basic.tf.erb +++ b/templates/terraform/examples/notebook_instance_basic.tf.erb @@ -1,5 +1,4 @@ resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta name = "<%= ctx[:vars]["instance_name"] %>" location = "us-west1-a" machine_type = "e2-medium" diff --git a/templates/terraform/examples/notebook_instance_basic_container.tf.erb b/templates/terraform/examples/notebook_instance_basic_container.tf.erb index 5b5eaca0328c..0d93d9a5a3db 100644 --- a/templates/terraform/examples/notebook_instance_basic_container.tf.erb +++ b/templates/terraform/examples/notebook_instance_basic_container.tf.erb @@ -1,5 +1,4 @@ resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta name = "<%= ctx[:vars]["instance_name"] %>" location = "us-west1-a" machine_type = "e2-medium" diff --git a/templates/terraform/examples/notebook_instance_basic_gpu.tf.erb b/templates/terraform/examples/notebook_instance_basic_gpu.tf.erb index 16e02533b040..10ecfea6b54b 100644 --- a/templates/terraform/examples/notebook_instance_basic_gpu.tf.erb +++ b/templates/terraform/examples/notebook_instance_basic_gpu.tf.erb @@ -1,5 +1,4 @@ resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta name = "<%= ctx[:vars]["instance_name"] %>" location = "us-west1-a" machine_type = "n1-standard-1" // can't be e2 because of accelerator diff --git a/templates/terraform/examples/notebook_instance_full.tf.erb b/templates/terraform/examples/notebook_instance_full.tf.erb index be236934331c..1e6b20c7d152 100644 --- a/templates/terraform/examples/notebook_instance_full.tf.erb +++ b/templates/terraform/examples/notebook_instance_full.tf.erb @@ -1,5 +1,4 @@ resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { - provider = google-beta name = "<%= ctx[:vars]["instance_name"] %>" location = "us-central1-a" machine_type = "e2-medium"