Skip to content

Commit

Permalink
Added az account get-access-token
Browse files Browse the repository at this point in the history
  • Loading branch information
Abby Artagame committed Nov 14, 2024
1 parent 7f813e2 commit 6899ece
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tf/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,19 @@ resource "null_resource" "build_image_template" {
# }
provisioner "local-exec" {
command = <<EOT
# Start a background process to refresh the token
(while true; do
az account get-access-token
sleep 1800 # Refresh every 30 minutes
done) &
# Run the main image builder commands
az image builder run -n ${var.imageTemplateName} -g ${data.azurerm_resource_group.rg.name} --no-wait
az image builder wait -n ${var.imageTemplateName} -g ${data.azurerm_resource_group.rg.name} --custom "lastRunStatus.runState!='Running'"
az image builder show -n ${var.imageTemplateName} -g ${data.azurerm_resource_group.rg.name}
# Kill the background refresh process after completion
kill $!
EOT
}

Expand Down

0 comments on commit 6899ece

Please sign in to comment.