Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a897961
Added new resource "Oracle Autonomous database cross region disaster …
evgeniifedotov May 23, 2025
5a30804
Oracle documentation added for Autonomous database cross region disas…
evgeniifedotov Jul 16, 2025
e794fc3
Fix code style for oracle_autonomous_database_cross_region_disaster_r…
evgen Aug 4, 2025
ca7b261
Oracle - Comment resolution
evgenwk Sep 5, 2025
af34669
Oracle code fixed - force new properties and removed manual validation
evgenwk Sep 11, 2025
3094e55
Oracle code fixed - rename fields
evgenwk Oct 23, 2025
619d5d1
Oracle code fixed - update code after review
evgenwk Oct 30, 2025
e6c5dad
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Dec 4, 2025
dfa1c16
Oracle code fixed - update code after review
evgenwk Dec 4, 2025
59e7568
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Jan 22, 2026
846b371
Oracle code fixed - update code after review
evgenwk Jan 22, 2026
aa28dae
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Jan 28, 2026
dfee32b
Oracle code fixed - update code after review
evgenwk Jan 28, 2026
b7b0c69
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Feb 3, 2026
63f98ca
Oracle code fixed - update code after review
evgenwk Feb 3, 2026
21ee0a3
Fix code style
evgenwk Feb 3, 2026
9c270c4
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Feb 11, 2026
5e48d23
Oracle - remove fields in the documentation
evgenwk Feb 11, 2026
c98cd6a
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Feb 12, 2026
a05b426
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Feb 25, 2026
80c8e4a
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Mar 6, 2026
1de8261
Oracle - update autonomous_database_cross_region_disaster_recovery
evgenwk Mar 6, 2026
3b3723a
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Mar 17, 2026
fb11058
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Apr 24, 2026
1f946ce
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk Apr 29, 2026
92d4345
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk May 7, 2026
64284db
Oracle - update autonomous_database_cross_region_disaster_recovery
evgenwk May 8, 2026
1fe038b
Merge branch 'main' into efedotov/2025-03-01-Terraform-AzureRM-for-AD…
evgenwk May 8, 2026
c7d6139
hjkhkashkdsa
mihretkidane-OCI May 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0
Comment on lines +1 to +2
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


package oracle_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/oracle"
)

type AutonomousDatabaseCrossRegionDisasterRecoveryDataSource struct{}

func TestAccAutonomousDatabaseCrossRegionDisasterRecoveryDataSource_basic(t *testing.T) {
data := acceptance.BuildTestData(t, oracle.AutonomousDatabaseCrossRegionDisasterRecoveryDataSource{}.ResourceType(), "adbs_secondary_crdr")
r := AutonomousDatabaseCrossRegionDisasterRecoveryDataSource{}
data.DataSourceTest(t, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(

check.That(data.ResourceName).Key("remote_disaster_recovery_type").HasValue("Adg"),
check.That(data.ResourceName).Key("source_autonomous_database_id").Exists(),
check.That(data.ResourceName).Key("location").Exists(),
check.That(data.ResourceName).Key("name").Exists(),
),
},
})
}

