# AddAutoScalingGroupCapacityOptions

The properties for adding an AutoScalingGroup.

Used as argument in: [Cluster.addAsgCapacityProvider](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.Cluster.html#addasgcapacityprovider)

- Source: [`aws-ecs/lib/cluster.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecs/lib/cluster.ts#L1153)
- Type last changed: v2.233.0 · 18 Dec 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_kms as kms } from 'aws-cdk-lib';

declare const key: kms.Key;
const addAutoScalingGroupCapacityOptions: ecs.AddAutoScalingGroupCapacityOptions = {
  machineImageType: ecs.MachineImageType.AMAZON_LINUX_2,
  spotInstanceDraining: false,
  topicEncryptionKey: key,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_kms as kms

# key: kms.Key

add_auto_scaling_group_capacity_options = ecs.AddAutoScalingGroupCapacityOptions(
    machine_image_type=ecs.MachineImageType.AMAZON_LINUX_2,
    spot_instance_draining=False,
    topic_encryption_key=key
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.kms.*;

Key key;

AddAutoScalingGroupCapacityOptions addAutoScalingGroupCapacityOptions = AddAutoScalingGroupCapacityOptions.builder()
        .machineImageType(MachineImageType.AMAZON_LINUX_2)
        .spotInstanceDraining(false)
        .topicEncryptionKey(key)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.KMS;

Key key;

var addAutoScalingGroupCapacityOptions = new AddAutoScalingGroupCapacityOptions {
    MachineImageType = MachineImageType.AMAZON_LINUX_2,
    SpotInstanceDraining = false,
    TopicEncryptionKey = key
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var key Key

addAutoScalingGroupCapacityOptions := &AddAutoScalingGroupCapacityOptions{
	MachineImageType: awscdk.Aws_ecs.MachineImageType_AMAZON_LINUX_2,
	SpotInstanceDraining: jsii.Boolean(false),
	TopicEncryptionKey: key,
}
```

## Properties

- `machineImageType`: [MachineImageType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.MachineImageType.html) — What type of machine image this is.

  **Default:** Automatically determined from `machineImage`, if available, otherwise `MachineImageType.AMAZON_LINUX_2`.

  Depending on the setting, different UserData will automatically be added
  to the `AutoScalingGroup` to configure it properly for use with ECS.

  If you create an `AutoScalingGroup` yourself and are adding it via
  `addAutoScalingGroup()`, you must specify this value. If you are adding an
  `autoScalingGroup` via `addCapacity`, this value will be determined
  from the `machineImage` you pass.

- `spotInstanceDraining`: boolean = false — Specify whether to enable Automated Draining for Spot Instances running Amazon ECS Services.

  For more information, see [Using Spot Instances](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container-instance-spot.html).

- `topicEncryptionKey`: [IKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) — If `AddAutoScalingGroupCapacityOptions.taskDrainTime` is non-zero, then the ECS cluster creates an SNS Topic to as part of a system to drain instances of tasks when the instance is being shut down. If this property is provided, then this key will be used to encrypt the contents of that SNS Topic. See [SNS Data Encryption](https://docs.aws.amazon.com/sns/latest/dg/sns-data-encryption.html) for more information.

  **Default:** The SNS Topic will not be encrypted.
