hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.59k stars 4.63k forks source link

azurerm_linux_web_app backup start_time cannot be set (drift introduced) in v3.90 #24776

Open Noel-Jones opened 8 months ago

Noel-Jones commented 8 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.6.6

AzureRM Provider Version

3.90.0

Affected Resource(s)/Data Source(s)

azurerm_linux_web_app

Terraform Configuration Files

At this time I can only provide the fragment where I set the start time. Hoping it is not necessary to reproduce a minimal config since this is drift but will find time if neceessary.

  backup {
    enabled = true
    name    = join("-", [local.wordpress-site-resource-name-prefix, each.key])
    storage_account_url = join("", [
      azurerm_storage_account.wordpress-website.primary_blob_endpoint,
      azurerm_storage_container.wordpress-website-backups[each.key].name,
      data.azurerm_storage_account_blob_container_sas.wordpress-website-backup-sas[each.key].sas
    ])
    schedule {
      frequency_interval       = 1
      frequency_unit           = "Day"
      keep_at_least_one_backup = true
      retention_period_days    = 60
      start_time               = each.value.backup_time # "2024-01-31T19:30:00Z"
    }
  }

Debug Output/Panic Output

Will need to provide later as an when I can produce a minimal case. However, I just ran with debug and note that the start time appears to be blank in the state.

            "backup": [
              {
                "enabled": true,
                "name": "xxxx-uk",
                "schedule": [
                  {
                    "frequency_interval": 1,
                    "frequency_unit": "Day",
                    "keep_at_least_one_backup": true,
                    "last_execution_time": "",
                    "retention_period_days": 60,
                    "start_time": ""
                  }

Whatever is changed in 3.90 is detecting that the start time is not set in state but the state is still not being updated after the change.

Expected Behaviour

No change. Your infrastructure matches the configuration.

Actual Behaviour

With v3.90 the start time is always being set

# azurerm_linux_web_app.wordpress-website["xxxx-uk"] will be updated in-place
  ~ resource "azurerm_linux_web_app" "wordpress-website" {
        id                                             = "/subscriptions/xxxx/resourceGroups/rg-appservice-web-001/providers/Microsoft.Web/sites/xxxx-uk"
        name                                           = "xxxx-uk"
        tags                                           = {
          redacted
        }
        # (22 unchanged attributes hidden)

      ~ backup {
            name                = "xxxx-uk"
            # (2 unchanged attributes hidden)

          ~ schedule {
              + start_time               = "2024-01-31T19:30:00Z"
                # (4 unchanged attributes hidden)
            }
        }

        # (1 unchanged block hidden)
    }

Steps to Reproduce

Upgrade / set provider to 3.90.0 and apply. Change detected. Approve change.

Repeat apply. Change detected. Give up.

Downgrade provider back to 3.89.0 and apply. No change detected.

Important Factoids

No response

References

No response

Noel-Jones commented 8 months ago

Further to this, with 3.89 I am seeing that changing the start time does cause the change to be applied

          ~ schedule {
              ~ start_time               = "2024-01-31T19:10:00Z" -> "2024-01-31T19:10:10Z"
                # (5 unchanged attributes hidden)
            }

UPDATED COMMENT due to innacuracy!

3.89 works correctly and set the backup time in state file and in the resource.

3.90 does not work. If a new backup time is specified this is not set against the resource and the state file entry is cleared (leading to repeated apply).

3.89 state after apply

            "schedule": [
              {
                "frequency_interval": 1,
                "frequency_unit": "Day",
                "keep_at_least_one_backup": true,
                "last_execution_time": "2024-02-04T19:10:00Z",
                "retention_period_days": 60,
                "start_time": "2024-01-31T19:10:10Z"
              }

3.90 state after apply

            "schedule": [
              {
                "frequency_interval": 1,
                "frequency_unit": "Day",
                "keep_at_least_one_backup": true,
                "last_execution_time": "",
                "retention_period_days": 60,
                "start_time": ""
              }
            ],

So this is not simply drift. With 3.90 it is not possible to set the start time.