Skip to content

Commit 3eb6ec7

Browse files
feat: add OdbNetwork support in OracleDatabase CloudVmCluster resource (#14587) (#10391)
[upstream:b59a2d6837f20d54824571c10b1fee21944f730e] Signed-off-by: Modular Magician <[email protected]>
1 parent 548efd8 commit 3eb6ec7

File tree

5 files changed

+245
-29
lines changed

5 files changed

+245
-29
lines changed

.changelog/14587.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
oracledatabase: added `odb_network`, `odb_subnet` and `backup_odb_subnet` fields, and make `network`, `cidr` and `backup_subnet_cidr` fields optional in `google_oracle_database_cloud_vm_cluster` resource
3+
```

google-beta/services/oracledatabase/resource_oracle_database_cloud_vm_cluster.go

Lines changed: 93 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ func ResourceOracleDatabaseCloudVmCluster() *schema.Resource {
5656
),
5757

5858
Schema: map[string]*schema.Schema{
59-
"backup_subnet_cidr": {
60-
Type: schema.TypeString,
61-
Required: true,
62-
ForceNew: true,
63-
Description: `CIDR range of the backup subnet.`,
64-
},
65-
"cidr": {
66-
Type: schema.TypeString,
67-
Required: true,
68-
ForceNew: true,
69-
Description: `Network settings. CIDR to use for cluster IP allocation.`,
70-
},
7159
"cloud_vm_cluster_id": {
7260
Type: schema.TypeString,
7361
Required: true,
@@ -91,12 +79,25 @@ projects/{project}/locations/{region}/cloudExadataInfrastuctures/{cloud_extradat
9179
ForceNew: true,
9280
Description: `Resource ID segment making up resource 'name'. See documentation for resource type 'oracledatabase.googleapis.com/DbNode'.`,
9381
},
94-
"network": {
82+
"backup_odb_subnet": {
9583
Type: schema.TypeString,
96-
Required: true,
84+
Optional: true,
9785
ForceNew: true,
98-
Description: `The name of the VPC network.
99-
Format: projects/{project}/global/networks/{network}`,
86+
Description: `The name of the backup OdbSubnet associated with the VM Cluster.
87+
Format:
88+
projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}`,
89+
},
90+
"backup_subnet_cidr": {
91+
Type: schema.TypeString,
92+
Optional: true,
93+
ForceNew: true,
94+
Description: `CIDR range of the backup subnet.`,
95+
},
96+
"cidr": {
97+
Type: schema.TypeString,
98+
Optional: true,
99+
ForceNew: true,
100+
Description: `Network settings. CIDR to use for cluster IP allocation.`,
100101
},
101102
"display_name": {
102103
Type: schema.TypeString,
@@ -113,6 +114,31 @@ Format: projects/{project}/global/networks/{network}`,
113114
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
114115
Elem: &schema.Schema{Type: schema.TypeString},
115116
},
117+
"network": {
118+
Type: schema.TypeString,
119+
Optional: true,
120+
ForceNew: true,
121+
Description: `The name of the VPC network.
122+
Format: projects/{project}/global/networks/{network}`,
123+
},
124+
"odb_network": {
125+
Type: schema.TypeString,
126+
Optional: true,
127+
ForceNew: true,
128+
Description: `The name of the OdbNetwork associated with the VM Cluster.
129+
Format:
130+
projects/{project}/locations/{location}/odbNetworks/{odb_network}
131+
It is optional but if specified, this should match the parent ODBNetwork of
132+
the odb_subnet and backup_odb_subnet.`,
133+
},
134+
"odb_subnet": {
135+
Type: schema.TypeString,
136+
Optional: true,
137+
ForceNew: true,
138+
Description: `The name of the OdbSubnet associated with the VM Cluster for
139+
IP allocation. Format:
140+
projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}`,
141+
},
116142
"properties": {
117143
Type: schema.TypeList,
118144
Optional: true,
@@ -470,6 +496,24 @@ func resourceOracleDatabaseCloudVmClusterCreate(d *schema.ResourceData, meta int
470496
} else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) {
471497
obj["network"] = networkProp
472498
}
499+
odbNetworkProp, err := expandOracleDatabaseCloudVmClusterOdbNetwork(d.Get("odb_network"), d, config)
500+
if err != nil {
501+
return err
502+
} else if v, ok := d.GetOkExists("odb_network"); !tpgresource.IsEmptyValue(reflect.ValueOf(odbNetworkProp)) && (ok || !reflect.DeepEqual(v, odbNetworkProp)) {
503+
obj["odbNetwork"] = odbNetworkProp
504+
}
505+
odbSubnetProp, err := expandOracleDatabaseCloudVmClusterOdbSubnet(d.Get("odb_subnet"), d, config)
506+
if err != nil {
507+
return err
508+
} else if v, ok := d.GetOkExists("odb_subnet"); !tpgresource.IsEmptyValue(reflect.ValueOf(odbSubnetProp)) && (ok || !reflect.DeepEqual(v, odbSubnetProp)) {
509+
obj["odbSubnet"] = odbSubnetProp
510+
}
511+
backupOdbSubnetProp, err := expandOracleDatabaseCloudVmClusterBackupOdbSubnet(d.Get("backup_odb_subnet"), d, config)
512+
if err != nil {
513+
return err
514+
} else if v, ok := d.GetOkExists("backup_odb_subnet"); !tpgresource.IsEmptyValue(reflect.ValueOf(backupOdbSubnetProp)) && (ok || !reflect.DeepEqual(v, backupOdbSubnetProp)) {
515+
obj["backupOdbSubnet"] = backupOdbSubnetProp
516+
}
473517
labelsProp, err := expandOracleDatabaseCloudVmClusterEffectiveLabels(d.Get("effective_labels"), d, config)
474518
if err != nil {
475519
return err
@@ -611,6 +655,15 @@ func resourceOracleDatabaseCloudVmClusterRead(d *schema.ResourceData, meta inter
611655
if err := d.Set("network", flattenOracleDatabaseCloudVmClusterNetwork(res["network"], d, config)); err != nil {
612656
return fmt.Errorf("Error reading CloudVmCluster: %s", err)
613657
}
658+
if err := d.Set("odb_network", flattenOracleDatabaseCloudVmClusterOdbNetwork(res["odbNetwork"], d, config)); err != nil {
659+
return fmt.Errorf("Error reading CloudVmCluster: %s", err)
660+
}
661+
if err := d.Set("odb_subnet", flattenOracleDatabaseCloudVmClusterOdbSubnet(res["odbSubnet"], d, config)); err != nil {
662+
return fmt.Errorf("Error reading CloudVmCluster: %s", err)
663+
}
664+
if err := d.Set("backup_odb_subnet", flattenOracleDatabaseCloudVmClusterBackupOdbSubnet(res["backupOdbSubnet"], d, config)); err != nil {
665+
return fmt.Errorf("Error reading CloudVmCluster: %s", err)
666+
}
614667
if err := d.Set("terraform_labels", flattenOracleDatabaseCloudVmClusterTerraformLabels(res["labels"], d, config)); err != nil {
615668
return fmt.Errorf("Error reading CloudVmCluster: %s", err)
616669
}
@@ -1089,6 +1142,18 @@ func flattenOracleDatabaseCloudVmClusterNetwork(v interface{}, d *schema.Resourc
10891142
return v
10901143
}
10911144

1145+
func flattenOracleDatabaseCloudVmClusterOdbNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1146+
return v
1147+
}
1148+
1149+
func flattenOracleDatabaseCloudVmClusterOdbSubnet(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1150+
return v
1151+
}
1152+
1153+
func flattenOracleDatabaseCloudVmClusterBackupOdbSubnet(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1154+
return v
1155+
}
1156+
10921157
func flattenOracleDatabaseCloudVmClusterTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
10931158
if v == nil {
10941159
return v
@@ -1552,6 +1617,18 @@ func expandOracleDatabaseCloudVmClusterNetwork(v interface{}, d tpgresource.Terr
15521617
return v, nil
15531618
}
15541619

1620+
func expandOracleDatabaseCloudVmClusterOdbNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1621+
return v, nil
1622+
}
1623+
1624+
func expandOracleDatabaseCloudVmClusterOdbSubnet(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1625+
return v, nil
1626+
}
1627+
1628+
func expandOracleDatabaseCloudVmClusterBackupOdbSubnet(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1629+
return v, nil
1630+
}
1631+
15551632
func expandOracleDatabaseCloudVmClusterEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
15561633
if v == nil {
15571634
return map[string]string{}, nil

google-beta/services/oracledatabase/resource_oracle_database_cloud_vm_cluster_generated_meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ api_version: 'v1'
66
api_resource_type_kind: 'CloudVmCluster'
77
autogen_status: true
88
fields:
9+
- field: 'backup_odb_subnet'
910
- field: 'backup_subnet_cidr'
1011
- field: 'cidr'
1112
- field: 'cloud_vm_cluster_id'
@@ -23,6 +24,8 @@ fields:
2324
provider_only: true
2425
- field: 'name'
2526
- field: 'network'
27+
- field: 'odb_network'
28+
- field: 'odb_subnet'
2629
- field: 'properties.cluster_name'
2730
- field: 'properties.compartment_id'
2831
- field: 'properties.cpu_core_count'

google-beta/services/oracledatabase/resource_oracle_database_cloud_vm_cluster_generated_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,76 @@ data "google_compute_network" "default" {
102102
`, context)
103103
}
104104

105+
func TestAccOracleDatabaseCloudVmCluster_oracledatabaseCloudVmclusterOdbnetworkExample(t *testing.T) {
106+
t.Parallel()
107+
108+
context := map[string]interface{}{
109+
"backup_odb_subnet": "projects/oci-terraform-testing-prod/locations/europe-west2/odbNetworks/tf-test-permanent-odbnetwork/odbSubnets/tf-test-permanent-backup-odbsubnet",
110+
"cloud_exadata_infrastructure_id": fmt.Sprintf("ofake-tf-test-exadata-for-vmcluster-odbnetwork-%s", acctest.RandString(t, 10)),
111+
"cloud_vm_cluster_id": fmt.Sprintf("ofake-tf-test-vmcluster-odbnetwork-%s", acctest.RandString(t, 10)),
112+
"deletion_protection": false,
113+
"odb_network": "projects/oci-terraform-testing-prod/locations/europe-west2/odbNetworks/tf-test-permanent-odbnetwork",
114+
"odb_subnet": "projects/oci-terraform-testing-prod/locations/europe-west2/odbNetworks/tf-test-permanent-odbnetwork/odbSubnets/tf-test-permanent-client-odbsubnet",
115+
"project": "oci-terraform-testing-prod",
116+
"random_suffix": acctest.RandString(t, 10),
117+
}
118+
119+
acctest.VcrTest(t, resource.TestCase{
120+
PreCheck: func() { acctest.AccTestPreCheck(t) },
121+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
122+
CheckDestroy: testAccCheckOracleDatabaseCloudVmClusterDestroyProducer(t),
123+
Steps: []resource.TestStep{
124+
{
125+
Config: testAccOracleDatabaseCloudVmCluster_oracledatabaseCloudVmclusterOdbnetworkExample(context),
126+
},
127+
{
128+
ResourceName: "google_oracle_database_cloud_vm_cluster.my_vmcluster",
129+
ImportState: true,
130+
ImportStateVerify: true,
131+
ImportStateVerifyIgnore: []string{"cloud_vm_cluster_id", "deletion_protection", "labels", "location", "properties.0.gi_version", "properties.0.hostname_prefix", "terraform_labels"},
132+
},
133+
},
134+
})
135+
}
136+
137+
func testAccOracleDatabaseCloudVmCluster_oracledatabaseCloudVmclusterOdbnetworkExample(context map[string]interface{}) string {
138+
return acctest.Nprintf(`
139+
resource "google_oracle_database_cloud_vm_cluster" "my_vmcluster"{
140+
cloud_vm_cluster_id = "%{cloud_vm_cluster_id}"
141+
display_name = "%{cloud_vm_cluster_id} displayname"
142+
location = "europe-west2"
143+
project = "%{project}"
144+
exadata_infrastructure = google_oracle_database_cloud_exadata_infrastructure.cloudExadataInfrastructures.id
145+
odb_network = "%{odb_network}"
146+
odb_subnet = "%{odb_subnet}"
147+
backup_odb_subnet = "%{backup_odb_subnet}"
148+
properties {
149+
license_type = "LICENSE_INCLUDED"
150+
ssh_public_keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCz1X2744t+6vRLmE5u6nHi6/QWh8bQDgHmd+OIxRQIGA/IWUtCs2FnaCNZcqvZkaeyjk5v0lTA/n+9jvO42Ipib53athrfVG8gRt8fzPL66C6ZqHq+6zZophhrCdfJh/0G4x9xJh5gdMprlaCR1P8yAaVvhBQSKGc4SiIkyMNBcHJ5YTtMQMTfxaB4G1sHZ6SDAY9a6Cq/zNjDwfPapWLsiP4mRhE5SSjJX6l6EYbkm0JeLQg+AbJiNEPvrvDp1wtTxzlPJtIivthmLMThFxK7+DkrYFuLvN5AHUdo9KTDLvHtDCvV70r8v0gafsrKkM/OE9Jtzoo0e1N/5K/ZdyFRbAkFT4QSF3nwpbmBWLf2Evg//YyEuxnz4CwPqFST2mucnrCCGCVWp1vnHZ0y30nM35njLOmWdRDFy5l27pKUTwLp02y3UYiiZyP7d3/u5pKiN4vC27VuvzprSdJxWoAvluOiDeRh+/oeQDowxoT/Oop8DzB9uJmjktXw8jyMW2+Rpg+ENQqeNgF1OGlEzypaWiRskEFlkpLb4v/s3ZDYkL1oW0Nv/J8LTjTOTEaYt2Udjoe9x2xWiGnQixhdChWuG+MaoWffzUgx1tsVj/DBXijR5DjkPkrA1GA98zd3q8GKEaAdcDenJjHhNYSd4+rE9pIsnYn7fo5X/tFfcQH1XQ== [email protected]"]
151+
cpu_core_count = "4"
152+
gi_version = "19.0.0.0"
153+
hostname_prefix = "hostname1"
154+
}
155+
156+
deletion_protection = "%{deletion_protection}"
157+
}
158+
159+
resource "google_oracle_database_cloud_exadata_infrastructure" "cloudExadataInfrastructures"{
160+
cloud_exadata_infrastructure_id = "%{cloud_exadata_infrastructure_id}"
161+
display_name = "%{cloud_exadata_infrastructure_id} displayname"
162+
location = "europe-west2"
163+
project = "%{project}"
164+
properties {
165+
shape = "Exadata.X9M"
166+
compute_count= "2"
167+
storage_count= "3"
168+
}
169+
170+
deletion_protection = "%{deletion_protection}"
171+
}
172+
`, context)
173+
}
174+
105175
func TestAccOracleDatabaseCloudVmCluster_oracledatabaseCloudVmclusterFullExample(t *testing.T) {
106176
t.Parallel()
107177

website/docs/r/oracle_database_cloud_vm_cluster.html.markdown

Lines changed: 76 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,49 @@ data "google_compute_network" "default" {
7878
project = "my-project"
7979
}
8080
```
81+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
82+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=oracledatabase_cloud_vmcluster_odbnetwork&open_in_editor=main.tf" target="_blank">
83+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
84+
</a>
85+
</div>
86+
## Example Usage - Oracledatabase Cloud Vmcluster Odbnetwork
87+
88+
89+
```hcl
90+
resource "google_oracle_database_cloud_vm_cluster" "my_vmcluster"{
91+
cloud_vm_cluster_id = "my-instance"
92+
display_name = "my-instance displayname"
93+
location = "europe-west2"
94+
project = "my-project"
95+
exadata_infrastructure = google_oracle_database_cloud_exadata_infrastructure.cloudExadataInfrastructures.id
96+
odb_network = "projects/my-project/locations/europe-west2/odbNetworks/my-odbnetwork"
97+
odb_subnet = "projects/my-project/locations/europe-west2/odbNetworks/my-odbnetwork/odbSubnets/my-odbsubnet"
98+
backup_odb_subnet = "projects/my-project/locations/europe-west2/odbNetworks/my-odbnetwork/odbSubnets/my-backup-odbsubnet"
99+
properties {
100+
license_type = "LICENSE_INCLUDED"
101+
ssh_public_keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCz1X2744t+6vRLmE5u6nHi6/QWh8bQDgHmd+OIxRQIGA/IWUtCs2FnaCNZcqvZkaeyjk5v0lTA/n+9jvO42Ipib53athrfVG8gRt8fzPL66C6ZqHq+6zZophhrCdfJh/0G4x9xJh5gdMprlaCR1P8yAaVvhBQSKGc4SiIkyMNBcHJ5YTtMQMTfxaB4G1sHZ6SDAY9a6Cq/zNjDwfPapWLsiP4mRhE5SSjJX6l6EYbkm0JeLQg+AbJiNEPvrvDp1wtTxzlPJtIivthmLMThFxK7+DkrYFuLvN5AHUdo9KTDLvHtDCvV70r8v0gafsrKkM/OE9Jtzoo0e1N/5K/ZdyFRbAkFT4QSF3nwpbmBWLf2Evg//YyEuxnz4CwPqFST2mucnrCCGCVWp1vnHZ0y30nM35njLOmWdRDFy5l27pKUTwLp02y3UYiiZyP7d3/u5pKiN4vC27VuvzprSdJxWoAvluOiDeRh+/oeQDowxoT/Oop8DzB9uJmjktXw8jyMW2+Rpg+ENQqeNgF1OGlEzypaWiRskEFlkpLb4v/s3ZDYkL1oW0Nv/J8LTjTOTEaYt2Udjoe9x2xWiGnQixhdChWuG+MaoWffzUgx1tsVj/DBXijR5DjkPkrA1GA98zd3q8GKEaAdcDenJjHhNYSd4+rE9pIsnYn7fo5X/tFfcQH1XQ== [email protected]"]
102+
cpu_core_count = "4"
103+
gi_version = "19.0.0.0"
104+
hostname_prefix = "hostname1"
105+
}
106+
107+
deletion_protection = "true"
108+
}
109+
110+
resource "google_oracle_database_cloud_exadata_infrastructure" "cloudExadataInfrastructures"{
111+
cloud_exadata_infrastructure_id = "my-exadata"
112+
display_name = "my-exadata displayname"
113+
location = "europe-west2"
114+
project = "my-project"
115+
properties {
116+
shape = "Exadata.X9M"
117+
compute_count= "2"
118+
storage_count= "3"
119+
}
120+
121+
deletion_protection = "true"
122+
}
123+
```
81124
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
82125
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=oracledatabase_cloud_vmcluster_full&open_in_editor=main.tf" target="_blank">
83126
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
@@ -165,19 +208,6 @@ The following arguments are supported:
165208
resource is created, in the following format:
166209
projects/{project}/locations/{region}/cloudExadataInfrastuctures/{cloud_extradata_infrastructure}
167210

168-
* `cidr` -
169-
(Required)
170-
Network settings. CIDR to use for cluster IP allocation.
171-
172-
* `backup_subnet_cidr` -
173-
(Required)
174-
CIDR range of the backup subnet.
175-
176-
* `network` -
177-
(Required)
178-
The name of the VPC network.
179-
Format: projects/{project}/global/networks/{network}
180-
181211
* `location` -
182212
(Required)
183213
Resource ID segment making up resource `name`. See documentation for resource type `oracledatabase.googleapis.com/DbNode`.
@@ -205,6 +235,39 @@ The following arguments are supported:
205235
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
206236
Please refer to the field `effective_labels` for all of the labels present on the resource.
207237

238+
* `cidr` -
239+
(Optional)
240+
Network settings. CIDR to use for cluster IP allocation.
241+
242+
* `backup_subnet_cidr` -
243+
(Optional)
244+
CIDR range of the backup subnet.
245+
246+
* `network` -
247+
(Optional)
248+
The name of the VPC network.
249+
Format: projects/{project}/global/networks/{network}
250+
251+
* `odb_network` -
252+
(Optional)
253+
The name of the OdbNetwork associated with the VM Cluster.
254+
Format:
255+
projects/{project}/locations/{location}/odbNetworks/{odb_network}
256+
It is optional but if specified, this should match the parent ODBNetwork of
257+
the odb_subnet and backup_odb_subnet.
258+
259+
* `odb_subnet` -
260+
(Optional)
261+
The name of the OdbSubnet associated with the VM Cluster for
262+
IP allocation. Format:
263+
projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}
264+
265+
* `backup_odb_subnet` -
266+
(Optional)
267+
The name of the backup OdbSubnet associated with the VM Cluster.
268+
Format:
269+
projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}
270+
208271
* `project` - (Optional) The ID of the project in which the resource belongs.
209272
If it is not provided, the provider project is used.
210273

0 commit comments

Comments
 (0)