# ScalableTarget

Define a scalable target.

Extends: Construct › Resource › ScalableTarget
Implements: IResource, IScalableTarget, IEnvironmentAware, IScalableTargetRef, IConstruct, IDependable

- CloudFormation: [`AWS::ApplicationAutoScaling::ScalableTarget`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-applicationautoscaling-scalabletarget.html)
- L1 type: [`CfnScalableTarget`](/cdk/api/v2/docs/aws-cdk-lib.aws_applicationautoscaling.CfnScalableTarget.html)
- Source: [`aws-applicationautoscaling/lib/scalable-target.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-applicationautoscaling/lib/scalable-target.ts#L105)
- Type last changed: v2.234.0 · 8 Jan 2026

## Example

```ts
const shardsScalableTarget = new appscaling.ScalableTarget(this, 'ElastiCacheRedisShardsScalableTarget', {
  serviceNamespace: appscaling.ServiceNamespace.ELASTICACHE,
  scalableDimension: 'elasticache:replication-group:NodeGroups',
  minCapacity: 2,
  maxCapacity: 10,
  resourceId: 'replication-group/main-cluster',
});

shardsScalableTarget.scaleToTrackMetric('ElastiCacheRedisShardsCPUUtilization', {
  targetValue: 20,
  predefinedMetric: appscaling.PredefinedMetric.ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION,
});
```

## Initializer

```ts
new ScalableTarget(scope: Construct, id: string, props: ScalableTargetProps)
```

## Construct Props

- `maxCapacity`: number (required) — The maximum value that Application Auto Scaling can use to scale a target during a scaling activity.

- `minCapacity`: number (required) — The minimum value that Application Auto Scaling can use to scale a target during a scaling activity.

- `resourceId`: string (required) — The resource identifier to associate with this scalable target.

  This string consists of the resource type and unique identifier.

  Example value: `service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH`

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) = A role is automatically created — Role that allows Application Auto Scaling to modify your scalable target.

- `scalableDimension`: string (required) — The scalable dimension that's associated with the scalable target.

  Specify the service namespace, resource type, and scaling property.

  Example value: `ecs:service:DesiredCount`

- `serviceNamespace`: [ServiceNamespace](/cdk/api/v2/docs/aws-cdk-lib.aws_applicationautoscaling.ServiceNamespace.html) (required) — The namespace of the AWS service that provides the resource or custom-resource for a resource provided by your own application or service.

  For valid AWS service namespace values, see the RegisterScalableTarget
  action in the Application Auto Scaling API Reference.

## Properties

- `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.

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

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) (required) — The role used to give AutoScaling permissions to your resource.

- `scalableTargetId`: string (required) — ID of the Scalable Target.

  Example value: `service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH|ecs:service:DesiredCount|ecs`

- `scalableTargetRef`: [ScalableTargetReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_applicationautoscaling.ScalableTargetReference.html) (required) — A reference to a ScalableTarget resource.

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

## Methods

- `addToRolePolicy(statement: PolicyStatement): void` — Add a policy statement to the role's policy.

- `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`).

- `fromScalableTargetAttributes(scope: Construct, id: string, attrs: ScalableTargetAttributes): IScalableTarget` (static) — Create a referenceable `IScalableTarget` object based on properties of a resource that already exists in your account.

- `fromScalableTargetId(scope: Construct, id: string, scalableTargetId: string): IScalableTarget` (static) — Create a referenceable `IScalableTarget` object based on properties of a resource that already exists in your account.

- `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.

- `scaleOnMetric(id: string, props: BasicStepScalingPolicyProps): StepScalingPolicy` — Scale out or in, in response to a metric.

- `scaleOnSchedule(id: string, action: ScalingSchedule): void` — Scale out or in based on time.

- `scaleToTrackMetric(id: string, props: BasicTargetTrackingScalingPolicyProps): TargetTrackingScalingPolicy` — Scale out or in in order to keep a metric around a target value.

- `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.
