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_mysql_flexible_server suggests in-place update for storage size down-scale #25043

Closed
1 task done
sigv opened this issue Feb 27, 2024 · 2 comments · Fixed by #25074
Closed
1 task done

azurerm_mysql_flexible_server suggests in-place update for storage size down-scale #25043

sigv opened this issue Feb 27, 2024 · 2 comments · Fixed by #25074

Comments

@sigv
Copy link
Contributor

sigv commented Feb 27, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.7.4

AzureRM Provider Version

3.93.0

Affected Resource(s)/Data Source(s)

azurerm_mysql_flexible_server

Terraform Configuration Files

# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_flexible_server
# Example from documentation, with additional `storage` block.

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "example-vn"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "example" {
  name                 = "example-sn"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]
  service_endpoints    = ["Microsoft.Storage"]
  delegation {
    name = "fs"
    service_delegation {
      name = "Microsoft.DBforMySQL/flexibleServers"
      actions = [
        "Microsoft.Network/virtualNetworks/subnets/join/action",
      ]
    }
  }
}

resource "azurerm_private_dns_zone" "example" {
  name                = "example.mysql.database.azure.com"
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "example" {
  name                  = "exampleVnetZone.com"
  private_dns_zone_name = azurerm_private_dns_zone.example.name
  virtual_network_id    = azurerm_virtual_network.example.id
  resource_group_name   = azurerm_resource_group.example.name
}

resource "azurerm_mysql_flexible_server" "example" {
  name                   = "example-fs"
  resource_group_name    = azurerm_resource_group.example.name
  location               = azurerm_resource_group.example.location
  administrator_login    = "psqladmin"
  administrator_password = "H@Sh1CoR3!"
  backup_retention_days  = 7
  delegated_subnet_id    = azurerm_subnet.example.id
  private_dns_zone_id    = azurerm_private_dns_zone.example.id
  sku_name               = "GP_Standard_D2ds_v4"

  storage {
    size_gb = 30 # attribute to change
  }

  depends_on = [azurerm_private_dns_zone_virtual_network_link.example]
}

Debug Output/Panic Output

N/A.

Expected Behaviour

When reducing storage.size_gb in configuration, the azurerm_mysql_flexible_server resource should be destroyed and re-created.

The same applies when auto-grow has increased the actual size_gb value, resulting in configuration drift.

Actual Behaviour

Terraform suggests an in-place update.

  # azurerm_mysql_flexible_server.example will be updated in-place
  ~ resource "azurerm_mysql_flexible_server" "main" {
      ~ storage {
          ~ size_gb            = 40 -> 30
        }
    }

Steps to Reproduce

  1. terraform apply
  2. Decrease storage.size_gb from 30 to 20.
  3. terraform apply

Important Factoids

N/A.

References

Azure Database for MySQL - Flexible Server service tiers: Storage explicitly notes:

Storage can only be scaled up, not down.

@rcskosir
Copy link
Contributor

rcskosir commented Mar 4, 2024

Thank you for taking the time to open this issue. Please subscribe to PR #25074 created by @neil-yechenwei for this issue.

Copy link

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants