Skip to content

Commit de44db1

Browse files
stephanechariteDawid212
authored andcommitted
Adding new Lustre Resource (GoogleCloudPlatform#13181)
1 parent 797f8e8 commit de44db1

File tree

6 files changed

+303
-0
lines changed

6 files changed

+303
-0
lines changed

mmv1/products/lustre/Instance.yaml

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: Instance
16+
description: A Managed Lustre instance
17+
base_url: projects/{{project}}/locations/{{location}}/instances
18+
update_mask: true
19+
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance_id}}
20+
create_url: projects/{{project}}/locations/{{location}}/instances?instanceId={{instance_id}}
21+
update_verb: PATCH
22+
id_format: projects/{{project}}/locations/{{location}}/instances/{{instance_id}}
23+
import_format:
24+
- projects/{{project}}/locations/{{location}}/instances/{{instance_id}}
25+
examples:
26+
- name: lustre_instance_basic
27+
primary_resource_id: 'instance'
28+
vars:
29+
name: 'my-instance'
30+
address_name: 'my-ip-address-name'
31+
network_name: 'my-network'
32+
subnetwork_name: 'my-subnetwork'
33+
test_vars_overrides:
34+
'network_name': 'acctest.BootstrapSharedServiceNetworkingConnection(t, "default-vpc")'
35+
autogen_async: true
36+
async:
37+
operation:
38+
timeouts:
39+
insert_minutes: 20
40+
update_minutes: 20
41+
delete_minutes: 20
42+
base_url: '{{op_id}}'
43+
actions:
44+
- create
45+
- delete
46+
- update
47+
type: OpAsync
48+
result:
49+
resource_inside_response: true
50+
include_project: false
51+
autogen_status: SW5zdGFuY2U=
52+
parameters:
53+
- name: location
54+
type: String
55+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
56+
immutable: true
57+
url_param_only: true
58+
required: true
59+
- name: instanceId
60+
type: String
61+
description: |-
62+
Required. The name of the Managed Lustre instance.
63+
64+
* Must contain only lowercase letters, numbers, and hyphens.
65+
* Must start with a letter.
66+
* Must be between 1-63 characters.
67+
* Must end with a number or a letter.
68+
immutable: true
69+
url_param_only: true
70+
required: true
71+
properties:
72+
- name: state
73+
type: String
74+
description: |-
75+
Output only. The state of the instance.
76+
Possible values:
77+
STATE_UNSPECIFIED
78+
ACTIVE
79+
CREATING
80+
DELETING
81+
UPGRADING
82+
REPAIRING
83+
STOPPED
84+
output: true
85+
- name: mountPoint
86+
type: String
87+
description: Output only. Mount point of the instance in the format `IP_ADDRESS@tcp:/FILESYSTEM`.
88+
output: true
89+
- name: labels
90+
type: KeyValueLabels
91+
description: Optional. Labels as key value pairs.
92+
- name: capacityGib
93+
type: String
94+
description: |-
95+
Required. The storage capacity of the instance in gibibytes (GiB). Allowed values
96+
are from 18000 to 954000, in increments of 9000.
97+
required: true
98+
- name: createTime
99+
type: String
100+
description: Output only. Timestamp when the instance was created.
101+
output: true
102+
- name: updateTime
103+
type: String
104+
description: Output only. Timestamp when the instance was last updated.
105+
output: true
106+
- name: description
107+
type: String
108+
description: Optional. A user-readable description of the instance.
109+
- name: gkeSupportEnabled
110+
type: Boolean
111+
description: |-
112+
Optional. Indicates whether you want to enable support for GKE clients. By default,
113+
GKE clients are not supported.
114+
- name: name
115+
type: String
116+
description: Identifier. The name of the instance.
117+
output: true
118+
- name: filesystem
119+
type: String
120+
description: |-
121+
Required. Immutable. The filesystem name for this instance. This name is used by client-side
122+
tools, including when mounting the instance. Must be 8 characters or less
123+
and may only contain letters and numbers.
124+
immutable: true
125+
required: true
126+
- name: network
127+
type: String
128+
description: |-
129+
Required. Immutable. The full name of the VPC network to which the instance is connected.
130+
Must be in the format
131+
`projects/{project_id}/global/networks/{network_name}`.
132+
immutable: true
133+
required: true

mmv1/products/lustre/product.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2024 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: Lustre
16+
display_name: Google Cloud Managed Lustre
17+
scopes:
18+
- https://www.googleapis.com/auth/cloud-platform
19+
versions:
20+
- base_url: https://lustre.googleapis.com/v1/
21+
name: ga
22+
- base_url: https://lustre.googleapis.com/v1/
23+
name: beta
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "google_lustre_instance" "{{$.PrimaryResourceId}}" {
2+
instance_id = "{{index $.Vars "name"}}"
3+
location = "us-central1-a"
4+
description = "test lustre instance"
5+
filesystem = "testfs"
6+
capacity_gib = 18000
7+
network = data.google_compute_network.lustre-network.id
8+
labels = {
9+
test = "value"
10+
}
11+
timeouts {
12+
create = "120m"
13+
}
14+
}
15+
16+
// This example assumes this network already exists.
17+
// The API creates a tenant network per network authorized for a
18+
// Lustre instance and that network is not deleted when the user-created
19+
// network (authorized_network) is deleted, so this prevents issues
20+
// with tenant network quota.
21+
// If this network hasn't been created and you are using this example in your
22+
// config, add an additional network resource or change
23+
// this from "data"to "resource"
24+
data "google_compute_network" "lustre-network" {
25+
name = "{{index $.Vars "network_name"}}"
26+
}

mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt

+5
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,11 @@ var ServicesListBeta = mapOf(
526526
"displayName" to "Looker",
527527
"path" to "./google-beta/services/looker"
528528
),
529+
"lustre" to mapOf(
530+
"name" to "lustre",
531+
"displayName" to "GoogleCloudManagedLustre",
532+
"path" to "./google-beta/services/lustre"
533+
),
529534
"managedkafka" to mapOf(
530535
"name" to "managedkafka",
531536
"displayName" to "Managedkafka",

mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt

+5
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,11 @@ var ServicesListGa = mapOf(
521521
"displayName" to "Looker",
522522
"path" to "./google/services/looker"
523523
),
524+
"lustre" to mapOf(
525+
"name" to "lustre",
526+
"displayName" to "GoogleCloudManagedLustre",
527+
"path" to "./google/services/lustre"
528+
),
524529
"managedkafka" to mapOf(
525530
"name" to "managedkafka",
526531
"displayName" to "Managedkafka",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package lustre_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
8+
9+
"github.com/hashicorp/terraform-provider-google/google/acctest"
10+
)
11+
12+
func TestAccLustreInstance_update(t *testing.T) {
13+
t.Parallel()
14+
15+
context := map[string]interface{}{
16+
"network_name": acctest.BootstrapSharedTestNetwork(t, "default-vpc"),
17+
"random_suffix": acctest.RandString(t, 10),
18+
}
19+
20+
acctest.VcrTest(t, resource.TestCase{
21+
PreCheck: func() { acctest.AccTestPreCheck(t) },
22+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
23+
Steps: []resource.TestStep{
24+
{
25+
Config: testAccLustreInstance_full(context),
26+
},
27+
{
28+
ResourceName: "google_lustre_instance.instance",
29+
ImportState: true,
30+
ImportStateVerify: true,
31+
ImportStateVerifyIgnore: []string{"instance_id", "labels", "gke_support_enabled", "location", "terraform_labels"},
32+
},
33+
{
34+
Config: testAccLustreInstance_update(context),
35+
ConfigPlanChecks: resource.ConfigPlanChecks{
36+
PreApply: []plancheck.PlanCheck{
37+
plancheck.ExpectResourceAction(
38+
"google_lustre_instance.instance",
39+
plancheck.ResourceActionUpdate,
40+
),
41+
},
42+
},
43+
},
44+
{
45+
ResourceName: "google_lustre_instance.instance",
46+
ImportState: true,
47+
ImportStateVerify: true,
48+
ImportStateVerifyIgnore: []string{"instance_id", "labels", "gke_support_enabled", "location", "terraform_labels"},
49+
},
50+
},
51+
})
52+
}
53+
54+
func testAccLustreInstance_full(context map[string]interface{}) string {
55+
return acctest.Nprintf(`
56+
resource "google_lustre_instance" "instance" {
57+
instance_id = "tf-test-my-instance%{random_suffix}"
58+
location = "us-central1-a"
59+
filesystem = "testfs"
60+
network = data.google_compute_network.lustre-network.id
61+
gke_support_enabled = false
62+
capacity_gib = 18000
63+
timeouts {
64+
create = "120m"
65+
}
66+
}
67+
68+
// This example assumes this network already exists.
69+
// The API creates a tenant network per network authorized for a
70+
// Lustre instance and that network is not deleted when the user-created
71+
// network (authorized_network) is deleted, so this prevents issues
72+
// with tenant network quota.
73+
// If this network hasn't been created and you are using this example in your
74+
// config, add an additional network resource or change
75+
// this from "data"to "resource"
76+
data "google_compute_network" "lustre-network" {
77+
name = "%{network_name}"
78+
}
79+
`, context)
80+
}
81+
82+
func testAccLustreInstance_update(context map[string]interface{}) string {
83+
return acctest.Nprintf(`
84+
resource "google_lustre_instance" "instance" {
85+
instance_id = "tf-test-my-instance%{random_suffix}"
86+
location = "us-central1-a"
87+
filesystem = "testfs"
88+
capacity_gib = 18000
89+
network = data.google_compute_network.lustre-network.id
90+
description = "test-description"
91+
labels = {
92+
test = "test-label"
93+
}
94+
timeouts {
95+
create = "120m"
96+
}
97+
}
98+
99+
// This example assumes this network already exists.
100+
// The API creates a tenant network per network authorized for a
101+
// Lustre instance and that network is not deleted when the user-created
102+
// network (authorized_network) is deleted, so this prevents issues
103+
// with tenant network quota.
104+
// If this network hasn't been created and you are using this example in your
105+
// config, add an additional network resource or change
106+
// this from "data"to "resource"
107+
data "google_compute_network" "lustre-network" {
108+
name = "%{network_name}"
109+
}
110+
`, context)
111+
}

0 commit comments

Comments
 (0)