Skip to content

Efedotov/2025 03 01 terraform azure rm for adbs cross region disaster recovery#30167

Open
evgeniifedotov wants to merge 29 commits into
hashicorp:mainfrom
evgeniifedotov:efedotov/2025-03-01-Terraform-AzureRM-for-ADBS-Cross-Region_Disaster-Recovery
Open

Efedotov/2025 03 01 terraform azure rm for adbs cross region disaster recovery#30167
evgeniifedotov wants to merge 29 commits into
hashicorp:mainfrom
evgeniifedotov:efedotov/2025-03-01-Terraform-AzureRM-for-ADBS-Cross-Region_Disaster-Recovery

Conversation

@evgeniifedotov
Copy link
Copy Markdown

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

To support new Oracle resource type Cross Region Disaster Recovery Autonomous Database the following changes have been made to the Oracle provider: added new resource oracle_autonomous_database_cross_region_disaster_recovery_resource and corresponding data source oracle_autonomous_database_cross_region_disaster_recovery_data_source

New resource oracle_autonomous_database_cross_region_disaster_recovery_resource has following required arguments:

name,
display_name,
location,
database_type,
source,
source_id,
source_ocid,
remote_disaster_recovery_type,
replicate_automatic_backups,
subnet_id,
virtual_network_id,
resource_group_name,
source_location,
license_model,
backup_retention_period_in_days,
auto_scaling_enabled,
auto_scaling_for_storage_enabled,
mtls_connection_required,
data_storage_size_in_tbs,
compute_model,
compute_count,
db_workload,
db_version,
admin_password,
character_set,
national_character_set

New data source oracle_autonomous_database_cross_region_disaster_recovery_data_source has following attributes:

