|
1 | 1 | package looker_test |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "testing" |
5 | 6 |
|
6 | 7 | "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
@@ -40,3 +41,89 @@ func TestAccLookerInstance_update(t *testing.T) { |
40 | 41 | }, |
41 | 42 | }) |
42 | 43 | } |
| 44 | + |
| 45 | +func TestAccLookerInstance_updateControlledEgress(t *testing.T) { |
| 46 | + t.Parallel() |
| 47 | + |
| 48 | + // Step 1: Create instance WITHOUT controlled egress |
| 49 | + context := map[string]interface{}{ |
| 50 | + "random_suffix": acctest.RandString(t, 10), |
| 51 | + } |
| 52 | + |
| 53 | + acctest.VcrTest(t, resource.TestCase{ |
| 54 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 55 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 56 | + Steps: []resource.TestStep{ |
| 57 | + { |
| 58 | + // Config A: Basic Instance |
| 59 | + Config: testAccLookerInstance_basic(context), |
| 60 | + }, |
| 61 | + { |
| 62 | + ResourceName: "google_looker_instance.test", |
| 63 | + ImportState: true, |
| 64 | + ImportStateVerify: true, |
| 65 | + ImportStateVerifyIgnore: []string{"oauth_config", "region"}, |
| 66 | + }, |
| 67 | + { |
| 68 | + // Config B: Update to ENABLE controlled egress |
| 69 | + // This triggers the PATCH with your update_mask logic |
| 70 | + Config: testAccLookerInstance_controlledEgress(context), |
| 71 | + }, |
| 72 | + { |
| 73 | + ResourceName: "google_looker_instance.test", |
| 74 | + ImportState: true, |
| 75 | + ImportStateVerify: true, |
| 76 | + ImportStateVerifyIgnore: []string{"oauth_config", "region"}, |
| 77 | + }, |
| 78 | + }, |
| 79 | + }) |
| 80 | +} |
| 81 | + |
| 82 | +func testAccLookerInstance_basic(context map[string]interface{}) string { |
| 83 | + return fmt.Sprintf(` |
| 84 | +resource "google_looker_instance" "test" { |
| 85 | + name = "tf-test-looker-%s" |
| 86 | + platform_edition = "LOOKER_CORE_ENTERPRISE_ANNUAL" |
| 87 | + region = "us-central1" |
| 88 | + public_ip_enabled = true |
| 89 | + psc_enabled = true |
| 90 | +
|
| 91 | + psc_config { |
| 92 | + allowed_vpcs = [] |
| 93 | + } |
| 94 | +
|
| 95 | + oauth_config { |
| 96 | + client_id = "my-client-id" |
| 97 | + client_secret = "my-client-secret" |
| 98 | + } |
| 99 | +} |
| 100 | +`, context["random_suffix"]) |
| 101 | +} |
| 102 | + |
| 103 | +func testAccLookerInstance_controlledEgress(context map[string]interface{}) string { |
| 104 | + return fmt.Sprintf(` |
| 105 | +resource "google_looker_instance" "test" { |
| 106 | + name = "tf-test-looker-%s" |
| 107 | + platform_edition = "LOOKER_CORE_ENTERPRISE_ANNUAL" |
| 108 | + region = "us-central1" |
| 109 | + public_ip_enabled = true |
| 110 | + psc_enabled = true |
| 111 | +
|
| 112 | + psc_config { |
| 113 | + allowed_vpcs = [] |
| 114 | + } |
| 115 | +
|
| 116 | + controlled_egress_enabled = true |
| 117 | +
|
| 118 | + controlled_egress_config { |
| 119 | + marketplace_enabled = true |
| 120 | + egress_fqdns = ["google.com", "github.com"] |
| 121 | + } |
| 122 | +
|
| 123 | + oauth_config { |
| 124 | + client_id = "my-client-id" |
| 125 | + client_secret = "my-client-secret" |
| 126 | + } |
| 127 | +} |
| 128 | +`, context["random_suffix"]) |
| 129 | +} |
0 commit comments