# CapacityType

Capacity type of the managed node group.

- Source: [`aws-eks/lib/managed-nodegroup.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts#L118)
- Type last changed: v2.185.0 · 19 Mar 2025

## Example

TypeScript:

```ts
declare const cluster: eks.Cluster;
cluster.addNodegroupCapacity('extra-ng-spot', {
  instanceTypes: [
    new ec2.InstanceType('c5.large'),
    new ec2.InstanceType('c5a.large'),
    new ec2.InstanceType('c5d.large'),
  ],
  minSize: 3,
  capacityType: eks.CapacityType.SPOT,
});
```

Python:

```python
# cluster: eks.Cluster

cluster.add_nodegroup_capacity("extra-ng-spot",
    instance_types=[
        ec2.InstanceType("c5.large"),
        ec2.InstanceType("c5a.large"),
        ec2.InstanceType("c5d.large")
    ],
    min_size=3,
    capacity_type=eks.CapacityType.SPOT
)
```

Java:

```java
Cluster cluster;

cluster.addNodegroupCapacity("extra-ng-spot", NodegroupOptions.builder()
        .instanceTypes(List.of(
            new InstanceType("c5.large"),
            new InstanceType("c5a.large"),
            new InstanceType("c5d.large")))
        .minSize(3)
        .capacityType(CapacityType.SPOT)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;

cluster.AddNodegroupCapacity("extra-ng-spot", new NodegroupOptions {
    InstanceTypes = new [] {
        new InstanceType("c5.large"),
        new InstanceType("c5a.large"),
        new InstanceType("c5d.large") },
    MinSize = 3,
    CapacityType = CapacityType.SPOT
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster

cluster.AddNodegroupCapacity(jsii.String("extra-ng-spot"), &NodegroupOptions{
	InstanceTypes: []InstanceType{
		ec2.NewInstanceType(jsii.String("c5.large")),
		ec2.NewInstanceType(jsii.String("c5a.large")),
		ec2.NewInstanceType(jsii.String("c5d.large")),
	},
	MinSize: jsii.Number(3),
	CapacityType: eks.CapacityType_SPOT,
})
```

## Members

| Member | Description |
| --- | --- |
| `SPOT` | spot instances. |
| `ON_DEMAND` | on-demand instances. |
| `CAPACITY_BLOCK` | capacity block instances. |

## Referenced by

- [`NodegroupOptions`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks.NodegroupOptions.html).capacityType