func (d AutonomousDatabaseCrossRegionDisasterRecoveryDataSource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
%s

data "azurerm_oracle_autonomous_database_cross_region_disaster_recovery" "adbs_secondary_crdr" {
name = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.name
resource_group_name = azurerm_oracle_autonomous_database_cross_region_disaster_recovery.adbs_secondary_crdr.resource_group_name
}
`, AdbsCrossRegionDisasterRecoveryResource{}.complete(data))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0
Comment on lines +1 to +2
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


package oracle

import (
"context"
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/oracledatabase/2025-09-01/autonomousdatabases"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/oracle/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
)

var _ sdk.Resource = AutonomousDatabaseCrossRegionDisasterRecoveryResource{}

type AutonomousDatabaseCrossRegionDisasterRecoveryResource struct{}

type AutonomousDatabaseCrossRegionDisasterRecoveryResourceModel struct {
Location string `tfschema:"location"`
Name string `tfschema:"name"`
ResourceGroupName string `tfschema:"resource_group_name"`
Tags map[string]string `tfschema:"tags"`
RemoteDisasterRecoveryType string `tfschema:"remote_disaster_recovery_type"`
SourceAutonomousDatabaseId string `tfschema:"source_autonomous_database_id"`
AutoScalingEnabled bool `tfschema:"auto_scaling_enabled"`
AutoScalingForStorageEnabled bool `tfschema:"auto_scaling_for_storage_enabled"`
BackupRetentionPeriodInDays int64 `tfschema:"backup_retention_period_in_days"`
CharacterSet string `tfschema:"character_set"`
ComputeCount float64 `tfschema:"compute_count"`
ComputeModel string `tfschema:"compute_model"`
DataStorageSizeInTb int64 `tfschema:"data_storage_size_in_tb"`
DatabaseVersion string `tfschema:"database_version"`
DatabaseWorkload string `tfschema:"database_workload"`
DisplayName string `tfschema:"display_name"`
LicenseModel string `tfschema:"license_model"`
MtlsConnectionRequired bool `tfschema:"mtls_connection_required"`
NationalCharacterSet string `tfschema:"national_character_set"`
SubnetId string `tfschema:"subnet_id"`
CustomerContacts []string `tfschema:"customer_contacts"`
ReplicateAutomaticBackupsEnabled bool `tfschema:"replicate_automatic_backups_enabled"`
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) Arguments() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
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 reorder the fields with the guidance

Image

"name": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validate.AutonomousDatabaseName,
ForceNew: true,
},

"resource_group_name": commonschema.ResourceGroupName(),

"location": commonschema.Location(),

"display_name": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.AutonomousDatabaseName,
},
"replicate_automatic_backups_enabled": {
Type: pluginsdk.TypeBool,
Required: true,
ForceNew: true,
},
"source_autonomous_database_id": commonschema.ResourceIDReferenceRequiredForceNew(&autonomousdatabases.AutonomousDatabaseId{}),

"subnet_id": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: commonids.ValidateSubnetID,
},
"tags": commonschema.TagsForceNew(),
}
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
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 reorder the fields with the guidance

Image

"auto_scaling_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},
"auto_scaling_for_storage_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},
"backup_retention_period_in_days": {
Type: pluginsdk.TypeInt,
Computed: true,
},
"character_set": {
Type: pluginsdk.TypeString,
Computed: true,
},
"compute_count": {
Type: pluginsdk.TypeFloat,
Computed: true,
},
"compute_model": {
Type: pluginsdk.TypeString,
Computed: true,
},
"customer_contacts": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},
"database_version": {
Type: pluginsdk.TypeString,
Computed: true,
},
"database_workload": {
Type: pluginsdk.TypeString,
Computed: true,
},
"data_storage_size_in_tb": {
Type: pluginsdk.TypeInt,
Computed: true,
},
"license_model": {
Type: pluginsdk.TypeString,
Computed: true,
},
"mtls_connection_required": {
Type: pluginsdk.TypeBool,
Computed: true,
},
"national_character_set": {
Type: pluginsdk.TypeString,
Computed: true,
},
"remote_disaster_recovery_type": {
Type: pluginsdk.TypeString,
Computed: true,
},
}
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) ModelObject() interface{} {
return &AutonomousDatabaseCrossRegionDisasterRecoveryResourceModel{}
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) ResourceType() string {
return "azurerm_oracle_autonomous_database_cross_region_disaster_recovery"
}

func (r AutonomousDatabaseCrossRegionDisasterRecoveryResource) Create() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 120 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
client := metadata.Client.Oracle.OracleClient.AutonomousDatabases
subscriptionId := metadata.Client.Account.SubscriptionId

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

sourceId, err := autonomousdatabases.ParseAutonomousDatabaseID(model.SourceAutonomousDatabaseId)
if err != nil {
return err
}
sourceDb, err := client.Get(ctx, *sourceId)
if err != nil {
return fmt.Errorf("retrieving %s: %+v", sourceId, err)
}
Comment on lines +203 to +205
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 consistency could you update this err msg to:

Suggested change
if err != nil {
return fmt.Errorf("fetching source DB: %+v", err)
}
if err != nil {
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)

}
Comment on lines +206 to +208
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 sourceDb.Model == nil {
return fmt.Errorf("source DB %s not found", model.SourceAutonomousDatabaseId)
}
if sourceDb.Model == nil {
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 {

return fmt.Errorf("disaster Recovery database must reside in a different region from the source database (source is '%s', target is '%s')", sourceLocation, model.Location)
}
subnetId, err := commonids.ParseSubnetID(model.SubnetId)
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)


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)

}
Comment on lines +218 to +221
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 all properties accessed here exist in the base implementation of the AutonomousDatabaseProperties field, could you update this to:

Suggested change
sourceProps, ok := sourceDb.Model.Properties.(autonomousdatabases.AutonomousDatabaseProperties)
if !ok {
return fmt.Errorf("unexpected source DB properties type")
}
if sourceDb.Model.Properties == nil {
return fmt.Errorf("retrieving %s: `Properties` was nil", sourceId)
}
sourceProps := sourceDb.Model.Properties.AutonomousDatabaseBaseProperties()

Instead of returning an error when the type assertion failed (which should only happen if Properties is nil), we can instead return a specific error indicating Properties was nil, then call the base properties func.

sourceProps := sourceDb.Model.Properties.AutonomousDatabaseBaseProperties()

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,

Tags: pointer.To(model.Tags),
Properties: &autonomousdatabases.AutonomousDatabaseCrossRegionDisasterRecoveryProperties{
Source: autonomousdatabases.SourceCrossRegionDisasterRecovery,
SourceId: model.SourceAutonomousDatabaseId,
SourceOcid: sourceProps.Ocid,
SourceLocation: pointer.To(sourceLocation),
RemoteDisasterRecoveryType: autonomousdatabases.DisasterRecoveryTypeAdg,
IsReplicateAutomaticBackups: pointer.To(model.ReplicateAutomaticBackupsEnabled),
AdminPassword: sourceProps.AdminPassword,
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 autonomous database resource, this field is not returned by the API.

I see 3 potential scenarios here:

  1. It is returned by the API, in which case this line is fine as is
  2. It is not returned by the API, in which case we'll have to add this as a property users must specify
  3. It is not returned by the API, but also not needed when creating a DR database, in which case we could simply remove this line entirely

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.

this is number 2 case and I am addressing it .

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?

BackupRetentionPeriodInDays: sourceProps.BackupRetentionPeriodInDays,
CharacterSet: sourceProps.CharacterSet,
ComputeCount: sourceProps.ComputeCount,
ComputeModel: sourceProps.ComputeModel,
CustomerContacts: sourceProps.CustomerContacts,
DataBaseType: autonomousdatabases.DataBaseTypeCrossRegionDisasterRecovery,
DataStorageSizeInTbs: sourceProps.DataStorageSizeInTbs,
DbWorkload: sourceProps.DbWorkload,
DbVersion: sourceProps.DbVersion,
DisplayName: pointer.To(model.DisplayName),
IsAutoScalingEnabled: sourceProps.IsAutoScalingEnabled,
IsAutoScalingForStorageEnabled: sourceProps.IsAutoScalingForStorageEnabled,
IsMtlsConnectionRequired: sourceProps.IsMtlsConnectionRequired,
LicenseModel: sourceProps.LicenseModel,
NcharacterSet: sourceProps.NcharacterSet,
SubnetId: pointer.To(model.SubnetId),
VnetId: pointer.To(VnetId.ID()),
},
}

id := autonomousdatabases.NewAutonomousDatabaseID(subscriptionId,
model.ResourceGroupName,
model.Name)
if err := client.CreateOrUpdateThenPoll(ctx, id, param); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
}

metadata.SetID(id)
return nil
},
}
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) Read() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 5 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
id, err := autonomousdatabases.ParseAutonomousDatabaseID(metadata.ResourceData.Id())
if err != nil {
return err
}

client := metadata.Client.Oracle.OracleClient.AutonomousDatabases
result, err := client.Get(ctx, *id)
if err != nil {
if response.WasNotFound(result.HttpResponse) {
return metadata.MarkAsGone(id)
}
return fmt.Errorf("retrieving %s: %+v", id, err)
}

state := AutonomousDatabaseCrossRegionDisasterRecoveryResourceModel{
Name: id.AutonomousDatabaseName,
ResourceGroupName: id.ResourceGroupName,
}
if model := result.Model; model != nil {
props, ok := model.Properties.(autonomousdatabases.AutonomousDatabaseCrossRegionDisasterRecoveryProperties)
if !ok {
return fmt.Errorf("%s was not of type `CrossRegionDisasterRecovery`", id)
}

state.ReplicateAutomaticBackupsEnabled = pointer.From(props.IsReplicateAutomaticBackups)
state.RemoteDisasterRecoveryType = string(props.RemoteDisasterRecoveryType)
state.SourceAutonomousDatabaseId = props.SourceId
state.AutoScalingEnabled = pointer.From(props.IsAutoScalingEnabled)
state.BackupRetentionPeriodInDays = pointer.From(props.BackupRetentionPeriodInDays)
state.AutoScalingForStorageEnabled = pointer.From(props.IsAutoScalingForStorageEnabled)
state.CharacterSet = pointer.From(props.CharacterSet)
state.ComputeCount = pointer.From(props.ComputeCount)
state.ComputeModel = pointer.FromEnum(props.ComputeModel)
state.CustomerContacts = flattenAdbsCustomerContacts(props.CustomerContacts)
state.DataStorageSizeInTb = pointer.From(props.DataStorageSizeInTbs)
state.DatabaseWorkload = pointer.FromEnum(props.DbWorkload)
state.DatabaseVersion = pointer.From(props.DbVersion)
state.DisplayName = pointer.From(props.DisplayName)
state.LicenseModel = pointer.FromEnum(props.LicenseModel)
state.Location = location.Normalize(model.Location)
state.NationalCharacterSet = pointer.From(props.NcharacterSet)
state.SubnetId = pointer.From(props.SubnetId)
state.Tags = pointer.From(model.Tags)
}
return metadata.Encode(&state)
},
}
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) Delete() sdk.ResourceFunc {
return sdk.ResourceFunc{
Timeout: 30 * time.Minute,
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
client := metadata.Client.Oracle.OracleClient.AutonomousDatabases

id, err := autonomousdatabases.ParseAutonomousDatabaseID(metadata.ResourceData.Id())
if err != nil {
return err
}

if err = client.DeleteThenPoll(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

return nil
},
}
}

func (AutonomousDatabaseCrossRegionDisasterRecoveryResource) IDValidationFunc() pluginsdk.SchemaValidateFunc {
return autonomousdatabases.ValidateAutonomousDatabaseID
}
Loading