Treat nil of LaunchTemplateSpecification.Version as $Default [0]

[0] https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_LaunchTemplateSpecification.html
This commit is contained in:
Hanfei Shen 2020-02-15 11:37:34 +08:00
parent a3633ad294
commit 5ff9b2b91e
1 changed files with 2 additions and 2 deletions

View File

@ -598,7 +598,7 @@ func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (
//See what version the ASG is set to use
mixedVersion := aws.StringValue(g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.Version)
//Correctly Handle Default and Latest Versions
if mixedVersion == "$Default" || mixedVersion == "$Latest" {
if mixedVersion == "" || mixedVersion == "$Default" || mixedVersion == "$Latest" {
request := &ec2.DescribeLaunchTemplatesInput{
LaunchTemplateNames: []*string{&name},
}
@ -607,7 +607,7 @@ func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (
return "", fmt.Errorf("error describing launch templates: %v", err)
}
launchTemplate := dltResponse.LaunchTemplates[0]
if mixedVersion == "$Default" {
if mixedVersion == "" || mixedVersion == "$Default" {
version = strconv.FormatInt(*launchTemplate.DefaultVersionNumber, 10)
} else {
version = strconv.FormatInt(*launchTemplate.LatestVersionNumber, 10)