New here, so apologies in advanced in this is an inappropriate place for this question.
My team uses GitHub Workflow Actions with Terraform. We’re performing various types of value validations and checks within our .tf
files.
At the moment, we’re trying to output Workflow Annotation message to the Workflow logs when certain criteria are met. We have various use-cases, the simplest being to notify users that they’re using deprecated variables on our Terraform module.
We’ve achieved this using the check
block, such as in the following simple example:
check using_legacy_variable {
assert {
condition = var.old_variable_name == null
error_message = <<-EOT
::warning::Deprecated Variable: 'old_variable_name'.
The variable 'old_variable_name' is deprecated. Please use 'new_variable_name' instead.
EOT
}
}
This renders a nicely formatted warning annotation in the Summary section of our GitHub Workflow.
However, I’m struggling to achieve the same result using provisioner "local-exec"
block, such as in this example:
resource "null_resource" "track_partition_count_change" {
for_each = local.event_hub_partition_counts
triggers = {
partition_count = each.value
}
provisioner "local-exec" {
command = "echo \"::warning::Deprecated Variable: 'old_variable_name'. The variable 'old_variable_name' is deprecated. Please use 'new_variable_name' instead.\""
}
}
resource "azurerm_eventhub" "hub" {
for_each = { for hub in var.event_hubs : hub.name => hub }
lifecycle {
replace_triggered_by = [null_resource.track_partition_count_changes[each.key]]
}
name = each.value.name
partition_count = local.event_hub_partition_counts[each.key]
}
Any advice would be greatly appreciated!