Skip to content

Commit ebc0666

Browse files
authored
Merge branch 'GoogleCloudPlatform:main' into megan-kuo-patch-1
2 parents 2ddfe99 + ce5d3bf commit ebc0666

File tree

7 files changed

+196
-0
lines changed

7 files changed

+196
-0
lines changed

mmv1/products/dataprocgdc/ServiceInstance.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ examples:
5757
project: "my-project"
5858
test_vars_overrides:
5959
'project': '"gdce-cluster-monitoring"'
60+
skip_test: https://github.com/hashicorp/terraform-provider-google/issues/21173
6061
properties:
6162
- name: gdceCluster
6263
type: NestedObject

mmv1/products/lustre/Instance.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
---
1515
name: Instance
1616
description: A Managed Lustre instance
17+
references:
18+
guides:
19+
'Official Documentation': 'https://cloud.google.com/managed-lustre/docs/create-instance'
20+
api: 'https://cloud.google.com/managed-lustre/docs/reference/rest/v1/projects.locations.instances'
1721
base_url: projects/{{project}}/locations/{{location}}/instances
1822
update_mask: true
1923
self_link: projects/{{project}}/locations/{{location}}/instances/{{instance_id}}

mmv1/third_party/terraform/provider/provider_mmv1_resources.go.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
168168
"google_logging_project_cmek_settings": logging.DataSourceGoogleLoggingProjectCmekSettings(),
169169
"google_logging_project_settings": logging.DataSourceGoogleLoggingProjectSettings(),
170170
"google_logging_sink": logging.DataSourceGoogleLoggingSink(),
171+
"google_lustre_instance": lustre.DataSourceLustreInstance(),
171172
"google_monitoring_notification_channel": monitoring.DataSourceMonitoringNotificationChannel(),
172173
"google_monitoring_cluster_istio_service": monitoring.DataSourceMonitoringServiceClusterIstio(),
173174
"google_monitoring_istio_canonical_service": monitoring.DataSourceMonitoringIstioCanonicalService(),

mmv1/third_party/terraform/services/dataprocgdc/resource_dataproc_gdc_application_environment_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
)
1010

