Search code examples
pythonamazon-web-servicesboto3launch-template

How to stop launch template versions from incrementing?


I am trying to write some code to automate AMI image updates for ASG with launch templates. I had some deployed code that created a new launch template version, but it was failing with exception and creating new launch templates without fully finishing. This resulted in 20 newly created launch template versions. I have deleted them using CLI and left the default version 1. However, now when the code runs again, the newly created versions always start from 20. So a new version number will be 21, 22, ... Is that how launch templates work or is there a way to reset the versions to start increment again with versions 2, 3, ... ? The code I'm using is:

client.create_launch_template_version(
    DryRun=False,
    LaunchTemplateName=tt_name,
    SourceVersion=str(old_lt_version),
    LaunchTemplateData=expired_launch_template_data
)

I can confirm that old_lt_version value is 1.


Solution

  • You cannot set the version number manually. It will always increment to the next number regardless of what you've deleted. They only way to reset the versions would be to recreate the resource.