diff --git a/apis/eks/v1beta1/zz_generated.deepcopy.go b/apis/eks/v1beta1/zz_generated.deepcopy.go index c0e01e1659..3ca07ad0b7 100644 --- a/apis/eks/v1beta1/zz_generated.deepcopy.go +++ b/apis/eks/v1beta1/zz_generated.deepcopy.go @@ -2049,16 +2049,6 @@ func (in *KubernetesNetworkConfigParameters) DeepCopy() *KubernetesNetworkConfig // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LaunchTemplateInitParameters) DeepCopyInto(out *LaunchTemplateInitParameters) { *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.Name != nil { - in, out := &in.Name, &out.Name - *out = new(string) - **out = **in - } if in.Version != nil { in, out := &in.Version, &out.Version *out = new(string) @@ -2114,6 +2104,26 @@ func (in *LaunchTemplateParameters) DeepCopyInto(out *LaunchTemplateParameters) *out = new(string) **out = **in } + if in.LaunchTemplateIDRefs != nil { + in, out := &in.LaunchTemplateIDRefs, &out.LaunchTemplateIDRefs + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.LaunchTemplateIDSelector != nil { + in, out := &in.LaunchTemplateIDSelector, &out.LaunchTemplateIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.LaunchTemplateNameRefs != nil { + in, out := &in.LaunchTemplateNameRefs, &out.LaunchTemplateNameRefs + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.LaunchTemplateNameSelector != nil { + in, out := &in.LaunchTemplateNameSelector, &out.LaunchTemplateNameSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.Name != nil { in, out := &in.Name, &out.Name *out = new(string) diff --git a/apis/eks/v1beta1/zz_generated.resolvers.go b/apis/eks/v1beta1/zz_generated.resolvers.go index baf8bb826f..db3439e226 100644 --- a/apis/eks/v1beta1/zz_generated.resolvers.go +++ b/apis/eks/v1beta1/zz_generated.resolvers.go @@ -257,6 +257,42 @@ func (mg *NodeGroup) ResolveReferences(ctx context.Context, c client.Reader) err mg.Spec.ForProvider.ClusterName = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClusterNameRef = rsp.ResolvedReference + for i3 := 0; i3 < len(mg.Spec.ForProvider.LaunchTemplate); i3++ { + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LaunchTemplate[i3].ID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LaunchTemplate[i3].LaunchTemplateIDRefs, + Selector: mg.Spec.ForProvider.LaunchTemplate[i3].LaunchTemplateIDSelector, + To: reference.To{ + List: &v1beta11.LaunchTemplateList{}, + Managed: &v1beta11.LaunchTemplate{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.LaunchTemplate[i3].ID") + } + mg.Spec.ForProvider.LaunchTemplate[i3].ID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.LaunchTemplate[i3].LaunchTemplateIDRefs = rsp.ResolvedReference + + } + for i3 := 0; i3 < len(mg.Spec.ForProvider.LaunchTemplate); i3++ { + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.LaunchTemplate[i3].Name), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.LaunchTemplate[i3].LaunchTemplateNameRefs, + Selector: mg.Spec.ForProvider.LaunchTemplate[i3].LaunchTemplateNameSelector, + To: reference.To{ + List: &v1beta11.LaunchTemplateList{}, + Managed: &v1beta11.LaunchTemplate{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.LaunchTemplate[i3].Name") + } + mg.Spec.ForProvider.LaunchTemplate[i3].Name = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.LaunchTemplate[i3].LaunchTemplateNameRefs = rsp.ResolvedReference + + } rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.NodeRoleArn), Extract: common.ARNExtractor(), diff --git a/apis/eks/v1beta1/zz_nodegroup_types.go b/apis/eks/v1beta1/zz_nodegroup_types.go index 449f35a392..6da1a03f4b 100755 --- a/apis/eks/v1beta1/zz_nodegroup_types.go +++ b/apis/eks/v1beta1/zz_nodegroup_types.go @@ -27,12 +27,6 @@ type AutoscalingGroupsParameters struct { type LaunchTemplateInitParameters struct { - // Identifier of the EC2 Launch Template. Conflicts with name. - ID *string `json:"id,omitempty" tf:"id,omitempty"` - - // Name of the EC2 Launch Template. Conflicts with id. - Name *string `json:"name,omitempty" tf:"name,omitempty"` - // EC2 Launch Template version number. While the API accepts values like $Default and $Latest, the API will convert the value to the associated version number (e.g., 1). Using the default_version or latest_version attribute of the aws_launch_template resource or data source is recommended for this argument. Version *string `json:"version,omitempty" tf:"version,omitempty"` } @@ -52,10 +46,32 @@ type LaunchTemplateObservation struct { type LaunchTemplateParameters struct { // Identifier of the EC2 Launch Template. Conflicts with name. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/ec2/v1beta1.LaunchTemplate + // +crossplane:generate:reference:refFieldName=LaunchTemplateIDRefs + // +crossplane:generate:reference:selectorFieldName=LaunchTemplateIDSelector // +kubebuilder:validation:Optional ID *string `json:"id,omitempty" tf:"id,omitempty"` + // Reference to a LaunchTemplate in ec2 to populate id. + // +kubebuilder:validation:Optional + LaunchTemplateIDRefs *v1.Reference `json:"launchTemplateIdRefs,omitempty" tf:"-"` + + // Selector for a LaunchTemplate in ec2 to populate id. + // +kubebuilder:validation:Optional + LaunchTemplateIDSelector *v1.Selector `json:"launchTemplateIdSelector,omitempty" tf:"-"` + + // Reference to a LaunchTemplate in ec2 to populate name. + // +kubebuilder:validation:Optional + LaunchTemplateNameRefs *v1.Reference `json:"launchTemplateNameRefs,omitempty" tf:"-"` + + // Selector for a LaunchTemplate in ec2 to populate name. + // +kubebuilder:validation:Optional + LaunchTemplateNameSelector *v1.Selector `json:"launchTemplateNameSelector,omitempty" tf:"-"` + // Name of the EC2 Launch Template. Conflicts with id. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/ec2/v1beta1.LaunchTemplate + // +crossplane:generate:reference:refFieldName=LaunchTemplateNameRefs + // +crossplane:generate:reference:selectorFieldName=LaunchTemplateNameSelector // +kubebuilder:validation:Optional Name *string `json:"name,omitempty" tf:"name,omitempty"` diff --git a/config/eks/config.go b/config/eks/config.go index 6f8b1c2b3d..080adf85e3 100644 --- a/config/eks/config.go +++ b/config/eks/config.go @@ -52,6 +52,16 @@ func Configure(p *config.Provider) { // nolint:gocyclo RefFieldName: "SubnetIDRefs", SelectorFieldName: "SubnetIDSelector", } + r.References["launch_template.id"] = config.Reference{ + Type: "github.com/upbound/provider-aws/apis/ec2/v1beta1.LaunchTemplate", + RefFieldName: "LaunchTemplateIDRefs", + SelectorFieldName: "LaunchTemplateIDSelector", + } + r.References["launch_template.name"] = config.Reference{ + Type: "github.com/upbound/provider-aws/apis/ec2/v1beta1.LaunchTemplate", + RefFieldName: "LaunchTemplateNameRefs", + SelectorFieldName: "LaunchTemplateNameSelector", + } r.UseAsync = true r.MetaResource.ArgumentDocs["launch_template.version"] = `- (Required) EC2 Launch Template version number. While the API accepts values like $Default and $Latest, the API will convert the value to the associated version number (e.g., 1). Using the default_version or latest_version attribute of the aws_launch_template resource or data source is recommended for this argument.` r.MetaResource.ArgumentDocs["subnet_ids"] = `- Identifiers of EC2 Subnets to associate with the EKS Node Group. Amazon EKS managed node groups can be launched in both public and private subnets. If you plan to deploy load balancers to a subnet, the private subnet must have tag kubernetes.io/role/internal-elb, the public subnet must have tag kubernetes.io/role/elb.` diff --git a/package/crds/eks.aws.upbound.io_nodegroups.yaml b/package/crds/eks.aws.upbound.io_nodegroups.yaml index 44c042678b..6454e10045 100644 --- a/package/crds/eks.aws.upbound.io_nodegroups.yaml +++ b/package/crds/eks.aws.upbound.io_nodegroups.yaml @@ -184,6 +184,162 @@ spec: description: Identifier of the EC2 Launch Template. Conflicts with name. type: string + launchTemplateIdRefs: + description: Reference to a LaunchTemplate in ec2 to populate + id. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution + of this reference is required. The default is + 'Required', which means the reconcile will fail + if the reference cannot be resolved. 'Optional' + means this reference will be a no-op if it cannot + be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference + should be resolved. The default is 'IfNotPresent', + which will attempt to resolve the reference only + when the corresponding field is not present. Use + 'Always' to resolve the reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + launchTemplateIdSelector: + description: Selector for a LaunchTemplate in ec2 to populate + id. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with + the same controller reference as the selecting object + is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching + labels is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution + of this reference is required. The default is + 'Required', which means the reconcile will fail + if the reference cannot be resolved. 'Optional' + means this reference will be a no-op if it cannot + be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference + should be resolved. The default is 'IfNotPresent', + which will attempt to resolve the reference only + when the corresponding field is not present. Use + 'Always' to resolve the reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + launchTemplateNameRefs: + description: Reference to a LaunchTemplate in ec2 to populate + name. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution + of this reference is required. The default is + 'Required', which means the reconcile will fail + if the reference cannot be resolved. 'Optional' + means this reference will be a no-op if it cannot + be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference + should be resolved. The default is 'IfNotPresent', + which will attempt to resolve the reference only + when the corresponding field is not present. Use + 'Always' to resolve the reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + launchTemplateNameSelector: + description: Selector for a LaunchTemplate in ec2 to populate + name. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with + the same controller reference as the selecting object + is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching + labels is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution + of this reference is required. The default is + 'Required', which means the reconcile will fail + if the reference cannot be resolved. 'Optional' + means this reference will be a no-op if it cannot + be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference + should be resolved. The default is 'IfNotPresent', + which will attempt to resolve the reference only + when the corresponding field is not present. Use + 'Always' to resolve the reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object name: description: Name of the EC2 Launch Template. Conflicts with id. @@ -658,14 +814,6 @@ spec: Detailed below. items: properties: - id: - description: Identifier of the EC2 Launch Template. Conflicts - with name. - type: string - name: - description: Name of the EC2 Launch Template. Conflicts - with id. - type: string version: description: EC2 Launch Template version number. While the API accepts values like $Default and $Latest, the API