Skip to content

Commit 513c50b

Browse files
authored
Adding access_rules_options to google_lustre_instance (#15898)
1 parent e8de273 commit 513c50b

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed

mmv1/products/lustre/Instance.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,56 @@ properties:
158158
description: |-
159159
The reason why the instance is in a certain state.
160160
output: true
161+
- name: accessRulesOptions
162+
type: NestedObject
163+
description: |-
164+
Access control rules for the Lustre instance. Configures default root
165+
squashing behavior and specific access rules based on IP addresses.
166+
properties:
167+
- name: defaultSquashMode
168+
type: Enum
169+
required: true
170+
description: |-
171+
Set to "ROOT_SQUASH" to enable root squashing by default.
172+
Other values include "NO_SQUASH".
173+
enum_values:
174+
- 'ROOT_SQUASH'
175+
- 'NO_SQUASH'
176+
- name: defaultSquashUid
177+
type: Integer
178+
description: |-
179+
The UID to map the root user to when root squashing is enabled
180+
(e.g., 65534 for nobody).
181+
- name: defaultSquashGid
182+
type: Integer
183+
description: |-
184+
The GID to map the root user to when root squashing is enabled
185+
(e.g., 65534 for nobody).
186+
- name: accessRules
187+
type: Array
188+
description: |-
189+
An array of access rule exceptions. Each rule defines IP address ranges
190+
that should have different squash behavior than the default.
191+
item_type:
192+
type: NestedObject
193+
properties:
194+
- name: name
195+
type: String
196+
description: |-
197+
A unique identifier for the access rule.
198+
required: true
199+
- name: ipAddressRanges
200+
type: Array
201+
description: |-
202+
An array of IP address strings or CIDR ranges that this rule applies to.
203+
required: true
204+
item_type:
205+
type: String
206+
- name: squashMode
207+
type: Enum
208+
description: |-
209+
The squash mode for this specific rule. Currently, only "NO_SQUASH"
210+
is supported for exceptions.
211+
required: true
212+
enum_values:
213+
- 'NO_SQUASH'

mmv1/third_party/terraform/services/lustre/resource_lustre_instance_test.go

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,121 @@ data "google_compute_network" "lustre-network" {
8080
`, context)
8181
}
8282

83+
func TestAccLustreInstance_withAccessRulesOptions(t *testing.T) {
84+
t.Parallel()
85+
86+
context := map[string]interface{}{
87+
"network_name": acctest.BootstrapSharedTestNetwork(t, "default-vpc"),
88+
"random_suffix": acctest.RandString(t, 10),
89+
}
90+
91+
acctest.VcrTest(t, resource.TestCase{
92+
PreCheck: func() { acctest.AccTestPreCheck(t) },
93+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
94+
Steps: []resource.TestStep{
95+
{
96+
Config: testAccLustreInstance_withAccessRulesOptions(context),
97+
},
98+
{
99+
ResourceName: "google_lustre_instance.instance",
100+
ImportState: true,
101+
ImportStateVerify: true,
102+
ImportStateVerifyIgnore: []string{"instance_id", "labels", "gke_support_enabled", "location", "terraform_labels"},
103+
},
104+
{
105+
Config: testAccLustreInstance_withAccessRulesOptionsUpdate(context),
106+
ConfigPlanChecks: resource.ConfigPlanChecks{
107+
PreApply: []plancheck.PlanCheck{
108+
plancheck.ExpectResourceAction(
109+
"google_lustre_instance.instance",
110+
plancheck.ResourceActionUpdate,
111+
),
112+
},
113+
},
114+
},
115+
{
116+
ResourceName: "google_lustre_instance.instance",
117+
ImportState: true,
118+
ImportStateVerify: true,
119+
ImportStateVerifyIgnore: []string{"instance_id", "labels", "gke_support_enabled", "location", "terraform_labels"},
120+
},
121+
},
122+
})
123+
}
124+
125+
func testAccLustreInstance_withAccessRulesOptions(context map[string]interface{}) string {
126+
return acctest.Nprintf(`
127+
resource "google_lustre_instance" "instance" {
128+
instance_id = "tf-test-my-instance%{random_suffix}"
129+
location = "us-central1-a"
130+
filesystem = "testfs"
131+
network = data.google_compute_network.lustre-network.id
132+
gke_support_enabled = false
133+
capacity_gib = 18000
134+
per_unit_storage_throughput = 1000
135+
136+
access_rules_options {
137+
default_squash_mode = "ROOT_SQUASH"
138+
default_squash_uid = 65534
139+
140+
access_rules {
141+
name = "admin_hosts"
142+
ip_address_ranges = ["192.168.0.0/24","10.0.1.10/32"]
143+
squash_mode = "NO_SQUASH"
144+
}
145+
146+
access_rules {
147+
name = "another_admin"
148+
ip_address_ranges = ["172.16.5.0/24"]
149+
squash_mode = "NO_SQUASH"
150+
}
151+
}
152+
153+
timeouts {
154+
create = "120m"
155+
}
156+
}
157+
158+
data "google_compute_network" "lustre-network" {
159+
name = "%{network_name}"
160+
}
161+
`, context)
162+
}
163+
164+
func testAccLustreInstance_withAccessRulesOptionsUpdate(context map[string]interface{}) string {
165+
return acctest.Nprintf(`
166+
resource "google_lustre_instance" "instance" {
167+
instance_id = "tf-test-my-instance%{random_suffix}"
168+
location = "us-central1-a"
169+
filesystem = "testfs"
170+
network = data.google_compute_network.lustre-network.id
171+
gke_support_enabled = false
172+
capacity_gib = 18000
173+
per_unit_storage_throughput = 1000
174+
175+
access_rules_options {
176+
default_squash_mode = "NO_SQUASH"
177+
default_squash_uid = 0
178+
default_squash_gid = 0
179+
180+
access_rules {
181+
name = "updated_admin"
182+
ip_address_ranges = ["10.0.0.0/8"]
183+
squash_mode = "NO_SQUASH"
184+
}
185+
}
186+
187+
timeouts {
188+
create = "120m"
189+
}
190+
}
191+
192+
data "google_compute_network" "lustre-network" {
193+
name = "%{network_name}"
194+
}
195+
`, context)
196+
}
197+
83198
func TestAccLustreInstance_withKmsKey(t *testing.T) {
84199
t.Parallel()
85200

0 commit comments

Comments
 (0)