Skip to content

Commit 12e4d53

Browse files
Feat: Add oracle_database_cloud_vm_cluster datasource (#11997) (#8410)
[upstream:67774938b12e510a6a705cc5c0cf4f897f27f464] Signed-off-by: Modular Magician <[email protected]>
1 parent ed2b623 commit 12e4d53

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

.changelog/11997.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-datasource
2+
`google_oracle_database_cloud_vm_cluster`
3+
```

google-beta/provider/provider_mmv1_resources.go

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
294294
"google_monitoring_uptime_check_ips": monitoring.DataSourceGoogleMonitoringUptimeCheckIps(),
295295
"google_netblock_ip_ranges": resourcemanager.DataSourceGoogleNetblockIpRanges(),
296296
"google_oracle_database_db_servers": oracledatabase.DataSourceOracleDatabaseDbServers(),
297+
"google_oracle_database_cloud_vm_cluster": oracledatabase.DataSourceOracleDatabaseCloudVmCluster(),
297298
"google_oracle_database_cloud_exadata_infrastructure": oracledatabase.DataSourceOracleDatabaseCloudExadataInfrastructure(),
298299
"google_organization": resourcemanager.DataSourceGoogleOrganization(),
299300
"google_privateca_certificate_authority": privateca.DataSourcePrivatecaCertificateAuthority(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package oracledatabase
4+
5+
import (
6+
"fmt"
7+
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
10+
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
11+
)
12+
13+
func DataSourceOracleDatabaseCloudVmCluster() *schema.Resource {
14+
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceOracleDatabaseCloudVmCluster().Schema)
15+
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "cloud_vm_cluster_id")
16+
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
17+
return &schema.Resource{
18+
Read: dataSourceOracleDatabaseCloudVmClusterRead,
19+
Schema: dsSchema,
20+
}
21+
22+
}
23+
24+
func dataSourceOracleDatabaseCloudVmClusterRead(d *schema.ResourceData, meta interface{}) error {
25+
config := meta.(*transport_tpg.Config)
26+
27+
id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/cloudVmClusters/{{cloud_vm_cluster_id}}")
28+
if err != nil {
29+
return fmt.Errorf("Error constructing id: %s", err)
30+
}
31+
err = resourceOracleDatabaseCloudVmClusterRead(d, meta)
32+
if err != nil {
33+
return err
34+
}
35+
d.SetId(id)
36+
37+
return nil
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
package oracledatabase_test
4+
5+
import (
6+
"fmt"
7+
"testing"
8+
9+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
10+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
11+
)
12+
13+
func TestAccOracleDatabaseCloudVmCluster_basic(t *testing.T) {
14+
t.Parallel()
15+
acctest.VcrTest(t, resource.TestCase{
16+
PreCheck: func() { acctest.AccTestPreCheck(t) },
17+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
18+
Steps: []resource.TestStep{
19+
{
20+
Config: testAccOracleDatabaseCloudVmCluster_basic(),
21+
Check: resource.ComposeTestCheckFunc(
22+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "display_name"),
23+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "exadata_infrastructure"),
24+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "cidr"),
25+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.#"),
26+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.cpu_core_count"),
27+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.cluster_name"),
28+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "gcp_oracle_zone", "us-east4-b-r1"),
29+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.node_count", "2"),
30+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.state", "AVAILABLE"),
31+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.shape", "Exadata.X9M"),
32+
),
33+
},
34+
},
35+
})
36+
}
37+
38+
func testAccOracleDatabaseCloudVmCluster_basic() string {
39+
return fmt.Sprintf(`
40+
data "google_oracle_database_cloud_vm_cluster" "my-vmcluster"{
41+
cloud_vm_cluster_id = "ofake-do-not-delete-tf-vmcluster"
42+
project = "oci-terraform-testing"
43+
location = "us-east4"
44+
}
45+
`)
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
subcategory: "Oracle Database"
3+
description: |-
4+
Get information about a CloudVmCluster.
5+
---
6+
7+
# google_oracle_database_cloud_vm_cluster
8+
9+
Get information about a CloudVmCluster.
10+
11+
## Example Usage
12+
13+
```hcl
14+
data "google_oracle_database_cloud_vm_cluster" "my-vmcluster"{
15+
location = "us-east4"
16+
cloud_vm_cluster_id = "vmcluster-id"
17+
}
18+
```
19+
20+
## Argument Reference
21+
22+
The following arguments are supported:
23+
24+
* `cloud_vm_cluster_id` - (Required) The ID of the VM Cluster.
25+
26+
* `location` - (Required) The location of the resource.
27+
28+
- - -
29+
* `project` - (Optional) The project in which the resource belongs. If it
30+
is not provided, the provider project is used.
31+
32+
## Attributes Reference
33+
34+
See [google_oracle_database_cloud_vm_cluster](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_oracle_database_cloud_vm_cluster#argument-reference) resource for details of the available attributes.

0 commit comments

Comments
 (0)