Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_mssql_managed_instance_failover_group: add property secondary_type #28633

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MsSqlManagedInstanceFailoverGroupModel struct {
ManagedInstanceId string `tfschema:"managed_instance_id"`
PartnerManagedInstanceId string `tfschema:"partner_managed_instance_id"`
ReadOnlyEndpointFailoverPolicyEnabled bool `tfschema:"readonly_endpoint_failover_policy_enabled"`
SecondaryType string `tfschema:"secondary_type"`

ReadWriteEndpointFailurePolicy []MsSqlManagedInstanceReadWriteEndpointFailurePolicyModel `tfschema:"read_write_endpoint_failover_policy"`

Expand Down Expand Up @@ -118,6 +119,15 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Arguments() map[string]*plugi
},
},
},

"secondary_type": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
string(instancefailovergroups.SecondaryInstanceTypeGeo),
string(instancefailovergroups.SecondaryInstanceTypeStandby),
}, false),
},
}
}

Expand Down Expand Up @@ -207,6 +217,7 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Create() sdk.ResourceFunc {
PartnerManagedInstanceId: utils.String(partnerId.ID()),
},
},
SecondaryType: pointer.To(instancefailovergroups.SecondaryInstanceType(model.SecondaryType)),
},
}

Expand Down Expand Up @@ -286,6 +297,7 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Update() sdk.ResourceFunc {
PartnerManagedInstanceId: utils.String(partnerId.ID()),
},
},
SecondaryType: pointer.To(instancefailovergroups.SecondaryInstanceType(state.SecondaryType)),
},
}

Expand Down Expand Up @@ -380,6 +392,10 @@ func (r MsSqlManagedInstanceFailoverGroupResource) Read() sdk.ResourceFunc {
}
}

if secondaryType := props.SecondaryType; secondaryType != nil {
model.SecondaryType = string(pointer.From(props.SecondaryType))
}

model.ReadWriteEndpointFailurePolicy = []MsSqlManagedInstanceReadWriteEndpointFailurePolicyModel{
{
Mode: string(props.ReadWriteEndpoint.FailoverPolicy),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAccMsSqlManagedInstanceFailoverGroup_update(t *testing.T) {
Config: r.update(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("secondary_type").HasValue("Geo"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -67,6 +68,7 @@ resource "azurerm_mssql_managed_instance_failover_group" "test" {
location = "%[3]s"
managed_instance_id = azurerm_mssql_managed_instance.test.id
partner_managed_instance_id = azurerm_mssql_managed_instance.secondary.id
secondary_type = "Standby"

read_write_endpoint_failover_policy {
mode = "Manual"
Expand All @@ -89,6 +91,7 @@ resource "azurerm_mssql_managed_instance_failover_group" "test" {
location = "%[3]s"
managed_instance_id = azurerm_mssql_managed_instance.test.id
partner_managed_instance_id = azurerm_mssql_managed_instance.secondary.id
secondary_type = "Geo"

readonly_endpoint_failover_policy_enabled = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ The following arguments are supported:

* `readonly_endpoint_failover_policy_enabled` - (Optional) Failover policy for the read-only endpoint. Defaults to `true`.

* `secondary_type` - (Optional) The type of the secondary Managed Instance. Possible values are `Geo`, `Standby`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

idk yet what the default value is


---

A `read_write_endpoint_failover_policy` block supports the following:
Expand Down
Loading