provider-aws icon indicating copy to clipboard operation
provider-aws copied to clipboard

ec2-instance: imageId and launchtemplateId required even if launchtemplateName set

Open BronzeDeer opened this issue 2 years ago • 1 comments

I am trying to spawn an Instance using a LaunchTemplate which has imageId set. I have set launchTemplate.launchTemplateName to reference said template. I expect that I only need to set imageId on the Instance CRD if I want to override the value from the launchTemplate. Furthermore, based on the documentation, I expect that I must not also set launchTemplate.launchTemplateId since I have already set launchTemplateName

What happened?

When trying to create the Instance Resource, I get two validation Errors, telling me that both Instance.spec.forProvider.imageId and Instance.spec.forProvider.launchTemplate.launchTemplateId are required fields

How can we reproduce it?

The crd has the fields set as required (here, and here)

What environment did it happen in?

Crossplane version:

  • aws-provider v0.24.1

BronzeDeer avatar Mar 08 '22 11:03 BronzeDeer

I ran into this issue too. Here is the workaround I found and it works well for me:

  1. Manually edit the instance CRD and remove imageId and launchTemplateName from required section.
$ kubectl edit crd instances.ec2.aws.crossplane.io
...
 623                   launchTemplate:
 624                     description: The launch template to use to launch the instances.
 625                       Any parameters that you specify in RunInstances override the
 626                       same parameters in the launch template. You can specify either
 627                       the name or ID of a launch template, but not both.
 628                     properties:
 629                       launchTemplateId:
 630                         description: The ID of the launch template.
 631                         type: string
 632                       launchTemplateName:
 633                         description: The name of the launch template.
 634                         type: string
 635                       version:
 636                         description: "The version number of the launch template. \n
 637                           Default: The default version for the launch template."
 638                         type: string
 639                     required:
 640                     - launchTemplateId
-641                     - launchTemplateName
  1. Re-apply the xr/xrc.

andrewli96 avatar Aug 01 '22 10:08 andrewli96

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

github-actions[bot] avatar Sep 07 '23 01:09 github-actions[bot]

This is still relevant and doesn't allow proper usage of Launch templates.

DenisBaginsky avatar May 17 '24 15:05 DenisBaginsky

/fresh

DenisBaginsky avatar May 17 '24 15:05 DenisBaginsky

/open

DenisBaginsky avatar May 17 '24 15:05 DenisBaginsky