# Nodegroup

The Nodegroup resource class.

Extends: Construct › Resource › Nodegroup
Implements: IResource, INodegroup, IEnvironmentAware, INodegroupRef, IConstruct, IDependable

- CloudFormation: [`AWS::EKS::Nodegroup`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-eks-nodegroup.html)
- L1 type: [`CfnNodegroup`](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.CfnNodegroup.html)
- Source: [`aws-eks/lib/managed-nodegroup.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts#L411)
- Type last changed: v2.236.0 · 23 Jan 2026

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_eks as eks } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';

declare const cluster: eks.Cluster;
declare const instanceType: ec2.InstanceType;
declare const role: iam.Role;
declare const securityGroup: ec2.SecurityGroup;
declare const subnet: ec2.Subnet;
declare const subnetFilter: ec2.SubnetFilter;
const nodegroup = new eks.Nodegroup(this, 'MyNodegroup', {
  cluster: cluster,

  // the properties below are optional
  amiType: eks.NodegroupAmiType.AL2_X86_64,
  capacityType: eks.CapacityType.SPOT,
  desiredSize: 123,
  diskSize: 123,
  enableNodeAutoRepair: false,
  forceUpdate: false,
  instanceTypes: [instanceType],
  labels: {
    labelsKey: 'labels',
  },
  launchTemplateSpec: {
    id: 'id',

    // the properties below are optional
    version: 'version',
  },
  maxSize: 123,
  maxUnavailable: 123,
  maxUnavailablePercentage: 123,
  minSize: 123,
  nodegroupName: 'nodegroupName',
  nodeRole: role,
  releaseVersion: 'releaseVersion',
  remoteAccess: {
    sshKeyName: 'sshKeyName',

    // the properties below are optional
    sourceSecurityGroups: [securityGroup],
  },
  removalPolicy: cdk.RemovalPolicy.DESTROY,
  subnets: {
    availabilityZones: ['availabilityZones'],
    onePerAz: false,
    subnetFilters: [subnetFilter],
    subnetGroupName: 'subnetGroupName',
    subnets: [subnet],
    subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
  },
  tags: {
    tagsKey: 'tags',
  },
  taints: [{
    effect: eks.TaintEffect.NO_SCHEDULE,
    key: 'key',
    value: 'value',
  }],
});
```

## Initializer

```ts
new Nodegroup(scope: Construct, id: string, props: NodegroupProps)
```

## Construct Props

- `amiType`: [NodegroupAmiType](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.NodegroupAmiType.html) — The AMI type for your node group.

  **Default:** auto-determined from the instanceTypes property when launchTemplateSpec property is not specified

  If you explicitly specify the launchTemplate with custom AMI, do not specify this property, or
  the node group deployment will fail. In other cases, you will need to specify correct amiType for the nodegroup.

- `capacityType`: [CapacityType](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.CapacityType.html) = ON_DEMAND — The capacity type of the nodegroup.

- `cluster`: [ICluster](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.ICluster.html) (required) — Cluster resource.

- `desiredSize`: number = 2 — The current number of worker nodes that the managed node group should maintain.

  If not specified,
  the nodewgroup will initially create `minSize` instances.

- `diskSize`: number = 20 — The root device disk size (in GiB) for your node group instances.

- `enableNodeAutoRepair`: boolean = disabled — Specifies whether to enable node auto repair for the node group.

  Node auto repair is disabled by default.

- `forceUpdate`: boolean = true — Force the update if the existing node group's pods are unable to be drained due to a pod disruption budget issue.

  If an update fails because pods could not be drained, you can force the update after it fails to terminate the old
  node whether or not any pods are
  running on the node.

- `instanceTypes`: [InstanceType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html)[] — The instance types to use for your node group.

  **Default:** t3.medium will be used according to the cloudformation document.

- `labels`: { [key: string]: string } = None — The Kubernetes labels to be applied to the nodes in the node group when they are created.

- `launchTemplateSpec`: [LaunchTemplateSpec](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.LaunchTemplateSpec.html) — Launch template specification used for the nodegroup.

  **Default:** no launch template

- `maxSize`: number = desiredSize — The maximum number of worker nodes that the managed node group can scale out to.

  Managed node groups can support up to 100 nodes by default.

- `maxUnavailable`: number = 1 — The maximum number of nodes unavailable at once during a version update.

  Nodes will be updated in parallel. The maximum number is 100.

  This value or `maxUnavailablePercentage` is required to have a value for custom update configurations to be applied.

- `maxUnavailablePercentage`: number — The maximum percentage of nodes unavailable during a version update.

  **Default:** undefined - node groups will update instances one at a time

  This percentage of nodes will be updated in parallel, up to 100 nodes at once.

  This value or `maxUnavailable` is required to have a value for custom update configurations to be applied.

- `minSize`: number = 1 — The minimum number of worker nodes that the managed node group can scale in to.

  This number must be greater than or equal to zero.

- `nodegroupName`: string — Name of the Nodegroup.

  **Default:** resource ID

- `nodeRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM role to associate with your node group.

  **Default:** None. Auto-generated if not specified.

  The Amazon EKS worker node kubelet daemon
  makes calls to AWS APIs on your behalf. Worker nodes receive permissions for these API calls through
  an IAM instance profile and associated policies. Before you can launch worker nodes and register them
  into a cluster, you must create an IAM role for those worker nodes to use when they are launched.

- `releaseVersion`: string — The AMI version of the Amazon EKS-optimized AMI to use with your node group (for example, `1.14.7-YYYYMMDD`).

  **Default:** The latest available AMI version for the node group's current Kubernetes version is used.

- `remoteAccess`: [NodegroupRemoteAccess](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.NodegroupRemoteAccess.html) = disabled — The remote access (SSH) configuration to use with your node group.

  Disabled by default, however, if you
  specify an Amazon EC2 SSH key but do not specify a source security group when you create a managed node group,
  then port 22 on the worker nodes is opened to the internet (0.0.0.0/0)

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.DESTROY — The removal policy applied to the managed node group.

  The removal policy controls what happens to the resource if it stops being managed by CloudFormation.
  This can happen in one of three situations:

  - The resource is removed from the template, so CloudFormation stops managing it
  - A change to the resource is made that requires it to be replaced, so CloudFormation stops managing it
  - The stack is deleted, so CloudFormation stops managing all resources in it

- `subnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — The subnets to use for the Auto Scaling group that is created for your node group.

  **Default:** private subnets

  By specifying the
  SubnetSelection, the selected subnets will automatically apply required tags i.e.
  `kubernetes.io/cluster/CLUSTER_NAME` with a value of `shared`, where `CLUSTER_NAME` is replaced with
  the name of your cluster.

- `tags`: { [key: string]: string } = None — The metadata to apply to the node group to assist with categorization and organization.

  Each tag consists of
  a key and an optional value, both of which you define. Node group tags do not propagate to any other resources
  associated with the node group, such as the Amazon EC2 instances or subnets.

- `taints`: [TaintSpec](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.TaintSpec.html)[] = None — The Kubernetes taints to be applied to the nodes in the node group when they are created.

## Properties

- `cluster`: [ICluster](/cdk/api/v2/docs/aws-cdk-lib.aws_eks.ICluster.html) (required) — the Amazon EKS cluster resource.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `nodegroupArn`: string (required) — ARN of the nodegroup.

- `nodegroupName`: string (required) — Name of the nodegroup.

- `nodegroupRef`: [NodegroupReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_eks.NodegroupReference.html) (required) — A reference to a Nodegroup resource.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) (required) — IAM role of the instance profile for the nodegroup.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromNodegroupName(scope: Construct, id: string, nodegroupName: string): INodegroup` (static) — Import the Nodegroup from attributes.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