The following arguments are supported:

  • name - (Required) The name of this Autonomous Database.

  • resource_group_name - (Required) The name of the Resource Group where the Autonomous Database exists.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • actual_used_data_storage_size_in_tbs - The current amount of storage in use for user and system data, in terabytes (TB).

  • allocated_storage_size_in_tbs - The amount of storage currently allocated for the database tables and billed for, rounded up. When auto-scaling is not enabled, this value is equal to the dataStorageSizeInTBs value. You can compare this value to the actualUsedDataStorageSizeInTBs value to determine if a manual shrink operation is appropriate for your allocated storage.

  • auto_scaling_enabled - Indicates if auto scaling is enabled for the Cross Region Disaster Recovery Autonomous Database CPU core count.

  • auto_scaling_for_storage_enabled - Indicates if auto scaling is enabled for the Cross Region Disaster Recovery Autonomous Database storage.

  • backup_retention_period_in_days - Retention period, in days, for backups.

  • character_set - The character set for the Cross Region Disaster Recovery Autonomous Database.

  • compute_count - The compute amount (CPUs) available to the cross region disaster recovery database.

  • compute_model - The compute model of the Cross Region Disaster Recovery Autonomous Database.

  • database_type - The type of this Cross Region Disaster Recovery Autonomous Database.

  • db_workload - The Autonomous Database workload type. The following values are possible:

    • OLTP - indicates an Autonomous Transaction Processing database
    • DW - indicates an Autonomous Data Warehouse database
    • AJD - indicates an Autonomous JSON Database
    • APEX - indicates an Autonomous Database with the Oracle APEX Application Development workload type.
  • display_name - The user-friendly name for the Cross Region Disaster Recovery Autonomous Database. The name does not have to be unique.

  • id - The Immutable Azure Resource ID of the Cross Region Disaster Recovery Autonomous Database.

  • license_model - The Oracle license model that applies to the Oracle Cross Region Disaster Recovery Autonomous Database.

  • lifecycle_details - Information about the current lifecycle state.

  • local_data_guard_enabled - Indicates whether the Cross Region Disaster Recovery Autonomous Database has local (in-region) Data Guard enabled. Not applicable to cross-region Autonomous Data Guard associations, or to Autonomous Databases using dedicated Exadata infrastructure or Exadata Cloud@Customer infrastructure.

  • location - The Azure Region where the Cross Region Disaster Recovery Autonomous Database exists.

  • mtls_connection_required - Specifies if the Cross Region Disaster Recovery Autonomous Database requires mTLS connections.

  • name - The name of this Cross Region Disaster Recovery Autonomous Database.

  • national_character_set - The national character set for the Cross Region Disaster Recovery Autonomous Database. The default is AL16UTF16. Allowed values are: AL16UTF16 or UTF8.

  • oci_url - The URL of the resource in the OCI console.

  • ocid - The OCID of the autonomous database.

  • peer_db_ids - The list of Immutable Azure Resource IDs of Autonomous Databases peered with this Cross Region Disaster Recovery Autonomous Database.

  • private_endpoint - The private endpoint for the resource.

  • private_endpoint_ip - The private endpoint Ip address for the resource.

  • private_endpoint_label - The private endpoint label for the resource.

  • remote_data_guard_enabled - Indicates whether the Cross Region Disaster Recovery Autonomous Database has Cross Region Data Guard enabled. Not applicable to Autonomous Databases using dedicated Exadata infrastructure or Exadata Cloud@Customer infrastructure.

  • remote_disaster_recovery_type - Type of recovery. Value can be either Adg (Autonomous Data Guard) or BackupBased.

  • replicate_automatic_backups - If true, 7 days worth of backups are replicated across regions for Cross-Region ADB or Backup-Based Disaster Recovery between Primary and Standby. If false, the backups taken on the Primary are not replicated to the Standby database.

  • source - The source of the database. For cross region disaster recovery autonomous database the source is always "CrossRegionDisasterRecovery" as this type of autonomous database can be created only as disaster recovery solution for another autonomous database.

  • source_id - The Immutable Azure Resource ID of autonomous database for which cross region disaster recovery autonomous database was created.

  • source_location - The Azure Region where source autonomous database for which cross region disaster recovery autonomous database is located

  • source_ocid - The OCID of the autonomous database for which cross region disaster recovery autonomous database was created.

  • subnet_id - The OCID of the subnet the resource is associated with.

  • supported_regions_to_clone_to - The list of regions that support the creation Cross Region Disaster Recovery clone. List is always empty as Cross Region Disaster Recovery Autonomous Database cannot be cloned.

  • time_created - The date and time the Autonomous Database was created.

  • time_data_guard_role_changed - The date and time the Autonomous Data Guard role was switched for the Cross Region Disaster Recovery Autonomous Database. For databases that have standbys in both the primary Data Guard region and a remote Data Guard standby region, this is the latest timestamp of either the database using the "primary" role in the primary Data Guard region, or database located in the remote Data Guard standby region.

  • time_maintenance_begin - The date and time when maintenance will begin.

  • time_maintenance_end - The date and time when maintenance will end.

  • virtual_network_id - The ID to an Azure Resource Manager vnet resource.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevant documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass.
    Cross Region Disaster Recovery Autonomous Database cannot be imported. admin_password parameter is required, but this parameter cannot be imported, therefore the entire import procedure and 'requiresImport' test method cannot be executed.
    Cross Region Disaster Recovery Autonomous Database cannot itself be updated as is must have exactly same parameters as peered original Autonomous Database. Updating original Autonomous Database will trigger an update for peered Cross Region Disaster Recovery Autonomous Database, therefore update test cannot be executed.

Complete test to create new instance is passing
Screenshot 2025-07-15 at 13 53 37

DataSource test is passing
Screenshot 2025-07-15 at 12 13 03

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • oracle_autonomous_database_cross_region_disaster_recovery_resource - support for the new Oracle Cross Region Disaster Recovery Autonomous Database resource

  • oracle_autonomous_database_cross_region_disaster_recovery_data_source - support for the new Oracle Cross Region Disaster Recovery Autonomous Database data source

This is a (please select all that apply):

  • New Feature (ie adding a service, resource, or data source)

Related Issue(s)

Fixes #30166

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Copy link
Copy Markdown
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @evgeniifedotov - it looks like there are some build failures on this, if those could be fixed up, then I can take another look. Thanks!

