Skip to content

Commit 4113c98

Browse files
authored
Add Looker egress configs to Instance.yaml (#15749)
1 parent 5accf02 commit 4113c98

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

mmv1/products/looker/Instance.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,31 @@ properties:
153153
Network name in the consumer project in the format of: projects/{project}/global/networks/{network}
154154
Note that the consumer network may be in a different GCP project than the consumer
155155
project that is hosting the Looker Instance.
156+
# Controlled Egress Config Object
157+
- name: 'controlledEgressConfig'
158+
type: NestedObject
159+
description: |
160+
Controlled egress configuration.
161+
update_mask_fields:
162+
- 'controlled_egress_config.marketplace_enabled'
163+
- 'controlled_egress_config.egress_fqdns'
164+
properties:
165+
- name: 'marketplaceEnabled'
166+
type: Boolean
167+
description: |
168+
Whether the Looker Marketplace is enabled.
169+
- name: 'egressFqdns'
170+
type: Array
171+
description: |
172+
List of fully qualified domain names to be added to the allowlist for
173+
outbound traffic.
174+
item_type:
175+
type: String
176+
# Controlled Egress Config Object - End
177+
- name: 'controlledEgressEnabled'
178+
type: Boolean
179+
description: |
180+
Whether controlled egress is enabled on the Looker instance.
156181
- name: 'createTime'
157182
type: Time
158183
description: |
@@ -440,6 +465,7 @@ properties:
440465
type: NestedObject
441466
description: |
442467
Information for Private Service Connect (PSC) setup for a Looker instance.
468+
default_from_api: true
443469
update_mask_fields:
444470
- 'psc_config.allowed_vpcs'
445471
- 'psc_config.service_attachments'

mmv1/third_party/terraform/services/looker/resource_looker_instance_test.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package looker_test
22

33
import (
4+
"fmt"
45
"testing"
56

67
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -40,3 +41,89 @@ func TestAccLookerInstance_update(t *testing.T) {
4041
},
4142
})
4243
}
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

Comments
 (0)