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_elasticpool - adding high_availability_replica_count property #28572

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

accts4mjs
Copy link

@accts4mjs accts4mjs commented Jan 22, 2025

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

#28542 - I recently built a hyperscale elastic pool for our Azure sql server using the azurerm_mssql_elastic_pool resource and was surprised the high_avilability_replica_count property was not part of the provider. We will use the default of 1 for our production servers but want to use a value of 0 for our test and DR servers. I added a null_resource with a powershell exec to run an az CLI command to change the replica but it felt clunky and I thought I'd try my hand at contributing to the provider for our team and for others.

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.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • 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. (if this is not possible for any reason, please include details of why you did or could not add test coverage)
make build && make acctests SERVICE='mssql' TESTARGS='-run=TestAccMsSqlElasticPool_hyperScale' TESTTIMEOUT='60m'
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
go generate ./internal/services/...
go generate ./internal/provider/
go install

==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/mssql -run=TestAccMsSqlElasticPool_hyperScale -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccMsSqlElasticPool_hyperScale
=== PAUSE TestAccMsSqlElasticPool_hyperScale
=== CONT  TestAccMsSqlElasticPool_hyperScale
--- PASS: TestAccMsSqlElasticPool_hyperScale (292.12s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql 292.134s

Additional testing (using locally built copy of azurerm with these changes):

│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp/azurerm in /lib/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # azurerm_mssql_elasticpool.this will be created
  + resource "azurerm_mssql_elasticpool" "this" {
      + enclave_type                    = (known after apply)
      + high_availability_replica_count = 2
      + id                              = (known after apply)
      + license_type                    = "LicenseIncluded"
      + location                        = "westus2"
      + maintenance_configuration_name  = "SQL_Default"
      + max_size_bytes                  = (known after apply)
      + max_size_gb                     = (known after apply)
      + name                            = "mjs-hyperscale-epool"
      + resource_group_name             = "rg-mjs"
      + server_name                     = "mjs-sql-server"

      + per_database_settings {
          + max_capacity = 4
          + min_capacity = 0.25
        }

      + sku {
          + capacity = 4
          + family   = "PRMS"
          + name     = "HS_PRMS"
          + tier     = "Hyperscale"
        }
    }

Result of change:

azurerm_mssql_elasticpool.this: Creation complete after 2m4s [id=/subscriptions/01483503-ddb6-431f-a330-6b9b098f4656/resourceGroups/rg-mjs/providers/Microsoft.Sql/servers/mjs-sql-server/elasticPools/mjs-hyperscale-epool]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Az CLI cmd to report # of replicas:

az sql elastic-pool show -g rg-mjs --server mjs-sql-server --name mjs-hyperscale-epool --query "highAvailabilityReplicaCount"
2

Terraform apply to change count to 0:

Terraform will perform the following actions:

  # azurerm_mssql_elasticpool.this will be updated in-place
  ~ resource "azurerm_mssql_elasticpool" "this" {
      ~ high_availability_replica_count = 2 -> 0
        id                              = "/subscriptions/01483503-ddb6-431f-a330-6b9b098f4656/resourceGroups/rg-mjs/providers/Microsoft.Sql/servers/mjs-sql-server/elasticPools/mjs-hyperscale-epool"
        name                            = "mjs-hyperscale-epool"
        tags                            = {}
        # (9 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
azurerm_mssql_elasticpool.this: Modifications complete after 16s [id=/subscriptions/01483503-ddb6-431f-a330-6b9b098f4656/resourceGroups/rg-mjs/providers/Microsoft.Sql/servers/mjs-sql-server/elasticPools/mjs-hyperscale-epool]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Change Log

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

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #28542

Note

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

@accts4mjs accts4mjs requested a review from a team as a code owner January 22, 2025 06:21
@accts4mjs accts4mjs changed the title Issue 28542 - azurerm_mssql_elasticpool - adding high_availability_replica_count property Issue 28542 - azurerm_mssql_elasticpool - adding high_availability_replica_count property Jan 22, 2025
@accts4mjs accts4mjs changed the title Issue 28542 - azurerm_mssql_elasticpool - adding high_availability_replica_count property azurerm_mssql_elasticpool - adding high_availability_replica_count property Jan 22, 2025
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 SQL Elastic Pool Hyperscale Replica Count
1 participant