Copy link
Copy Markdown
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @evgeniifedotov - could you take a look at resolving the conflicts on this pr? Then we can give this a proper review. Thanks!

@evgenwk evgenwk force-pushed the efedotov/2025-03-01-Terraform-AzureRM-for-ADBS-Cross-Region_Disaster-Recovery branch 2 times, most recently from ca3ab38 to 695f4b9 Compare August 7, 2025 15:12
@evgenwk
Copy link
Copy Markdown
Contributor

evgenwk commented Aug 7, 2025

@catriona-m The conflicts have been resolved. Could you please comment? Thank you.

@evgenwk evgenwk force-pushed the efedotov/2025-03-01-Terraform-AzureRM-for-ADBS-Cross-Region_Disaster-Recovery branch from 695f4b9 to 1ef44e2 Compare August 7, 2025 18:50
@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

@ms-henglu please help review this PR.

Copy link
Copy Markdown
Collaborator

@ms-henglu ms-henglu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, I left some comments, please check.

}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) ModelObject() interface{} {
return &AutonomousDatabaseCrossRegionDisasterRecoveryResource{}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should return "&AutonomousDatabaseCrossRegionDisasterRecoveryResourceModel{}"

Typed resources must return the model struct; returning the resource struct will break decode/encode.


var model AutonomousDatabaseCrossRegionDisasterRecoveryResourceModel
if err := metadata.Decode(&model); err != nil {
return err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap decode error instead of returning raw:
return fmt.Errorf("decoding: %+v", err)


var model AutonomousDatabaseCrossRegionDisasterRecoveryResourceModel
if err = metadata.Decode(&model); err != nil {
return fmt.Errorf("decoding err: %+v", err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return fmt.Errorf("decoding: %+v", err)


err = client.UpdateThenPoll(ctx, *id, *update)
if err != nil {
return fmt.Errorf("updating %s: %v", id, err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use %+v not %v:
return fmt.Errorf("updating %s: %+v", id, err)

Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
id, err := autonomousdatabases.ParseAutonomousDatabaseID(metadata.ResourceData.Id())
if err != nil {
return fmt.Errorf("retrieving %s: %+v", id, err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid referencing id when parsing fails; include the raw ID instead:

return fmt.Errorf("parsing %q: %+v", metadata.ResourceData.Id(), err)

---
subcategory: "Oracle"
layout: "azurerm"
page_title: "Azure Resource Manager: Data Source: azurerm_oracle_autonomous_database"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title should be "azurerm_oracle_autonomous_database_cross_region_disaster_recovery"

layout: "azurerm"
page_title: "Azure Resource Manager: Data Source: azurerm_oracle_autonomous_database"
description: |-
Gets information about an existing Autonomous Database.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description should be "Gets information about an existing Cross Region Disaster Recovery Autonomous Database."

source_id = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.source_id
source_ocid = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.source_ocid
remote_disaster_recovery_type = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.remote_disaster_recovery_type
replicate_automatic_backups_enabled = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.replicate_automatic_backups
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it shoud be:

replicate_automatic_backups_enabled = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.replicate_automatic_backups_enabled

## Example Usage

```hcl
resource "azurerm_oracle_autonomous_database_cross_region_disaster_recovery" "adbs_secondary_crdr" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please use a complete example here instead of using the placeholders.

Type: pluginsdk.TypeBool,
Computed: true,
},
"database_type": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to expose all the readonly fields, maybe just the fields that could be referenced by other resources.

@evgenwk evgenwk force-pushed the efedotov/2025-03-01-Terraform-AzureRM-for-ADBS-Cross-Region_Disaster-Recovery branch from 91842ea to 17062ad Compare September 5, 2025 15:13
@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

@ms-henglu I have addressed the latest comments . Could you please check?

func (AutonomousDatabaseRegularResource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{}
return map[string]*pluginsdk.Schema{
"ocid": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update this change in the document.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not resolved yet

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is still not resolved, the documentation for azurerm_oracle_autonomous_database doesn't include this attribute

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed this attribute as its not needed to be in the resource file .

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.AdbsComputeModel,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For properties which have a set of allowed values, please update the validate func like below:

ValidateFunc: validation.StringInSlice(autonomousdatabases.PossibleValuesForComputeModel(), false),

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this to

ValidateFunc: validation.StringInSlice(autonomousdatabases.PossibleValuesForWorkloadType(), false),

But I also noticed that PossibleValuesForWorkloadType contain "AJD" and "APEX", can these values be used here?

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

	ValidateFunc: validation.StringInSlice(autonomousdatabases.PossibleValuesForLicenseModel(), false),

r := AdbsCrossRegionDisasterRecoveryResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.requiresImport(data),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the import testcase, the first step should use the basic configuration to set up the resource.

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.DatabaseType,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use

ValidateFunc: validation.StringInSlice(autonomousdatabases.PossibleValuesForDataBaseType(), false),

"github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2025-03-01/autonomousdatabases"
)

func DbSource(i interface{}, k string) (warnings []string, errors []error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file as these validate functions are not used.

## Example Usage

```hcl
resource "azurerm_oracle_autonomous_database_cross_region_disaster_recovery" "example" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a complete configuration as an example.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs complete example, resource dependencies such as the resource group, virtual network, etc. must be added.

See Provider Documentation Standards - Examples


* `location` - (Required) The Azure Region where the Cross Region Disaster Recovery Autonomous Database should exist. Azure Region must be different from region where your original Autonomous Database resides. Changing this forces a new Cross Region Disaster Recovery Autonomous Database to be created.

* `database_type` - (Required) The type of Autonomous Database. To create Cross Region Disaster Recovery Autonomous Database set this value to "CrossRegionDisasterRecovery".
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the properties that are marked as "ForceNew". Please add "Changing this forces a new resource to be created." to the description.

Please also check:
name
database_type
source
remote_disaster_recovery_type
admin_password
backup_retention_period_in_days
character_set
compute_model
db_version
db_workload
display_name
mtls_connection_required
license_model
national_character_set
subnet_id
virtual_network_id
customer_contacts

@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

@ms-henglu can you please check this PR.

Copy link
Copy Markdown
Collaborator

@ms-henglu ms-henglu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

@catriona-m I see @ms-henglu has approved it , could you also please review the PR. Thank you.

Copy link
Copy Markdown
Collaborator

@sreallymatt sreallymatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @evgeniifedotov, this will need a bit of work before it can be merged into the provider.

Could you first review my comment in website/docs/r/oracle_autonomous_database_cross_region_disaster_recovery.html.markdown regarding the design of this resource? (here)

@@ -0,0 +1,535 @@
// Copyright © 2025, Oracle and/or its affiliates. All rights reserved
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright © 2025, Oracle and/or its affiliates. All rights reserved
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

Type: pluginsdk.TypeString,
Computed: true,
},
"source_id": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the resource test this looks like the id to an autonomous database, can you update this to be more specific as to what it is?

Suggested change
"source_id": {
"source_autonomous_database_id": {

},

// AutonomousDatabaseProperties
"actual_used_data_storage_size_in_tbs": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"actual_used_data_storage_size_in_tbs": {
"actual_used_data_storage_size_in_tb": {

Computed: true,
},

"allocated_storage_size_in_tbs": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"allocated_storage_size_in_tbs": {
"allocated_storage_size_in_tb": {

Comment on lines +156 to +159
"autonomous_database_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not the same as the id attribute for this datasource?

Please see #29633 (comment)


## Import

Cross Region Disaster Recovery Autonomous Database cannot be imported. `admin_password` parameter is required, but this parameter cannot be imported, therefore the entire import procedure cannot be executed.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have many resources that have password properties that aren't returned by the API. Generally users will just have to set ignore_changes on the properties that aren't imported, or we implement custom import logic.

Resources can always be imported.

Comment on lines +151 to +153
## Update

Cross Region Disaster Recovery Autonomous Database cannot be updated as is must have exactly same parameters as peered original Autonomous Database. Updating original Autonomous Database will trigger an update for peered Cross Region Disaster Recovery Autonomous Database.
Copy link
Copy Markdown
Collaborator

@sreallymatt sreallymatt Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a heading we include in our docs, please remove.

Additionally, "Cross Region Disaster Recovery Autonomous Database cannot be updated as is must have exactly same parameters as peered original Autonomous Database" doesn't make sense since you have added an update function to this resource?

It sounds like this probably shouldn't have an update function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

NextLongTermBackupTimeStamp string `tfschema:"next_long_term_backup_time_stamp"`
Ocid string `tfschema:"ocid"`
OciUrl string `tfschema:"oci_url"`
PeerDbId string `tfschema:"peer_db_id"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #29633, it was brought up that peer_db_id is not actually returned, so there's no sense in exposing it?

Pleas remove any other attributes that don't return a value, always return a single value, or always return empty values (e.g. empty arrays as mentioned in the docs for supported_regions_to_clone_to)

Computed: true,
},

"peer_db_id": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not returned there's no need to expose it

Comment on lines +228 to +229
Optional: true,
Computed: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note as to why this must be optional+computed (ref)

@evgenwk evgenwk force-pushed the efedotov/2025-03-01-Terraform-AzureRM-for-ADBS-Cross-Region_Disaster-Recovery branch from 89810c0 to d9a7f6d Compare October 23, 2025 17:58
@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

New tests

Screenshot 2025-10-22 at 2 58 05 PM Screenshot 2025-10-22 at 5 43 21 PM

Comment on lines +1 to +2
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0

Comment on lines +1 to +2
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0

Comment on lines +1 to +2
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0

Comment on lines +1 to +2
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0

auto_scaling_enabled = false
auto_scaling_for_storage_enabled = false
mtls_connection_required = false
data_storage_size_in_tbs = 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the testcase pass?

Suggested change
data_storage_size_in_tbs = 1
data_storage_size_in_tb = 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ms-zhenhua in this part the parameter is passed to the oracle_autonomous_database_resource_test.go to create the primary database , in our legacy code that's how its written with an 's' check it here

Comment on lines +113 to +115
* `private_endpoint_url` - The private endpoint for the resource.

* `private_endpoint_label` - The private endpoint label for the resource.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `private_endpoint_url` - The private endpoint for the resource.
* `private_endpoint_label` - The private endpoint label for the resource.
* `private_endpoint_label` - The private endpoint label for the resource.
* `private_endpoint_url` - The private endpoint for the resource.

if sourceDb.Model == nil {
return fmt.Errorf("retrieving %s: `Model` was nil", sourceId)
}
sourceLocation := sourceDb.Model.Location
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not resolved.

Comment on lines +95 to +97
* `resource_group_name` - (Required) The name of the Resource Group where the resource should exist. Changing this forces a new resource to be created.

* `name` - (Required) The name for this Cross Region Disaster Recovery Autonomous Database. Changing this forces a new resource to be created.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `resource_group_name` - (Required) The name of the Resource Group where the resource should exist. Changing this forces a new resource to be created.
* `name` - (Required) The name for this Cross Region Disaster Recovery Autonomous Database. Changing this forces a new resource to be created.
* `name` - (Required) The name for this Cross Region Disaster Recovery Autonomous Database. Changing this forces a new resource to be created.
* `resource_group_name` - (Required) The name of the Resource Group where the resource should exist. Changing this forces a new resource to be created.


Use this data source to access information about an existing peered Cross Region Disaster Recovery Autonomous Database.

## Example Usage
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the guidance, all name arguments should be example or be prefixed with example-. Please update all name related arguments in the configuration.

Manages a Cross Region Disaster Recovery Autonomous Database.
A Cross Region Disaster Recovery Autonomous Database is an Autonomous Database with a specific Cross-Region Disaster Recovery role. It must be an exact copy of the Autonomous Database for which you want to create a Disaster Recovery instance. The Cross Region Disaster Recovery Autonomous Database must reside in a region that is different from the region of the main Autonomous Database. You must create a separate virtual network and subnet in this second region for the Cross Region Disaster Recovery Autonomous Database to be able to communicate with its original database.

## Example Usage
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the guidance, all name arguments should be example or be prefixed with example-. Please update all name related arguments in the configuration.

Copy link
Copy Markdown
Contributor

@mihretkidane-OCI mihretkidane-OCI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ms-zhenhua thank you , I have replied and addressed your latest comments.

return fmt.Errorf("retrieving %s: `Model` was nil", sourceId)
}
sourceLocation := location.Normalize(sourceDb.Model.Location)
if location.Normalize(model.Location) == location.Normalize(sourceLocation) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if location.Normalize(model.Location) == location.Normalize(sourceLocation) {
normalizedLocation = location.Normalize(model.Location)
if normalizedLocation == sourceLocation {


param := autonomousdatabases.AutonomousDatabase{
Name: pointer.To(model.Name),
Location: location.Normalize(model.Location),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Location: location.Normalize(model.Location),
Location: normalizedLocation,

if err != nil {
return err
}
VnetId := commonids.NewVirtualNetworkID(subnetId.SubscriptionId, subnetId.ResourceGroupName, subnetId.VirtualNetworkName)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VnetId := commonids.NewVirtualNetworkID(subnetId.SubscriptionId, subnetId.ResourceGroupName, subnetId.VirtualNetworkName)
vnetId := commonids.NewVirtualNetworkID(subnetId.SubscriptionId, subnetId.ResourceGroupName, subnetId.VirtualNetworkName)

return fmt.Errorf("retrieving %s: %+v", sourceId, err)
}
if sourceDb.Model == nil {
return fmt.Errorf("retrieving %s: `Model` was nil", sourceId)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("retrieving %s: `Model` was nil", sourceId)
return fmt.Errorf("retrieving %s: `model` was nil", sourceId)

VnetId := commonids.NewVirtualNetworkID(subnetId.SubscriptionId, subnetId.ResourceGroupName, subnetId.VirtualNetworkName)

if sourceDb.Model.Properties == nil {
return fmt.Errorf("retrieving %s: `Properties` was nil", sourceId)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("retrieving %s: `Properties` was nil", sourceId)
return fmt.Errorf("retrieving %s: `properties` was nil", sourceId)

}

resource "azurerm_subnet" "example_subnet" {
name = "exampleSubnet"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "exampleSubnet"
name = "example-subnet"



resource "azurerm_oracle_autonomous_database" "primary" {
name = "examplePrimary"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "examplePrimary"
name = "example-primary"

}

resource "azurerm_virtual_network" "dr_vnet" {
name = "exampleDrVnet"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "exampleDrVnet"
name = "example-dr-vnet"

}

resource "azurerm_subnet" "dr_subnet" {
name = "exampleDrSubnet"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "exampleDrSubnet"
name = "example-dr-subnet"

}

resource "azurerm_oracle_autonomous_database_cross_region_disaster_recovery" "dr_example" {
name = "exampleDr"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "exampleDr"
name = "example-dr"

@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

Screenshot 2026-02-11 at 1 44 07 PM Screenshot 2026-02-10 at 2 33 19 PM

Copy link
Copy Markdown
Contributor

@mihretkidane-OCI mihretkidane-OCI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ms-zhenhua I have updated the PR with new test and resolved last comments please take a look. Thanks!

@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

@sreallymatt could you please one more review to this PR. Thanks!

Comment on lines +34 to +37
}


resource "azurerm_oracle_autonomous_database" "primary" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
resource "azurerm_oracle_autonomous_database" "primary" {
}
resource "azurerm_oracle_autonomous_database" "primary" {

replicate_automatic_backups_enabled = false

}
`, a.template(data), data.RandomInteger, "eastus", "westus")
Copy link
Copy Markdown
Collaborator

@ms-zhenhua ms-zhenhua Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason that not use data.Locations.Primary but use const strings of "eastus", "westus" as the location?

@mihretkidane-OCI
Copy link
Copy Markdown
Contributor

@ms-zhenhua can you check the PR , I have updated to use location.primary and location.secondary . I have validated the PR as well see screenshots.

Screenshot 2026-05-07 at 9 33 22 AM Screenshot 2026-05-05 at 1 30 04 PM Screenshot 2026-05-05 at 12 05 42 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Cross region disaster recovery for autonomous database