All credits go to How to debug Terraform variable content using this custom module, this is just a note to copy & past to my projects
resource "null_resource" "terraform_debug" {
provisioner "local-exec" {
command = "echo $VARIABLE1 >> debug.txt"
environment = {
VARIABLE1 = jsonencode(var.example)
}
}
}
Remove from state
to be re-generated again
terraform state rm null_resource.terraform_debug
Big gotcha… just happen when do a terraform apply