Skip to content

Commit

Permalink
fix: don't set AMI ID if empty
Browse files Browse the repository at this point in the history
If empty CAPA will fail with:
  failed to create AWSMachine instance: failed to run instance: MissingParameter: The request must contain the parameter ImageId
  • Loading branch information
dkoshkin committed Feb 9, 2024
1 parent 0cc2133 commit f486d5b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/handlers/aws/mutation/ami/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func (h *awsAMISpecPatchHandler) Mutate(
"patchedObjectName", client.ObjectKeyFromObject(obj),
).Info("setting AMI in AWSMachineTemplate spec")

obj.Spec.Template.Spec.AMI = capav1.AMIReference{ID: &amiSpecVar.ID}
if amiSpecVar.ID != "" {
obj.Spec.Template.Spec.AMI = capav1.AMIReference{ID: &amiSpecVar.ID}
}
if amiSpecVar.Lookup != nil {
obj.Spec.Template.Spec.ImageLookupFormat = amiSpecVar.Lookup.Format
obj.Spec.Template.Spec.ImageLookupOrg = amiSpecVar.Lookup.Org
Expand Down

0 comments on commit f486d5b

Please sign in to comment.