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_configuration - Remove ForceNew for value #22557

Merged
merged 8 commits into from
Jul 21, 2023
Merged
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 @@ -20,8 +20,9 @@ import (

func resourceMySQLFlexibleServerConfiguration() *pluginsdk.Resource {
return &pluginsdk.Resource{
Create: resourceMySQLFlexibleServerConfigurationCreate,
Create: resourceMySQLFlexibleServerConfigurationUpdate,
Copy link
Member

Choose a reason for hiding this comment

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

Can we have separate Create and Update methods here and not re-use, we will need this going forward in any case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Updated.

image

Read: resourceMySQLFlexibleServerConfigurationRead,
Update: resourceMySQLFlexibleServerConfigurationUpdate,
Delete: resourceMySQLFlexibleServerConfigurationDelete,

Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error {
Expand Down Expand Up @@ -55,19 +56,18 @@ func resourceMySQLFlexibleServerConfiguration() *pluginsdk.Resource {
"value": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
},
}
}

func resourceMySQLFlexibleServerConfigurationCreate(d *pluginsdk.ResourceData, meta interface{}) error {
func resourceMySQLFlexibleServerConfigurationUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).MySQL.FlexibleServers.Configurations
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d)
ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

log.Printf("[INFO] preparing arguments for AzureRM MySQL Configuration creation.")
log.Printf("[INFO] preparing arguments for AzureRM MySQL Configuration update.")

payload := configurations.Configuration{
Properties: &configurations.ConfigurationProperties{
Expand All @@ -80,7 +80,7 @@ func resourceMySQLFlexibleServerConfigurationCreate(d *pluginsdk.ResourceData, m

id := configurations.NewConfigurationID(subscriptionId, d.Get("resource_group_name").(string), d.Get("server_name").(string), d.Get("name").(string))
if err := client.UpdateThenPoll(ctx, id, payload); err != nil {
return fmt.Errorf("creating %s: %v", id, err)
return fmt.Errorf("updating %s: %v", id, err)
}

d.SetId(id.ID())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ func TestAccMySQLFlexibleServerConfiguration_logSlowAdminStatements(t *testing.T
})
}

func TestAccMySQLFlexibleServerConfiguration_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_mysql_flexible_server_configuration", "test")
r := MySQLFlexibleServerConfigurationResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.template(data, "slow_query_log", "OFF"),
Check: acceptance.ComposeTestCheckFunc(
data.CheckWithClient(r.checkValue("OFF")),
),
},
data.ImportStep(),
{
Config: r.template(data, "slow_query_log", "ON"),
Copy link
Member

Choose a reason for hiding this comment

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

Can we follow the pattern here in the other tests rather than specifying the template directly? e.g. Config: r.characterSetServer(data),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Updated.

image

Check: acceptance.ComposeTestCheckFunc(
data.CheckWithClient(r.checkValue("ON")),
),
},
data.ImportStep(),
})
}

func (t MySQLFlexibleServerConfigurationResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := configurations.ParseConfigurationID(state.ID)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The following arguments are supported:

* `resource_group_name` - (Required) The name of the resource group in which the MySQL Flexible Server exists. Changing this forces a new resource to be created.

* `value` - (Required) Specifies the value of the MySQL Flexible Server Configuration. See the MySQL documentation for valid values. Changing this forces a new resource to be created.
* `value` - (Required) Specifies the value of the MySQL Flexible Server Configuration. See the MySQL documentation for valid values.

## Attributes Reference

Expand Down