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 - forceNew when decreasing storage.size_gb #25074

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions internal/services/mysql/mysql_flexible_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ func resourceMysqlFlexibleServer() *pluginsdk.Resource {

"tags": commonschema.Tags(),
},

CustomizeDiff: pluginsdk.CustomDiffWithAll(
pluginsdk.ForceNewIfChange("storage.0.size_gb", func(ctx context.Context, old, new, meta interface{}) bool {
return new.(int) < old.(int)
}),
),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ resource "azurerm_private_dns_zone_virtual_network_link" "test" {
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name

depends_on = [azurerm_subnet.test]
Copy link
Collaborator

Choose a reason for hiding this comment

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

how come this is needed?

Copy link
Contributor Author

@neil-yechenwei neil-yechenwei Feb 29, 2024

Choose a reason for hiding this comment

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

Recently I found testcases "TestAccDataSourceMySqlFlexibleServer_complete/TestAccMySqlFlexibleServer_complete/TestAccMySqlFlexibleServer_completeUpdate" are always failed in Teamcity Daily Run. After investigated, I found the root cause is that azurerm_private_dns_zone_virtual_network_link and azurerm_subnet cannot be deleted in parallel since azurerm_private_dns_zone_virtual_network_link is referring azurerm_subnet. So I added it to fix this issue.

}

resource "azurerm_mysql_flexible_server" "test" {
Expand Down Expand Up @@ -694,6 +696,8 @@ resource "azurerm_private_dns_zone_virtual_network_link" "test" {
private_dns_zone_name = azurerm_private_dns_zone.test.name
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name

depends_on = [azurerm_subnet.test]
}

resource "azurerm_mysql_flexible_server" "test" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/mysql_flexible_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ A `storage` block supports the following:

* `size_gb` - (Optional) The max storage allowed for the MySQL Flexible Server. Possible values are between `20` and `16384`.

-> **Note:** Decreasing `size_gb` forces a new resource to be created.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:
Expand Down
Loading