From 127027fb175033d97d86cb241af0ba2ba9fa0729 Mon Sep 17 00:00:00 2001 From: xuchenma <67921399+xuchenma@users.noreply.github.com> Date: Tue, 24 Oct 2023 12:01:54 -0700 Subject: [PATCH] Add support for type in ApigeeEnvironment; remove obsolete broken test (#9340) --- mmv1/products/apigee/Environment.yaml | 15 +- ...rb => apigee_environment_type_test.tf.erb} | 5 +- ..._apigee_environment_nodeconfig_test.go.erb | 182 ------------------ 3 files changed, 15 insertions(+), 187 deletions(-) rename mmv1/templates/terraform/examples/{apigee_environment_nodeconfig_test.tf.erb => apigee_environment_type_test.tf.erb} (98%) delete mode 100644 mmv1/third_party/terraform/services/apigee/resource_apigee_environment_nodeconfig_test.go.erb diff --git a/mmv1/products/apigee/Environment.yaml b/mmv1/products/apigee/Environment.yaml index 83ca01541f8f..c9b343dc4a7b 100644 --- a/mmv1/products/apigee/Environment.yaml +++ b/mmv1/products/apigee/Environment.yaml @@ -87,7 +87,7 @@ examples: # Resource creation race skip_vcr: true - !ruby/object:Provider::Terraform::Examples - name: 'apigee_environment_nodeconfig_test' + name: 'apigee_environment_type_test' primary_resource_id: 'apigee_environment' primary_resource_name: "fmt.Sprintf(\"organizations/tf-test%s\", context[\"random_suffix\"\ @@ -184,3 +184,16 @@ properties: The current total number of gateway nodes that each environment currently has across all instances. output: true + - !ruby/object:Api::Type::Enum + name: 'type' + description: | + Types that can be selected for an Environment. Each of the types are + limited by capability and capacity. Refer to Apigee's public documentation + to understand about each of these types in details. + An Apigee org can support heterogeneous Environments. + default_from_api: true + values: + - 'ENVIRONMENT_TYPE_UNSPECIFIED' + - 'BASE' + - 'INTERMEDIATE' + - 'COMPREHENSIVE' diff --git a/mmv1/templates/terraform/examples/apigee_environment_nodeconfig_test.tf.erb b/mmv1/templates/terraform/examples/apigee_environment_type_test.tf.erb similarity index 98% rename from mmv1/templates/terraform/examples/apigee_environment_nodeconfig_test.tf.erb rename to mmv1/templates/terraform/examples/apigee_environment_type_test.tf.erb index a4efdafb7613..1286cc5ec1dd 100644 --- a/mmv1/templates/terraform/examples/apigee_environment_nodeconfig_test.tf.erb +++ b/mmv1/templates/terraform/examples/apigee_environment_type_test.tf.erb @@ -120,8 +120,5 @@ resource "google_apigee_environment" "<%= ctx[:primary_resource_id] %>" { name = "tf-test%{random_suffix}" description = "Apigee Environment" display_name = "tf-test%{random_suffix}" - node_config { - min_node_count = "3" - max_node_count = "5" - } + type = "COMPREHENSIVE" } diff --git a/mmv1/third_party/terraform/services/apigee/resource_apigee_environment_nodeconfig_test.go.erb b/mmv1/third_party/terraform/services/apigee/resource_apigee_environment_nodeconfig_test.go.erb deleted file mode 100644 index d493d58dcde3..000000000000 --- a/mmv1/third_party/terraform/services/apigee/resource_apigee_environment_nodeconfig_test.go.erb +++ /dev/null @@ -1,182 +0,0 @@ -<% autogen_exception -%> -package apigee_test -<% unless version == 'ga' -%> - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-provider-google/google/acctest" - "github.com/hashicorp/terraform-provider-google/google/envvar" -) - -func TestAccApigeeEnvironment_apigeeEnvironmentNodeconfigTestExampleUpdate(t *testing.T) { - acctest.SkipIfVcr(t) - t.Parallel() - - context := map[string]interface{}{ - "org_id": envvar.GetTestOrgFromEnv(t), - "billing_account": envvar.GetTestBillingAccountFromEnv(t), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckApigeeEnvironmentDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccApigeeEnvironment_apigeeEnvironmentNodeconfigTestExample(context), - }, - { - ResourceName: "google_apigee_environment.apigee_environment", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"org_id"}, - }, - { - Config: testAccApigeeEnvironment_apigeeEnvironmentNodeconfigTestExampleUpdate(context), - }, - { - ResourceName: "google_apigee_environment.apigee_environment", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"org_id"}, - }, - }, - }) -} - -func testAccApigeeEnvironment_apigeeEnvironmentNodeconfigTestExampleUpdate(context map[string]interface{}) string { - return acctest.Nprintf(` -resource "google_project" "project" { - provider = google-beta - - project_id = "tf-test%{random_suffix}" - name = "tf-test%{random_suffix}" - org_id = "%{org_id}" - billing_account = "%{billing_account}" -} - -resource "google_project_service" "apigee" { - provider = google-beta - - project = google_project.project.project_id - service = "apigee.googleapis.com" -} - -resource "google_project_service" "compute" { - provider = google-beta - - project = google_project.project.project_id - service = "compute.googleapis.com" -} - -resource "google_project_service" "servicenetworking" { - provider = google-beta - - project = google_project.project.project_id - service = "servicenetworking.googleapis.com" -} - -resource "google_project_service" "kms" { - provider = google-beta - - project = google_project.project.project_id - service = "cloudkms.googleapis.com" -} - -resource "google_compute_network" "apigee_network" { - provider = google-beta - - name = "apigee-network" - project = google_project.project.project_id - depends_on = [google_project_service.compute] -} - -resource "google_compute_global_address" "apigee_range" { - provider = google-beta - - name = "tf-test-apigee-range%{random_suffix}" - purpose = "VPC_PEERING" - address_type = "INTERNAL" - prefix_length = 16 - network = google_compute_network.apigee_network.id - project = google_project.project.project_id -} - -resource "google_service_networking_connection" "apigee_vpc_connection" { - provider = google-beta - - network = google_compute_network.apigee_network.id - service = "servicenetworking.googleapis.com" - reserved_peering_ranges = [google_compute_global_address.apigee_range.name] - depends_on = [google_project_service.servicenetworking] -} - -resource "google_kms_key_ring" "apigee_keyring" { - provider = google-beta - - name = "apigee-keyring" - location = "us-central1" - project = google_project.project.project_id - depends_on = [google_project_service.kms] -} - -resource "google_kms_crypto_key" "apigee_key" { - provider = google-beta - - name = "apigee-key" - key_ring = google_kms_key_ring.apigee_keyring.id -} - -resource "google_project_service_identity" "apigee_sa" { - provider = google-beta - - project = google_project.project.project_id - service = google_project_service.apigee.service -} - -resource "google_kms_crypto_key_iam_binding" "apigee_sa_keyuser" { - provider = google-beta - - crypto_key_id = google_kms_crypto_key.apigee_key.id - role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" - - members = [ - "serviceAccount:${google_project_service_identity.apigee_sa.email}", - ] -} - -resource "google_apigee_organization" "apigee_org" { - provider = google-beta - - analytics_region = "us-central1" - project_id = google_project.project.project_id - authorized_network = google_compute_network.apigee_network.id - billing_type = "PAYG" - runtime_database_encryption_key_name = google_kms_crypto_key.apigee_key.id - - depends_on = [ - google_service_networking_connection.apigee_vpc_connection, - google_project_service.apigee, - google_kms_crypto_key_iam_binding.apigee_sa_keyuser, - ] -} - -resource "google_apigee_environment" "apigee_environment" { - provider = google-beta - - org_id = google_apigee_organization.apigee_org.id - name = "tf-test%{random_suffix}" - description = "Apigee Environment" - display_name = "tf-test%{random_suffix}" - node_config { - min_node_count = "4" - max_node_count = "5" - } -} -`, context) -} - -<% end -%>