operators: correctly update launch template default version on AWS image upgrade (#2097)

Co-authored-by: Adrian Stobbe <stobbe.adrian@gmail.com>
This commit is contained in:
Malte Poll 2023-07-12 16:50:36 +02:00 committed by GitHub
parent ff4b5db74c
commit e536ff6df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ package client
import (
"context"
"fmt"
"strconv"
"strings"
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
@ -55,7 +56,7 @@ func (c *Client) SetScalingGroupImage(ctx context.Context, scalingGroupID, image
ImageId: &imageURI,
},
LaunchTemplateId: launchTemplate.LaunchTemplateId,
SourceVersion: toPtr(fmt.Sprintf("%d", *launchTemplate.VersionNumber)),
SourceVersion: toPtr(strconv.FormatInt(*launchTemplate.VersionNumber, 10)),
},
)
if err != nil {
@ -77,7 +78,7 @@ func (c *Client) SetScalingGroupImage(ctx context.Context, scalingGroupID, image
ctx,
&ec2.ModifyLaunchTemplateInput{
LaunchTemplateId: launchTemplate.LaunchTemplateId,
DefaultVersion: toPtr(fmt.Sprintf("%d", createLaunchTemplateOut.LaunchTemplateVersion.VersionNumber)),
DefaultVersion: toPtr(strconv.FormatInt(*createLaunchTemplateOut.LaunchTemplateVersion.VersionNumber, 10)),
},
)
if err != nil {