Hi guys,
I would like to trigger a null_resource depending on an azurerm_mssql_server resource change/update. Basically, if my azurerm_mssql_server resource is updated, I would like my null_resource to be triggered.
I know I could always trigger my null_resource, but I wonder if there is a way of detecting that my azurerm_mssql_server is being updated.
This is my code
resource "azurerm_mssql_server" "sql_01" {
name = "${var.dc_lid}-hy-${var.dc_iid}-sql01"
resource_group_name = azurerm_resource_group.this.name
location = azurerm_resource_group.this.location
version = "12.0"
minimum_tls_version = "1.2"
public_network_access_enabled = false
administrator_login = var.admin_login
administrator_login_password = data.azurerm_key_vault_secret.bus_admin_password.val e
azuread_administrator {
login_username = var.admin_login_sql_aad
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = var.admin_login_sql_aad
}
tags = local.tags
lifecycle {
ignore_changes = [ identity ]
}
}
resource "null_resource" "sql_01_configure_audit" {
triggers = {
configure_sql_audit_ps1 = sha1(file("${path.module}/res/sql/XYZ.ps1"))
}
provisioner "local-exec" {
command = "pwsh.exe -File .\\XYZ.ps1"
working_dir = "${path.module}/res/sql"
}
depends_on = [ azurerm_mssql_server.sql_01 ]
}
Thank you!
Alex