-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding new Lustre Resource #13181
base: main
Are you sure you want to change the base?
Adding new Lustre Resource #13181
Changes from all commits
f328696
87f3999
3fd8c57
e9f9eaf
07e616b
df56734
cf11b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Copyright 2024 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: Instance | ||
description: Description | ||
base_url: projects/{{project}}/locations/{{location}}/instances | ||
update_mask: true | ||
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance_id}} | ||
create_url: projects/{{project}}/locations/{{location}}/instances?instanceId={{instance_id}} | ||
update_verb: PATCH | ||
id_format: projects/{{project}}/locations/{{location}}/instances/{{instance_id}} | ||
import_format: | ||
- projects/{{project}}/locations/{{location}}/instances/{{instance_id}} | ||
examples: | ||
- name: lustre_instance_basic | ||
primary_resource_id: 'instance' | ||
vars: | ||
name: 'instance' | ||
network_name: 'network' | ||
address_name: 'ipaddress' | ||
filesystem_name: 'filesystem' | ||
capacity_gib: 21000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Values like this can be hardcoded (which it looks like you've already done actually) |
||
autogen_async: true | ||
async: | ||
operation: | ||
timeouts: | ||
insert_minutes: 20 | ||
update_minutes: 20 | ||
delete_minutes: 20 | ||
base_url: '{{op_id}}' | ||
actions: | ||
- create | ||
- delete | ||
- update | ||
type: OpAsync | ||
result: | ||
resource_inside_response: true | ||
include_project: false | ||
autogen_status: SW5zdGFuY2U= | ||
parameters: | ||
- name: location | ||
type: String | ||
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. | ||
immutable: true | ||
url_param_only: true | ||
required: true | ||
- name: instanceId | ||
type: String | ||
description: |- | ||
Required. Id of the requesting object | ||
If auto-generating Id server-side, remove this field and | ||
instance_id from the method_signature of Create RPC | ||
immutable: true | ||
url_param_only: true | ||
required: true | ||
properties: | ||
- name: name | ||
type: String | ||
description: Identifier. name of resource | ||
output: true | ||
- name: filesystem | ||
type: String | ||
description: Required. Immutable. Filesystem Name for Lustre. | ||
immutable: true | ||
required: true | ||
- name: network | ||
type: String | ||
description: |- | ||
Required. Immutable. VPC Network full name. | ||
Must be in a form 'projects/{project}/global/networks/{network}'. | ||
{project} is a project number, as in '12345' {network} is network name. | ||
immutable: true | ||
required: true | ||
- name: mountPoint | ||
type: String | ||
description: |- | ||
Output only. Mount point of the instance given by IP address and filesystem name and | ||
is in the format of {ip_address}@tcp:/{filesystem}. | ||
output: true | ||
- name: labels | ||
type: KeyValueLabels | ||
description: Optional. Labels as key value pairs | ||
- name: perUnitStorageThroughput | ||
type: String | ||
description: |- | ||
Optional. The throughput of the instance in MB/s/TiB. | ||
Valid values are 250, 500, 1000. | ||
Default value is 1000. | ||
- name: capacityGib | ||
type: String | ||
description: Required. Capacity of the instance in GiB | ||
required: true | ||
- name: state | ||
type: String | ||
description: |- | ||
Output only. State of the instance | ||
Possible values: | ||
STATE_UNSPECIFIED | ||
ACTIVE | ||
CREATING | ||
DELETING | ||
UPGRADING | ||
REPAIRING | ||
STOPPED | ||
output: true | ||
- name: createTime | ||
type: String | ||
description: Output only. [Output only] Create time stamp | ||
output: true | ||
- name: updateTime | ||
type: String | ||
description: Output only. [Output only] Update time stamp | ||
output: true | ||
- name: description | ||
type: String | ||
description: Optional. Description |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: Lustre | ||
display_name: Lustre | ||
scopes: | ||
- https://www.googleapis.com/auth/cloud-platform | ||
versions: | ||
- base_url: https://lustre.googleapis.com/v1/ | ||
name: ga | ||
caibaseurl: "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line can be removed for this resource (it's for products with urls like |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
resource "google_lustre_instance" "{{$.PrimaryResourceId}}" { | ||
instance_id = "{{index $.Vars "name"}}" | ||
location = "us-central1-a" | ||
description = "test instance" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the test configs (here or in the update test) should have optional fields omitted, to verify they are in fact optional. |
||
filesystem = "testfs" | ||
capacity_gib = 14000 | ||
network = google_compute_network.network.id | ||
labels = { | ||
test = "value" | ||
} | ||
depends_on = [google_service_networking_connection.default] | ||
} | ||
|
||
resource "google_compute_network" "network" { | ||
name = "{{index $.Vars "network_name"}}" | ||
auto_create_subnetworks = true | ||
mtu = 8896 | ||
} | ||
|
||
# Create an IP address | ||
resource "google_compute_global_address" "private_ip_alloc" { | ||
name = "{{index $.Vars "address_name"}}" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 24 | ||
network = google_compute_network.network.id | ||
} | ||
|
||
# Create a private connection | ||
resource "google_service_networking_connection" "default" { | ||
network = google_compute_network.network.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package lustre_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/plancheck" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
func TestAccLustreInstance_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccLustreInstance_full(context), | ||
}, | ||
{ | ||
ResourceName: "google_lustre_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"instance_id", "labels", "location", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccLustreInstance_update(context), | ||
ConfigPlanChecks: resource.ConfigPlanChecks{ | ||
PreApply: []plancheck.PlanCheck{ | ||
plancheck.ExpectResourceAction( | ||
"google_lustre_instance.description", | ||
plancheck.ResourceActionUpdate, | ||
), | ||
}, | ||
}, | ||
}, | ||
{ | ||
ResourceName: "google_lustre_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"instance_id", "labels", "location", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccLustreInstance_full(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_lustre_instance" "instance" { | ||
instance_id = "instance%{random_suffix}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my other comment, the ids in the test should have a sweepable prefix ie. |
||
location = "us-central1-a" | ||
description = "test instance" | ||
filesystem = "testfs" | ||
capacity_gib = 14000 | ||
network = google_compute_network.network.id | ||
labels = { | ||
test = "value" | ||
} | ||
depends_on = [google_service_networking_connection.default] | ||
timeouts { | ||
create = "180m" | ||
} | ||
} | ||
resource "google_compute_network" "network" { | ||
name = "network%{random_suffix}" | ||
auto_create_subnetworks = true | ||
mtu = 8896 | ||
} | ||
# Create an IP address | ||
resource "google_compute_global_address" "private_ip_alloc" { | ||
name = "ip%{random_suffix}" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 24 | ||
network = google_compute_network.network.id | ||
} | ||
# Create a private connection | ||
resource "google_service_networking_connection" "default" { | ||
network = google_compute_network.network.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccLustreInstance_update(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_lustre_instance" "instance" { | ||
instance_id = "instance%{random_suffix}" | ||
location = "us-central1-a" | ||
description = "test instance description field has been updated." | ||
filesystem = "testfs" | ||
capacity_gib = 14000 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was expecting to see more values changed here, like labels and capacity. |
||
network = google_compute_network.network.id | ||
labels = { | ||
test = "value" | ||
} | ||
depends_on = [google_service_networking_connection.default] | ||
timeouts { | ||
create = "180m" | ||
} | ||
} | ||
resource "google_compute_network" "network" { | ||
name = "network%{random_suffix}" | ||
auto_create_subnetworks = true | ||
mtu = 8896 | ||
} | ||
# Create an IP address | ||
resource "google_compute_global_address" "private_ip_alloc" { | ||
name = "ip%{random_suffix}" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 24 | ||
network = google_compute_network.network.id | ||
} | ||
# Create a private connection | ||
resource "google_service_networking_connection" "default" { | ||
network = google_compute_network.network.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name] | ||
} | ||
`, context) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ids here should each include a hyphen, which signals to our generator that we want the value used in tests to have a sweepable prefix and a randomize suffix. So for example, name could be
my-instance
or similar. I think the same applies to network_name and address_name.