Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/cloud/services/ec2/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,19 @@ func (s *Service) LaunchTemplateNeedsUpdate(scope scope.LaunchTemplateScope, inc
if incoming.InstanceType != existing.InstanceType {
return true, nil
}

if !cmp.Equal(incoming.InstanceMetadataOptions, existing.InstanceMetadataOptions) {
return true, nil
}

if !cmp.Equal(incoming.SpotMarketOptions, existing.SpotMarketOptions) {
return true, nil
}

if !cmp.Equal(incoming.SSHKeyName, existing.SSHKeyName) {
return true, nil
}

incomingIDs, err := s.GetAdditionalSecurityGroupsIDs(incoming.AdditionalSecurityGroups)
if err != nil {
return false, err
Expand Down
30 changes: 30 additions & 0 deletions pkg/cloud/services/ec2/launchtemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,36 @@ func TestServiceLaunchTemplateNeedsUpdate(t *testing.T) {
want: true,
wantErr: false,
},
{
name: "Should return true if SSH key names are different",
incoming: &expinfrav1.AWSLaunchTemplate{
SSHKeyName: aws.String("new-key"),
},
existing: &expinfrav1.AWSLaunchTemplate{
AdditionalSecurityGroups: []infrav1.AWSResourceReference{
{ID: aws.String("sg-111")},
{ID: aws.String("sg-222")},
},
SSHKeyName: aws.String("old-key"),
},
want: true,
wantErr: false,
},
{
name: "Should return true if one has SSH key name and other doesn't",
incoming: &expinfrav1.AWSLaunchTemplate{
SSHKeyName: aws.String("new-key"),
},
existing: &expinfrav1.AWSLaunchTemplate{
AdditionalSecurityGroups: []infrav1.AWSResourceReference{
{ID: aws.String("sg-111")},
{ID: aws.String("sg-222")},
},
SSHKeyName: nil,
},
want: true,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading