Skip to content

Commit 23e9065

Browse files
tulika-aakritiBBBmau
authored andcommitted
Feat: Add oracle_database_cloud_vm_cluster datasource (GoogleCloudPlatform#11997)
1 parent 6264f80 commit 23e9065

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ var handwrittenDatasources = map[string]*schema.Resource{
169169
"google_monitoring_uptime_check_ips": monitoring.DataSourceGoogleMonitoringUptimeCheckIps(),
170170
"google_netblock_ip_ranges": resourcemanager.DataSourceGoogleNetblockIpRanges(),
171171
"google_oracle_database_db_servers": oracledatabase.DataSourceOracleDatabaseDbServers(),
172+
"google_oracle_database_cloud_vm_cluster": oracledatabase.DataSourceOracleDatabaseCloudVmCluster(),
172173
"google_oracle_database_cloud_exadata_infrastructure":oracledatabase.DataSourceOracleDatabaseCloudExadataInfrastructure(),
173174
"google_organization": resourcemanager.DataSourceGoogleOrganization(),
174175
"google_privateca_certificate_authority": privateca.DataSourcePrivatecaCertificateAuthority(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package oracledatabase
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 DataSourceOracleDatabaseCloudVmCluster() *schema.Resource {
12+
dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceOracleDatabaseCloudVmCluster().Schema)
13+
tpgresource.AddRequiredFieldsToSchema(dsSchema, "location", "cloud_vm_cluster_id")
14+
tpgresource.AddOptionalFieldsToSchema(dsSchema, "project")
15+
return &schema.Resource{
16+
Read: dataSourceOracleDatabaseCloudVmClusterRead,
17+
Schema: dsSchema,
18+
}
19+
20+
}
21+
22+
func dataSourceOracleDatabaseCloudVmClusterRead(d *schema.ResourceData, meta interface{}) error {
23+
config := meta.(*transport_tpg.Config)
24+
25+
id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/cloudVmClusters/{{cloud_vm_cluster_id}}")
26+
if err != nil {
27+
return fmt.Errorf("Error constructing id: %s", err)
28+
}
29+
err = resourceOracleDatabaseCloudVmClusterRead(d, meta)
30+
if err != nil {
31+
return err
32+
}
33+
d.SetId(id)
34+
35+
return nil
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package oracledatabase_test
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
8+
"github.com/hashicorp/terraform-provider-google/google/acctest"
9+
)
10+
11+
func TestAccOracleDatabaseCloudVmCluster_basic(t *testing.T) {
12+
t.Parallel()
13+
acctest.VcrTest(t, resource.TestCase{
14+
PreCheck: func() { acctest.AccTestPreCheck(t) },
15+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
16+
Steps: []resource.TestStep{
17+
{
18+
Config: testAccOracleDatabaseCloudVmCluster_basic(),
19+
Check: resource.ComposeTestCheckFunc(
20+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "display_name"),
21+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "exadata_infrastructure"),
22+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "cidr"),
23+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.#"),
24+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.cpu_core_count"),
25+
resource.TestCheckResourceAttrSet("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.cluster_name"),
26+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "gcp_oracle_zone", "us-east4-b-r1"),
27+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.node_count", "2"),
28+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.state", "AVAILABLE"),
29+
resource.TestCheckResourceAttr("data.google_oracle_database_cloud_vm_cluster.my-vmcluster", "properties.0.shape", "Exadata.X9M"),
30+
),
31+
},
32+
},
33+
})
34+
}
35+
36+
func testAccOracleDatabaseCloudVmCluster_basic() string {
37+
return fmt.Sprintf(`
38+
data "google_oracle_database_cloud_vm_cluster" "my-vmcluster"{
39+
cloud_vm_cluster_id = "ofake-do-not-delete-tf-vmcluster"
40+
project = "oci-terraform-testing"
41+
location = "us-east4"
42+
}
43+
`)
44+
}
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)