From 50874dd1aeb6b9048df8a4bc8c6bd8bea9dd4aab Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Tue, 29 Oct 2024 15:39:04 +0000 Subject: [PATCH 1/7] add arguments for domain and scan listener port --- .../oracle/cloud_vm_cluster_resource.go | 39 +++++++++++++++++++ .../oracle/cloud_vm_cluster_resource_test.go | 3 ++ .../r/oracle_cloud_vm_cluster.html.markdown | 6 +++ 3 files changed, 48 insertions(+) diff --git a/internal/services/oracle/cloud_vm_cluster_resource.go b/internal/services/oracle/cloud_vm_cluster_resource.go index 526c364c7860..b3272d221a6f 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource.go +++ b/internal/services/oracle/cloud_vm_cluster_resource.go @@ -53,9 +53,12 @@ type CloudVmClusterResourceModel struct { ClusterName string `tfschema:"cluster_name"` DataCollectionOptions []DataCollectionOptionsModel `tfschema:"data_collection_options"` DataStoragePercentage int64 `tfschema:"data_storage_percentage"` + Domain string `tfschema:"domain"` IsLocalBackupEnabled bool `tfschema:"local_backup_enabled"` IsSparseDiskgroupEnabled bool `tfschema:"sparse_diskgroup_enabled"` Ocid string `tfschema:"ocid"` + ScanListenerPortTcp int64 `tfschema:"scan_listener_port_tcp"` + ScanListenerPortTcpSsl int64 `tfschema:"scan_listener_port_tcp_ssl"` TimeZone string `tfschema:"time_zone"` } @@ -223,6 +226,14 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { ValidateFunc: validate.DataStoragePercentage, }, + "domain": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: false, + ValidateFunc: validation.StringIsNotEmpty, + }, + "local_backup_enabled": { Type: pluginsdk.TypeBool, Optional: true, @@ -237,6 +248,22 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { ForceNew: true, }, + "scan_listener_port_tcp": { + Type: pluginsdk.TypeInt, + Optional: true, + Computed: true, + ForceNew: false, + ValidateFunc: validation.IntAtLeast(0), + }, + + "scan_listener_port_tcp_ssl": { + Type: pluginsdk.TypeInt, + Optional: true, + Computed: true, + ForceNew: false, + ValidateFunc: validation.IntAtLeast(0), + }, + "time_zone": { Type: pluginsdk.TypeString, Optional: true, @@ -325,6 +352,15 @@ func (r CloudVmClusterResource) Create() sdk.ResourceFunc { IsIncidentLogsEnabled: pointer.To(model.DataCollectionOptions[0].IsIncidentLogsEnabled), } } + if model.Domain != "" { + param.Properties.Domain = pointer.To(model.Domain) + } + if model.ScanListenerPortTcp >= 0 { + param.Properties.ScanListenerPortTcp = pointer.To(model.ScanListenerPortTcp) + } + if model.ScanListenerPortTcpSsl >= 0 { + param.Properties.ScanListenerPortTcpSsl = pointer.To(model.ScanListenerPortTcpSsl) + } if model.TimeZone != "" { param.Properties.ClusterName = pointer.To(model.TimeZone) } @@ -443,9 +479,12 @@ func (CloudVmClusterResource) Read() sdk.ResourceFunc { state.ClusterName = pointer.From(props.ClusterName) state.DataCollectionOptions = FlattenDataCollectionOptions(props.DataCollectionOptions) state.DataStoragePercentage = pointer.From(props.DataStoragePercentage) + state.Domain = pointer.From(props.Domain) state.Ocid = pointer.From(props.Ocid) state.IsLocalBackupEnabled = pointer.From(props.IsLocalBackupEnabled) state.IsSparseDiskgroupEnabled = pointer.From(props.IsSparseDiskgroupEnabled) + state.ScanListenerPortTcp = pointer.From(props.ScanListenerPortTcp) + state.ScanListenerPortTcpSsl = pointer.From(props.ScanListenerPortTcpSsl) state.TimeZone = pointer.From(props.TimeZone) } } diff --git a/internal/services/oracle/cloud_vm_cluster_resource_test.go b/internal/services/oracle/cloud_vm_cluster_resource_test.go index b54a72865c96..c2e3ecc36b22 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource_test.go +++ b/internal/services/oracle/cloud_vm_cluster_resource_test.go @@ -134,6 +134,7 @@ resource "azurerm_oracle_cloud_vm_cluster" "test" { db_node_storage_size_in_gbs = 120 db_servers = [for obj in data.azurerm_oracle_db_servers.test.db_servers : obj.ocid] display_name = "OFakeVmacctest%[2]d" + domain = "ociofakeacctes.ociofakeacctes.oraclevcn.com" gi_version = "23.0.0.0" local_backup_enabled = true sparse_diskgroup_enabled = true @@ -142,6 +143,8 @@ resource "azurerm_oracle_cloud_vm_cluster" "test" { hostname = "hostname" ssh_public_keys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN you@me.com"] subnet_id = azurerm_subnet.virtual_network_subnet.id + scan_listener_port_tcp = 1521 + scan_listener_port_tcp_ssl = 2484 tags = { test = "testTag1" } diff --git a/website/docs/r/oracle_cloud_vm_cluster.html.markdown b/website/docs/r/oracle_cloud_vm_cluster.html.markdown index 0742b6ae912a..462a83ed8683 100644 --- a/website/docs/r/oracle_cloud_vm_cluster.html.markdown +++ b/website/docs/r/oracle_cloud_vm_cluster.html.markdown @@ -121,12 +121,18 @@ The following arguments are supported: * `db_node_storage_size_in_gbs` - (Optional) The local node storage to be allocated in GBs. +* `domain` - (Optional) The domain name for the cloud VM cluster. + * `local_backup_enabled` - (Optional) If true, database backup on local Exadata storage is configured for the Cloud VM Cluster. If `false`, database backup on local Exadata storage is not available in the Cloud VM Cluster. * `sparse_diskgroup_enabled` - (Optional) If true, the sparse disk group is configured for the Cloud VM Cluster. If `false`, the sparse disk group is not created. * `memory_size_in_gbs` - (Optional) The memory to be allocated in GBs. +* `scan_listener_port_tcp` - (Optional) The TCP Single Client Access Name (SCAN) port. The default port is 1521. + +* `scan_listener_port_tcp_ssl` - (Optional) The TCPS Single Client Access Name (SCAN) port. The default port is 2484. + * `tags` - (Optional) A mapping of tags which should be assigned to the Cloud VM Cluster. * `time_zone` - (Optional) The time zone of the Cloud VM Cluster. For details, see [Exadata Infrastructure Time Zones](https://docs.cloud.oracle.com/iaas/Content/Database/References/timezones.htm). From fa1e3ca2d9d3c53e7d8eb26a06c2ef002c4b388f Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Tue, 29 Oct 2024 17:56:54 +0000 Subject: [PATCH 2/7] fix on clustername assignment and ForceNew flag --- internal/services/oracle/cloud_vm_cluster_resource.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/oracle/cloud_vm_cluster_resource.go b/internal/services/oracle/cloud_vm_cluster_resource.go index b3272d221a6f..eb66a1ecb717 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource.go +++ b/internal/services/oracle/cloud_vm_cluster_resource.go @@ -230,7 +230,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { Type: schema.TypeString, Optional: true, Computed: true, - ForceNew: false, + ForceNew: true, ValidateFunc: validation.StringIsNotEmpty, }, @@ -252,7 +252,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeInt, Optional: true, Computed: true, - ForceNew: false, + ForceNew: true, ValidateFunc: validation.IntAtLeast(0), }, @@ -260,7 +260,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeInt, Optional: true, Computed: true, - ForceNew: false, + ForceNew: true, ValidateFunc: validation.IntAtLeast(0), }, @@ -362,7 +362,7 @@ func (r CloudVmClusterResource) Create() sdk.ResourceFunc { param.Properties.ScanListenerPortTcpSsl = pointer.To(model.ScanListenerPortTcpSsl) } if model.TimeZone != "" { - param.Properties.ClusterName = pointer.To(model.TimeZone) + param.Properties.TimeZone = pointer.To(model.TimeZone) } if model.DataStoragePercentage != 0 { param.Properties.DataStoragePercentage = pointer.To(model.DataStoragePercentage) From ef2c07f4dd3c2ea185be17c3d876b1546d244223 Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Wed, 30 Oct 2024 13:01:32 +0000 Subject: [PATCH 3/7] update port checking between 1024 and 8999 --- internal/services/oracle/cloud_vm_cluster_resource.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/oracle/cloud_vm_cluster_resource.go b/internal/services/oracle/cloud_vm_cluster_resource.go index eb66a1ecb717..c565da931ec0 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource.go +++ b/internal/services/oracle/cloud_vm_cluster_resource.go @@ -253,7 +253,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { Optional: true, Computed: true, ForceNew: true, - ValidateFunc: validation.IntAtLeast(0), + ValidateFunc: validation.IntBetween(1024, 8999), }, "scan_listener_port_tcp_ssl": { @@ -261,7 +261,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { Optional: true, Computed: true, ForceNew: true, - ValidateFunc: validation.IntAtLeast(0), + ValidateFunc: validation.IntBetween(1024, 8999), }, "time_zone": { @@ -355,10 +355,10 @@ func (r CloudVmClusterResource) Create() sdk.ResourceFunc { if model.Domain != "" { param.Properties.Domain = pointer.To(model.Domain) } - if model.ScanListenerPortTcp >= 0 { + if model.ScanListenerPortTcp >= 1024 && model.ScanListenerPortTcp <= 8999 { param.Properties.ScanListenerPortTcp = pointer.To(model.ScanListenerPortTcp) } - if model.ScanListenerPortTcpSsl >= 0 { + if model.ScanListenerPortTcpSsl >= 1024 && model.ScanListenerPortTcpSsl <= 8999 { param.Properties.ScanListenerPortTcpSsl = pointer.To(model.ScanListenerPortTcpSsl) } if model.TimeZone != "" { From 793f37e3cb3e625a848c4a1cedcc2bf1d9958975 Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Wed, 30 Oct 2024 13:06:45 +0000 Subject: [PATCH 4/7] update Default of scan_listener_port_tcp and scan_listener_port_tcp_ssl --- internal/services/oracle/cloud_vm_cluster_resource.go | 4 ++-- website/docs/r/oracle_cloud_vm_cluster.html.markdown | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/oracle/cloud_vm_cluster_resource.go b/internal/services/oracle/cloud_vm_cluster_resource.go index c565da931ec0..fdcf8d6a8f9e 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource.go +++ b/internal/services/oracle/cloud_vm_cluster_resource.go @@ -251,7 +251,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { "scan_listener_port_tcp": { Type: pluginsdk.TypeInt, Optional: true, - Computed: true, + Default: 1521, ForceNew: true, ValidateFunc: validation.IntBetween(1024, 8999), }, @@ -259,7 +259,7 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { "scan_listener_port_tcp_ssl": { Type: pluginsdk.TypeInt, Optional: true, - Computed: true, + Default: 2484, ForceNew: true, ValidateFunc: validation.IntBetween(1024, 8999), }, diff --git a/website/docs/r/oracle_cloud_vm_cluster.html.markdown b/website/docs/r/oracle_cloud_vm_cluster.html.markdown index 462a83ed8683..01b31f7a9cb5 100644 --- a/website/docs/r/oracle_cloud_vm_cluster.html.markdown +++ b/website/docs/r/oracle_cloud_vm_cluster.html.markdown @@ -129,9 +129,9 @@ The following arguments are supported: * `memory_size_in_gbs` - (Optional) The memory to be allocated in GBs. -* `scan_listener_port_tcp` - (Optional) The TCP Single Client Access Name (SCAN) port. The default port is 1521. +* `scan_listener_port_tcp` - (Optional) The TCP Single Client Access Name (SCAN) port. The default port to 1521. -* `scan_listener_port_tcp_ssl` - (Optional) The TCPS Single Client Access Name (SCAN) port. The default port is 2484. +* `scan_listener_port_tcp_ssl` - (Optional) The TCPS Single Client Access Name (SCAN) port. The default port to 2484. * `tags` - (Optional) A mapping of tags which should be assigned to the Cloud VM Cluster. From 0bb6b03a88361e5f669ccaaa415353ce6f8437ef Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Wed, 30 Oct 2024 18:10:51 +0000 Subject: [PATCH 5/7] add zone_id for domain support --- .../services/oracle/cloud_vm_cluster_resource.go | 13 +++++++++++++ .../oracle/cloud_vm_cluster_resource_test.go | 3 ++- .../docs/r/oracle_cloud_vm_cluster.html.markdown | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/services/oracle/cloud_vm_cluster_resource.go b/internal/services/oracle/cloud_vm_cluster_resource.go index fdcf8d6a8f9e..169b8ee28ba3 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource.go +++ b/internal/services/oracle/cloud_vm_cluster_resource.go @@ -60,6 +60,7 @@ type CloudVmClusterResourceModel struct { ScanListenerPortTcp int64 `tfschema:"scan_listener_port_tcp"` ScanListenerPortTcpSsl int64 `tfschema:"scan_listener_port_tcp_ssl"` TimeZone string `tfschema:"time_zone"` + ZoneId string `tfschema:"zone_id"` } func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { @@ -271,6 +272,14 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { ForceNew: true, }, + "zone_id": { + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "tags": commonschema.Tags(), } } @@ -364,6 +373,9 @@ func (r CloudVmClusterResource) Create() sdk.ResourceFunc { if model.TimeZone != "" { param.Properties.TimeZone = pointer.To(model.TimeZone) } + if model.ZoneId != "" { + param.Properties.ZoneId = pointer.To(model.ZoneId) + } if model.DataStoragePercentage != 0 { param.Properties.DataStoragePercentage = pointer.To(model.DataStoragePercentage) } @@ -486,6 +498,7 @@ func (CloudVmClusterResource) Read() sdk.ResourceFunc { state.ScanListenerPortTcp = pointer.From(props.ScanListenerPortTcp) state.ScanListenerPortTcpSsl = pointer.From(props.ScanListenerPortTcpSsl) state.TimeZone = pointer.From(props.TimeZone) + state.ZoneId = pointer.From(props.ZoneId) } } diff --git a/internal/services/oracle/cloud_vm_cluster_resource_test.go b/internal/services/oracle/cloud_vm_cluster_resource_test.go index c2e3ecc36b22..e89b04b476aa 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource_test.go +++ b/internal/services/oracle/cloud_vm_cluster_resource_test.go @@ -134,7 +134,7 @@ resource "azurerm_oracle_cloud_vm_cluster" "test" { db_node_storage_size_in_gbs = 120 db_servers = [for obj in data.azurerm_oracle_db_servers.test.db_servers : obj.ocid] display_name = "OFakeVmacctest%[2]d" - domain = "ociofakeacctes.ociofakeacctes.oraclevcn.com" + domain = "ociofakeacctes.com" gi_version = "23.0.0.0" local_backup_enabled = true sparse_diskgroup_enabled = true @@ -149,6 +149,7 @@ resource "azurerm_oracle_cloud_vm_cluster" "test" { test = "testTag1" } time_zone = "UTC" + zone_id = "ocid1.dns-zone.oc1.iad.aaaaaaaac7lyw74bnybmlek7nrsd5h3v5kjfv3aiw62menpuuwoder7yhmpa" virtual_network_id = azurerm_virtual_network.virtual_network.id }`, a.template(data), data.RandomInteger, data.Locations.Primary) } diff --git a/website/docs/r/oracle_cloud_vm_cluster.html.markdown b/website/docs/r/oracle_cloud_vm_cluster.html.markdown index 01b31f7a9cb5..58fa2e4a6391 100644 --- a/website/docs/r/oracle_cloud_vm_cluster.html.markdown +++ b/website/docs/r/oracle_cloud_vm_cluster.html.markdown @@ -137,6 +137,8 @@ The following arguments are supported: * `time_zone` - (Optional) The time zone of the Cloud VM Cluster. For details, see [Exadata Infrastructure Time Zones](https://docs.cloud.oracle.com/iaas/Content/Database/References/timezones.htm). +* `zone_id` - (Optional) The OCID of the zone the cloud VM cluster is associated with. + --- A `data_collection_options` block supports the following: From 26c2752f678aeeec8be858ff0503d050f49be43d Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Wed, 30 Oct 2024 23:23:57 +0000 Subject: [PATCH 6/7] remove StringIsNotEmpty for optional arguments (domain and zone_id) --- .../oracle/cloud_vm_cluster_resource.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/services/oracle/cloud_vm_cluster_resource.go b/internal/services/oracle/cloud_vm_cluster_resource.go index 169b8ee28ba3..1f843f567705 100644 --- a/internal/services/oracle/cloud_vm_cluster_resource.go +++ b/internal/services/oracle/cloud_vm_cluster_resource.go @@ -228,11 +228,10 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { }, "domain": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, }, "local_backup_enabled": { @@ -273,11 +272,10 @@ func (CloudVmClusterResource) Arguments() map[string]*pluginsdk.Schema { }, "zone_id": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + ForceNew: true, }, "tags": commonschema.Tags(), From 43b8907369767d72b4c7cff19efd6c5b623fe09f Mon Sep 17 00:00:00 2001 From: Steven Chan Date: Thu, 31 Oct 2024 11:28:33 +0000 Subject: [PATCH 7/7] updated description of domain and zone_id --- website/docs/r/oracle_cloud_vm_cluster.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/oracle_cloud_vm_cluster.html.markdown b/website/docs/r/oracle_cloud_vm_cluster.html.markdown index 58fa2e4a6391..d208552cc1f4 100644 --- a/website/docs/r/oracle_cloud_vm_cluster.html.markdown +++ b/website/docs/r/oracle_cloud_vm_cluster.html.markdown @@ -121,7 +121,7 @@ The following arguments are supported: * `db_node_storage_size_in_gbs` - (Optional) The local node storage to be allocated in GBs. -* `domain` - (Optional) The domain name for the cloud VM cluster. +* `domain` - (Optional) The name of the OCI Private DNS Zone to be associated with the Cloud VM Cluster. This is required for specifying your own private domain name. * `local_backup_enabled` - (Optional) If true, database backup on local Exadata storage is configured for the Cloud VM Cluster. If `false`, database backup on local Exadata storage is not available in the Cloud VM Cluster. @@ -137,7 +137,7 @@ The following arguments are supported: * `time_zone` - (Optional) The time zone of the Cloud VM Cluster. For details, see [Exadata Infrastructure Time Zones](https://docs.cloud.oracle.com/iaas/Content/Database/References/timezones.htm). -* `zone_id` - (Optional) The OCID of the zone the cloud VM cluster is associated with. +* `zone_id` - (Optional) The OCID of the OCI Private DNS Zone to be associated with the Cloud VM Cluster. This is required for specifying your own private domain name. ---