Skip to content

Commit

Permalink
Move pickArchitectureForInstanceType call
Browse files Browse the repository at this point in the history
This prevent logging perms error which are not relevant when you have a Spec.AMI.ID
  • Loading branch information
enxebre committed Dec 15, 2023
1 parent 2a790d4 commit ed88eca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/cloud/services/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use

var err error

imageArchitecture, err := s.pickArchitectureForInstanceType(input.Type)
if err != nil {
return nil, err
}

// Pick image from the machine configuration, or use a default one.
if scope.AWSMachine.Spec.AMI.ID != nil { //nolint:nestif
input.ImageID = *scope.AWSMachine.Spec.AMI.ID
Expand All @@ -163,6 +158,11 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use
imageLookupBaseOS = scope.InfraCluster.ImageLookupBaseOS()
}

imageArchitecture, err := s.pickArchitectureForInstanceType(input.Type)
if err != nil {
return nil, err
}

if scope.IsEKSManaged() && imageLookupFormat == "" && imageLookupOrg == "" && imageLookupBaseOS == "" {
input.ImageID, err = s.eksAMILookup(*scope.Machine.Spec.Version, imageArchitecture, scope.AWSMachine.Spec.AMI.EKSOptimizedLookupType)
if err != nil {
Expand Down

0 comments on commit ed88eca

Please sign in to comment.