From c18c54156befde52cfcbceb9ff76b6ac102d4fd7 Mon Sep 17 00:00:00 2001 From: The Magician Date: Fri, 13 Nov 2020 11:01:18 -0800 Subject: [PATCH] Add `ignore_warnings` to `google_bigtable_app_profile` create call (#4220) (#7806) * Add to create call * add testcase to valid scenario is workign appropriately * use test config * update testcase with correct import name Signed-off-by: Modular Magician --- .changelog/4220.txt | 3 + google/resource_bigtable_app_profile.go | 2 +- google/resource_bigtable_app_profile_test.go | 89 +++++++++++++++++++ .../docs/r/bigtable_app_profile.html.markdown | 3 + 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 .changelog/4220.txt diff --git a/.changelog/4220.txt b/.changelog/4220.txt new file mode 100644 index 00000000000..43830db5e8e --- /dev/null +++ b/.changelog/4220.txt @@ -0,0 +1,3 @@ +```release-note:bug +bigtable: added ignore_warnings flag to create call for `google_bigtable_app_profile` +``` diff --git a/google/resource_bigtable_app_profile.go b/google/resource_bigtable_app_profile.go index 3291eebb715..e2d858fe65b 100644 --- a/google/resource_bigtable_app_profile.go +++ b/google/resource_bigtable_app_profile.go @@ -145,7 +145,7 @@ func resourceBigtableAppProfileCreate(d *schema.ResourceData, meta interface{}) return err } - url, err := replaceVars(d, config, "{{BigtableBasePath}}projects/{{project}}/instances/{{instance}}/appProfiles?appProfileId={{app_profile_id}}") + url, err := replaceVars(d, config, "{{BigtableBasePath}}projects/{{project}}/instances/{{instance}}/appProfiles?appProfileId={{app_profile_id}}&ignoreWarnings={{ignore_warnings}}") if err != nil { return err } diff --git a/google/resource_bigtable_app_profile_test.go b/google/resource_bigtable_app_profile_test.go index a98a9d2ee7f..bd53ca86114 100644 --- a/google/resource_bigtable_app_profile_test.go +++ b/google/resource_bigtable_app_profile_test.go @@ -41,6 +41,31 @@ func TestAccBigtableAppProfile_update(t *testing.T) { }) } +func TestAccBigtableAppProfile_ignoreWarnings(t *testing.T) { + // bigtable instance does not use the shared HTTP client, this test creates an instance + skipIfVcr(t) + t.Parallel() + + instanceName := fmt.Sprintf("tf-test-%s", randString(t, 10)) + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckBigtableAppProfileDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBigtableAppProfile_warningsProduced(instanceName), + }, + { + ResourceName: "google_bigtable_app_profile.gae-profile1", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"ignore_warnings"}, + }, + }, + }) +} + func testAccBigtableAppProfile_update1(instanceName string) string { return fmt.Sprintf(` resource "google_bigtable_instance" "instance" { @@ -97,3 +122,67 @@ resource "google_bigtable_app_profile" "ap" { } `, instanceName, instanceName, instanceName) } + +func testAccBigtableAppProfile_warningsProduced(instanceName string) string { + return fmt.Sprintf(` + resource "google_bigtable_instance" "instance" { + name = "%s" + instance_type = "PRODUCTION" + cluster { + cluster_id = "%s1" + zone = "us-central1-b" + num_nodes = 3 + } + + cluster { + cluster_id = "%s2" + zone = "us-west1-a" + num_nodes = 3 + } + + cluster { + cluster_id = "%s3" + zone = "us-west1-b" + num_nodes = 3 + } + + deletion_protection = false + } + + resource "google_bigtable_app_profile" "gae-profile1" { + instance = google_bigtable_instance.instance.id + app_profile_id = "bigtableinstance-sample1" + + single_cluster_routing { + cluster_id = "%s1" + allow_transactional_writes = true + } + + ignore_warnings = true + } + + resource "google_bigtable_app_profile" "gae-profile2" { + instance = google_bigtable_instance.instance.id + app_profile_id = "bigtableinstance-sample2" + + single_cluster_routing { + cluster_id = "%s2" + allow_transactional_writes = true + } + + ignore_warnings = true + } + + resource "google_bigtable_app_profile" "gae-profile3" { + instance = google_bigtable_instance.instance.id + app_profile_id = "bigtableinstance-sample3" + + single_cluster_routing { + cluster_id = "%s3" + allow_transactional_writes = true + } + + ignore_warnings = true + } +`, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName, instanceName) +} diff --git a/website/docs/r/bigtable_app_profile.html.markdown b/website/docs/r/bigtable_app_profile.html.markdown index 76421ba17db..19922212c69 100644 --- a/website/docs/r/bigtable_app_profile.html.markdown +++ b/website/docs/r/bigtable_app_profile.html.markdown @@ -25,6 +25,9 @@ description: |- App profile is a configuration object describing how Cloud Bigtable should treat traffic from a particular end user application. +To get more information about AppProfile, see: + +* [API documentation](https://cloud.google.com/bigtable/docs/reference/admin/rest/v2/projects.instances.appProfiles)