feat: automatically recreate azure bastion vm with latest version#167
Open
feat: automatically recreate azure bastion vm with latest version#167
Conversation
timtalbot
commented
Mar 6, 2026
| opts=pulumi.ResourceOptions( | ||
| parent=self, | ||
| protect=False, # allow the VM to be recreated on image version updates | ||
| replace_on_changes=["storageProfile.imageReference.version"], |
Contributor
Author
There was a problem hiding this comment.
replace_on_changes forces VM recreation when the imageReference version changes, otherwise it would be an update which doesn't actually update the image running on the VM.
timtalbot
commented
Mar 6, 2026
| parent=self, | ||
| protect=False, # allow the VM to be recreated on image version updates | ||
| replace_on_changes=["storageProfile.imageReference.version"], | ||
| delete_before_replace=True, |
Contributor
Author
There was a problem hiding this comment.
We ensure we delete the old VM first so it cleans up its disks and has no conflicts with the pending new VM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change implements automatic recreation of Azure Bastion jumpbox VMs when a new Ubuntu image version becomes available. Previously, the jumpbox VM used
version="latest"which would only apply the latest image on initial creation, but would not update existing VMs when new images were released. This change fetches the actual latest version number at Pulumi runtime and configures the VM resource to be automatically recreated when that version changes.Code Flow
1. Image Version Discovery (azure_sdk.py)
The new
get_latest_vm_image_version()function queries the Azure Compute Management API to retrieve all available versions for a given image (publisher/offer/SKU combination), then sorts them tofind the latest:
This replaces the use of the magic "latest" string with a concrete version number that Pulumi can track for changes.
2. Bastion VM Configuration (azure_bastion.py)
The AzureBastion component now:
3. Integration (azure_workload_persistent.py)
The _define_bastion() method:
Category of change
Checklist