1111
func TestAccDataprocGdcApplicationEnvironment_update(t *testing.T) {
12+
t.Skip("https://github.com/hashicorp/terraform-provider-google/issues/20419")
1213
t.Parallel()
1314

1415
context := map[string]interface{}{
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package lustre
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
7+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
8+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
9+
)
10+
11+
func DataSourceLustreInstance() *schema.Resource {
12+
13+
// Generate datasource schema from resource
14+
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceLustreInstance().Schema)
15+
16+
dsScema_zone := map[string]*schema.Schema{
17+
"zone": {
18+
Type: schema.TypeString,
19+
Optional: true,
20+
Description: `Zone of Lustre instance`,
21+
},
22+
}
23+
24+
// Set 'Required' schema elements from resource
25+
tpgresource.AddRequiredFieldsToSchema(dsSchema, "instance_id")
26+
27+
// Set 'Optional' schema elements from resource
28+
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
29+
30+
// Merge schema elements
31+
dsSchema_m := tpgresource.MergeSchemas(dsScema_zone, dsSchema)
32+
33+
return &schema.Resource{
34+
Read: dataSourceLustreInstanceRead,
35+
Schema: dsSchema_m,
36+
}
37+
}
38+
39+
func dataSourceLustreInstanceRead(d *schema.ResourceData, meta interface{}) error {
40+
config := meta.(*transport_tpg.Config)
41+
42+
// Get required fields for ID
43+
instance_id := d.Get("instance_id").(string)
44+
45+
zone, err := tpgresource.GetZone(d, config)
46+
if err != nil {
47+
return err
48+
}
49+
50+
project, err := tpgresource.GetProject(d, config)
51+
if err != nil {
52+
return err
53+
}
54+
55+
// Set the ID
56+
id := fmt.Sprintf("projects/%s/locations/%s/instances/%s", project, zone, instance_id)
57+
d.SetId(id)
58+
59+
// Setting location field for url_param_only field
60+
d.Set("location", zone)
61+
62+
err = resourceLustreInstanceRead(d, meta)
63+
if err != nil {
64+
return err
65+
}
66+
67+
if err := tpgresource.SetDataSourceLabels(d); err != nil {
68+
return err
69+
}
70+
71+
if d.Id() == "" {
72+
return fmt.Errorf("%s not found", d.Id())
73+
}
74+
75+
return nil
76+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package lustre_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-provider-google/google/acctest"
8+
)
9+
10+
func TestAccLustreInstanceDatasource_basic(t *testing.T) {
11+
t.Parallel()
12+
13+
context := map[string]interface{}{
14+
"random_suffix": acctest.RandString(t, 10),
15+
}
16+
17+
acctest.VcrTest(t, resource.TestCase{
18+
PreCheck: func() { acctest.AccTestPreCheck(t) },
19+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
20+
Steps: []resource.TestStep{
21+
{
22+
Config: testAccLustreInstanceDatasource_basic(context),
23+
Check: acctest.CheckDataSourceStateMatchesResourceState(
24+
"data.google_lustre_instance.default",
25+
"google_lustre_instance.instance",
26+
),
27+
},
28+
{
29+
ResourceName: "google_lustre_instance.instance",
30+
ImportState: true,
31+
ImportStateVerify: true,
32+
},
33+
},
34+
})
35+
}
36+
37+
func testAccLustreInstanceDatasource_basic(context map[string]interface{}) string {
38+
return acctest.Nprintf(`
39+
resource "google_lustre_instance" "instance" {
40+
instance_id = "my-instance-%{random_suffix}"
41+
location = "us-central1-a"
42+
filesystem = "testfs"
43+
capacity_gib = 18000
44+
network = google_compute_network.producer_net.id
45+
gke_support_enabled = false
46+
47+
depends_on = [ google_service_networking_connection.service_con ]
48+
}
49+
50+
resource "google_compute_subnetwork" "producer_subnet" {
51+
name = "tf-test-my-subnet-%{random_suffix}"
52+
ip_cidr_range = "10.0.0.248/29"
53+
region = "us-central1"
54+
network = google_compute_network.producer_net.id
55+
}
56+
57+
resource "google_compute_network" "producer_net" {
58+
name = "tf-test-my-network-%{random_suffix}"
59+
auto_create_subnetworks = false
60+
}
61+
62+
resource "google_compute_global_address" "private_ip_alloc" {
63+
name = "private-ip-alloc-%{random_suffix}"
64+
purpose = "VPC_PEERING"
65+
address_type = "INTERNAL"
66+
prefix_length = 16
67+
network = google_compute_network.producer_net.id
68+
}
69+
70+
resource "google_service_networking_connection" "service_con" {
71+
network = google_compute_network.producer_net.id
72+
service = "servicenetworking.googleapis.com"
73+
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
74+
}
75+
76+
data "google_lustre_instance" "default" {
77+
instance_id = google_lustre_instance.instance.instance_id
78+
zone = "us-central1-a"
79+
}
80+
`, context)
81+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
subcategory: "Lustre"
3+
description: |-
4+
Fetches the details of a Lustre instance.
5+
---
6+
7+
# google_lustre_instance
8+
9+
Use this data source to get information about a Lustre instance. For more information see the [API docs](https://cloud.google.com/filestore/docs/lustre/reference/rest/v1/projects.locations.instances).
10+
11+
## Example Usage
12+
13+
```hcl
14+
data "google_lustre_instance" "instance" {
15+
name = "my-instance"
16+
location = "us-central1"
17+
}
18+
```
19+
20+
## Argument Reference
21+
22+
The following arguments are supported:
23+
24+
* `instance_id` - (Required) The instance id of the Lustre instance.
25+
26+
* `zone` - (Optional) The ID of the zone in which the resource belongs. If it is not provided, the provider zone is used.
27+
28+
* `project` - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
29+
30+
## Attributes Reference
31+
32+
See [google_lustre_instance](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/lustre_instance) resource for details of all the available attributes.

0 commit comments

Comments
 (0)