diff --git a/CHANGELOG.md b/CHANGELOG.md index 14af60a6..eb549762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased - [Add support for non-default AWS partitions #788](https://github.com/pulumi/pulumi-eks/pull/788) +- [Add support for launchTemplateTagSpecifications within NodeGroupV2 #810](https://github.com/pulumi/pulumi-eks/pull/810) ## 0.42.2 (Released Oct 12, 2022) - Fix internal registration of NodeGroupV2 resource. diff --git a/examples/nodegroup/index.ts b/examples/nodegroup/index.ts index a8ac5523..3a09f6ab 100644 --- a/examples/nodegroup/index.ts +++ b/examples/nodegroup/index.ts @@ -71,6 +71,30 @@ const spot = new eks.NodeGroup("example-ng-simple-spot", { providers: { kubernetes: cluster1.provider}, }); +const withLaunchTemplateTagSpecifications = new eks.NodeGroupV2("example-ng2-launchtemplate-tags", { + cluster: cluster1, + instanceType: "t2.medium", + desiredCapacity: 1, + minSize: 1, + maxSize: 2, + labels: { "ondemand": "true" }, + instanceProfile: instanceProfile0, + launchTemplateTagSpecifications: [ + { + resourceType: "instance", + tags: { + "foo": "bar", + }, + }, + { + resourceType: "volume", + tags: { + "foo2": "bar2", + }, + }, + ], +}); + // Export the cluster's kubeconfig. export const kubeconfig1 = cluster1.kubeconfig; diff --git a/nodejs/eks/nodegroup.ts b/nodejs/eks/nodegroup.ts index 1f04b854..75140537 100644 --- a/nodejs/eks/nodegroup.ts +++ b/nodejs/eks/nodegroup.ts @@ -311,7 +311,9 @@ export interface NodeGroupV2Options extends NodeGroupOptions { * * Defaults to 50. */ - minRefreshPercentage?: number; + minRefreshPercentage?: number; + + launchTemplateTagSpecifications?: awsInputs.ec2.LaunchTemplateTagSpecification[]; } /** @@ -416,7 +418,7 @@ export class NodeGroupV2 extends pulumi.ComponentResource implements NodeGroupV2 * @param args The arguments for this cluster. * @param opts A bag of options that control this component's behavior. */ - constructor(name: string, args: NodeGroupOptions, opts?: pulumi.ComponentResourceOptions) { + constructor(name: string, args: NodeGroupV2Options, opts?: pulumi.ComponentResourceOptions) { super("eks:index:NodeGroupV2", name, args, opts); const group = createNodeGroupV2(name, args, this, opts?.provider); @@ -938,6 +940,7 @@ ${customUserData} securityGroups: [nodeSecurityGroupId, ...extraNodeSecurityGroupIds], }], userData: userdata, + tagSpecifications: args.launchTemplateTagSpecifications, }, { parent, provider}); // Compute the worker node group subnets to use from the various approaches. diff --git a/provider/cmd/pulumi-gen-eks/main.go b/provider/cmd/pulumi-gen-eks/main.go index e26c451f..2ec6fc0c 100644 --- a/provider/cmd/pulumi-gen-eks/main.go +++ b/provider/cmd/pulumi-gen-eks/main.go @@ -1540,6 +1540,14 @@ func nodeGroupProperties(cluster, v2 bool) map[string]schema.PropertySpec { TypeSpec: schema.TypeSpec{Type: "integer"}, Description: "The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50.", } + + props["launchTemplateTagSpecifications"] = schema.PropertySpec{ + TypeSpec: schema.TypeSpec{ + Type: "array", + Items: &schema.TypeSpec{Ref: awsRef("#/types/aws:ec2%2FLaunchTemplateTagSpecification:LaunchTemplateTagSpecification")}, + }, + Description: "The tag specifications to apply to the launch template.", + } } return props diff --git a/provider/cmd/pulumi-resource-eks/schema.json b/provider/cmd/pulumi-resource-eks/schema.json index 55c35149..c4d1273d 100644 --- a/provider/cmd/pulumi-resource-eks/schema.json +++ b/provider/cmd/pulumi-resource-eks/schema.json @@ -1326,6 +1326,13 @@ }, "description": "Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument." }, + "launchTemplateTagSpecifications": { + "type": "array", + "items": { + "$ref": "/aws/v5.4.0/schema.json#/types/aws:ec2%2FLaunchTemplateTagSpecification:LaunchTemplateTagSpecification" + }, + "description": "The tag specifications to apply to the launch template." + }, "maxSize": { "type": "integer", "description": "The maximum number of worker nodes running in the cluster. Defaults to 2." diff --git a/sdk/dotnet/NodeGroupV2.cs b/sdk/dotnet/NodeGroupV2.cs index 27e8daa9..6b311ef7 100644 --- a/sdk/dotnet/NodeGroupV2.cs +++ b/sdk/dotnet/NodeGroupV2.cs @@ -208,6 +208,18 @@ public InputMap Labels set => _labels = value; } + [Input("launchTemplateTagSpecifications")] + private InputList? _launchTemplateTagSpecifications; + + /// + /// The tag specifications to apply to the launch template. + /// + public InputList LaunchTemplateTagSpecifications + { + get => _launchTemplateTagSpecifications ?? (_launchTemplateTagSpecifications = new InputList()); + set => _launchTemplateTagSpecifications = value; + } + /// /// The maximum number of worker nodes running in the cluster. Defaults to 2. /// diff --git a/sdk/go/eks/nodeGroupV2.go b/sdk/go/eks/nodeGroupV2.go index 7ce62b43..217f0935 100644 --- a/sdk/go/eks/nodeGroupV2.go +++ b/sdk/go/eks/nodeGroupV2.go @@ -104,6 +104,8 @@ type nodeGroupV2Args struct { KubeletExtraArgs *string `pulumi:"kubeletExtraArgs"` // Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument. Labels map[string]string `pulumi:"labels"` + // The tag specifications to apply to the launch template. + LaunchTemplateTagSpecifications []ec2.LaunchTemplateTagSpecification `pulumi:"launchTemplateTagSpecifications"` // The maximum number of worker nodes running in the cluster. Defaults to 2. MaxSize *int `pulumi:"maxSize"` // The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50. @@ -206,6 +208,8 @@ type NodeGroupV2Args struct { KubeletExtraArgs pulumi.StringPtrInput // Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument. Labels pulumi.StringMapInput + // The tag specifications to apply to the launch template. + LaunchTemplateTagSpecifications ec2.LaunchTemplateTagSpecificationArrayInput // The maximum number of worker nodes running in the cluster. Defaults to 2. MaxSize pulumi.IntPtrInput // The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50. diff --git a/sdk/java/src/main/java/com/pulumi/eks/NodeGroupV2Args.java b/sdk/java/src/main/java/com/pulumi/eks/NodeGroupV2Args.java index b19c9336..6aef2831 100644 --- a/sdk/java/src/main/java/com/pulumi/eks/NodeGroupV2Args.java +++ b/sdk/java/src/main/java/com/pulumi/eks/NodeGroupV2Args.java @@ -5,6 +5,7 @@ import com.pulumi.aws.ec2.SecurityGroup; import com.pulumi.aws.ec2.SecurityGroupRule; +import com.pulumi.aws.ec2.inputs.LaunchTemplateTagSpecificationArgs; import com.pulumi.aws.iam.InstanceProfile; import com.pulumi.core.Output; import com.pulumi.core.annotations.Import; @@ -318,6 +319,21 @@ public Optional>> labels() { return Optional.ofNullable(this.labels); } + /** + * The tag specifications to apply to the launch template. + * + */ + @Import(name="launchTemplateTagSpecifications") + private @Nullable Output> launchTemplateTagSpecifications; + + /** + * @return The tag specifications to apply to the launch template. + * + */ + public Optional>> launchTemplateTagSpecifications() { + return Optional.ofNullable(this.launchTemplateTagSpecifications); + } + /** * The maximum number of worker nodes running in the cluster. Defaults to 2. * @@ -558,6 +574,7 @@ private NodeGroupV2Args(NodeGroupV2Args $) { this.keyName = $.keyName; this.kubeletExtraArgs = $.kubeletExtraArgs; this.labels = $.labels; + this.launchTemplateTagSpecifications = $.launchTemplateTagSpecifications; this.maxSize = $.maxSize; this.minRefreshPercentage = $.minRefreshPercentage; this.minSize = $.minSize; @@ -993,6 +1010,37 @@ public Builder labels(Map labels) { return labels(Output.of(labels)); } + /** + * @param launchTemplateTagSpecifications The tag specifications to apply to the launch template. + * + * @return builder + * + */ + public Builder launchTemplateTagSpecifications(@Nullable Output> launchTemplateTagSpecifications) { + $.launchTemplateTagSpecifications = launchTemplateTagSpecifications; + return this; + } + + /** + * @param launchTemplateTagSpecifications The tag specifications to apply to the launch template. + * + * @return builder + * + */ + public Builder launchTemplateTagSpecifications(List launchTemplateTagSpecifications) { + return launchTemplateTagSpecifications(Output.of(launchTemplateTagSpecifications)); + } + + /** + * @param launchTemplateTagSpecifications The tag specifications to apply to the launch template. + * + * @return builder + * + */ + public Builder launchTemplateTagSpecifications(LaunchTemplateTagSpecificationArgs... launchTemplateTagSpecifications) { + return launchTemplateTagSpecifications(List.of(launchTemplateTagSpecifications)); + } + /** * @param maxSize The maximum number of worker nodes running in the cluster. Defaults to 2. * diff --git a/sdk/python/pulumi_eks/node_group_v2.py b/sdk/python/pulumi_eks/node_group_v2.py index 346fd8ab..303d5b2f 100644 --- a/sdk/python/pulumi_eks/node_group_v2.py +++ b/sdk/python/pulumi_eks/node_group_v2.py @@ -33,6 +33,7 @@ def __init__(__self__, *, key_name: Optional[pulumi.Input[str]] = None, kubelet_extra_args: Optional[pulumi.Input[str]] = None, labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None, + launch_template_tag_specifications: Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]] = None, max_size: Optional[pulumi.Input[int]] = None, min_refresh_percentage: Optional[pulumi.Input[int]] = None, min_size: Optional[pulumi.Input[int]] = None, @@ -91,6 +92,7 @@ def __init__(__self__, *, :param pulumi.Input[str] key_name: Name of the key pair to use for SSH access to worker nodes. :param pulumi.Input[str] kubelet_extra_args: Extra args to pass to the Kubelet. Corresponds to the options passed in the `--kubeletExtraArgs` flag to `/etc/eks/bootstrap.sh`. For example, '--port=10251 --address=0.0.0.0'. Note that the `labels` and `taints` properties will be applied to this list (using `--node-labels` and `--register-with-taints` respectively) after to the explicit `kubeletExtraArgs`. :param pulumi.Input[Mapping[str, pulumi.Input[str]]] labels: Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument. + :param pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]] launch_template_tag_specifications: The tag specifications to apply to the launch template. :param pulumi.Input[int] max_size: The maximum number of worker nodes running in the cluster. Defaults to 2. :param pulumi.Input[int] min_refresh_percentage: The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50. :param pulumi.Input[int] min_size: The minimum number of worker nodes running in the cluster. Defaults to 1. @@ -149,6 +151,8 @@ def __init__(__self__, *, pulumi.set(__self__, "kubelet_extra_args", kubelet_extra_args) if labels is not None: pulumi.set(__self__, "labels", labels) + if launch_template_tag_specifications is not None: + pulumi.set(__self__, "launch_template_tag_specifications", launch_template_tag_specifications) if max_size is not None: pulumi.set(__self__, "max_size", max_size) if min_refresh_percentage is not None: @@ -395,6 +399,18 @@ def labels(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]: def labels(self, value: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]): pulumi.set(self, "labels", value) + @property + @pulumi.getter(name="launchTemplateTagSpecifications") + def launch_template_tag_specifications(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]: + """ + The tag specifications to apply to the launch template. + """ + return pulumi.get(self, "launch_template_tag_specifications") + + @launch_template_tag_specifications.setter + def launch_template_tag_specifications(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]): + pulumi.set(self, "launch_template_tag_specifications", value) + @property @pulumi.getter(name="maxSize") def max_size(self) -> Optional[pulumi.Input[int]]: @@ -586,6 +602,7 @@ def __init__(__self__, key_name: Optional[pulumi.Input[str]] = None, kubelet_extra_args: Optional[pulumi.Input[str]] = None, labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None, + launch_template_tag_specifications: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]] = None, max_size: Optional[pulumi.Input[int]] = None, min_refresh_percentage: Optional[pulumi.Input[int]] = None, min_size: Optional[pulumi.Input[int]] = None, @@ -648,6 +665,7 @@ def __init__(__self__, :param pulumi.Input[str] key_name: Name of the key pair to use for SSH access to worker nodes. :param pulumi.Input[str] kubelet_extra_args: Extra args to pass to the Kubelet. Corresponds to the options passed in the `--kubeletExtraArgs` flag to `/etc/eks/bootstrap.sh`. For example, '--port=10251 --address=0.0.0.0'. Note that the `labels` and `taints` properties will be applied to this list (using `--node-labels` and `--register-with-taints` respectively) after to the explicit `kubeletExtraArgs`. :param pulumi.Input[Mapping[str, pulumi.Input[str]]] labels: Custom k8s node labels to be attached to each worker node. Adds the given key/value pairs to the `--node-labels` kubelet argument. + :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]] launch_template_tag_specifications: The tag specifications to apply to the launch template. :param pulumi.Input[int] max_size: The maximum number of worker nodes running in the cluster. Defaults to 2. :param pulumi.Input[int] min_refresh_percentage: The minimum amount of instances that should remain available during an instance refresh, expressed as a percentage. Defaults to 50. :param pulumi.Input[int] min_size: The minimum number of worker nodes running in the cluster. Defaults to 1. @@ -715,6 +733,7 @@ def _internal_init(__self__, key_name: Optional[pulumi.Input[str]] = None, kubelet_extra_args: Optional[pulumi.Input[str]] = None, labels: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None, + launch_template_tag_specifications: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['pulumi_aws.ec2.LaunchTemplateTagSpecificationArgs']]]]] = None, max_size: Optional[pulumi.Input[int]] = None, min_refresh_percentage: Optional[pulumi.Input[int]] = None, min_size: Optional[pulumi.Input[int]] = None, @@ -760,6 +779,7 @@ def _internal_init(__self__, __props__.__dict__["key_name"] = key_name __props__.__dict__["kubelet_extra_args"] = kubelet_extra_args __props__.__dict__["labels"] = labels + __props__.__dict__["launch_template_tag_specifications"] = launch_template_tag_specifications __props__.__dict__["max_size"] = max_size __props__.__dict__["min_refresh_percentage"] = min_refresh_percentage __props__.__dict__["min_size"] = min_size