terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

`azurerm_mssql_database` - read maintenance configuration only if database is not in elastic pool

Open richardfric opened this issue 3 years ago • 1 comments

Fix the case when DB is part of elastic pool - the subsequent terraform plan command shows false change of maintenance configuration name:

  ~ resource "azurerm_mssql_database" "example" {
        id                                  = "/subscriptions/xxx/resourceGroups/group/providers/Microsoft.Sql/servers/server/databases/example"
      ~ maintenance_configuration_name      = "SQL_WestEurope_DB_2" -> "SQL_Default"
        name                                = "example"

richardfric avatar Sep 09 '22 06:09 richardfric

Thanks @richardfric - would it not make more sense to change the schema to be computed? as otherwise the state/resource would not watch what is in azure?

Value is computed only in case db is part of elastic pool. I'm not sure if this can be reflected in schema because the default value is not nil. resource azurerm_mssql_database: maintenance_configuration_name: Default must be nil if computed

richardfric avatar Sep 15 '22 08:09 richardfric

@richardfric - it might then be best to pull the default out of schema, mark it as computed, and then if it is not elastic set that default during Creat()

katbyte avatar Sep 24 '22 03:09 katbyte

Thanks @richardfric - we have a test failure now howeveR:

------- Stdout: -------
=== RUN   TestAccMsSqlDatabaseExtendedAuditingPolicy_complete
=== PAUSE TestAccMsSqlDatabaseExtendedAuditingPolicy_complete
=== CONT  TestAccMsSqlDatabaseExtendedAuditingPolicy_complete
    testcase.go:110: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating/updating Database: (Name "acctest-db-220927234016426462" / Server Name "acctest-sqlserver-220927234016426462" / Resource Group "acctestRG-mssql-220927234016426462"): sql.DatabasesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidResourceId" Message="Invalid resource identifier '/subscriptions/*******/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/'."
        
          with azurerm_mssql_database.test,
          on terraform_plugin_test.tf line 21, in resource "azurerm_mssql_database" "test":
          21: resource "azurerm_mssql_database" "test" {
        
--- FAIL: TestAccMsSqlDatabaseExtendedAuditingPolicy_complete (213.06s)
FAIL

also should we update the docs with the behaviour for elastic?

I wonder why all checks have passed when there was actually an error in tests. Problem with empty name should be now fixed and I've also added note to docs about conflict with elastic pool setting.

richardfric avatar Sep 28 '22 08:09 richardfric

Would this address https://github.com/hashicorp/terraform-provider-azurerm/issues/18621 ?

Currently, not specifying the maintenance configuration when one is specified for the elastic pool gives the following error: "Specified public maintenance configuration 'SQL_Default' for the database 'my-db' conflicts with the maintenance configuration 'DB_1' of the elastic pool 'my-pool'."

Whereas specifying it gives the error referenced in the issue above.

pierluca avatar Oct 05 '22 08:10 pierluca

Would this address #18621 ?

Currently, not specifying the maintenance configuration when one is specified for the elastic pool gives the following error: "Specified public maintenance configuration 'SQL_Default' for the database 'my-db' conflicts with the maintenance configuration 'DB_1' of the elastic pool 'my-pool'."

Whereas specifying it gives the error referenced in the issue above.

Seems so. This issue is currently blocking upgrade paths for us to newer versions of the provider, unfortunately.

tareks avatar Oct 06 '22 20:10 tareks

This functionality has been released in v3.29.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] avatar Oct 28 '22 00:10 github-actions[bot]

Has this now become available in v3.29.0? I can't find it in the changelog

peterprumbach-telekom avatar Oct 28 '22 06:10 peterprumbach-telekom

Any updates on this issue? It is an important issue for my company, SMBC group

bkatsnelson avatar Nov 03 '22 14:11 bkatsnelson

Any updates on this issue? It is an important issue for my company, SMBC group

@bkatsnelson This PR is already merged, see #19083 for remaining problems.

richardfric avatar Nov 03 '22 17:11 richardfric

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Dec 07 '22 02:12 github-actions[bot]