# ScalableTargetProps

Properties for a scalable target.

Used as props by: [ScalableTarget](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_applicationautoscaling.ScalableTarget.html)

- Source: [`aws-applicationautoscaling/lib/scalable-target.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-applicationautoscaling/lib/scalable-target.ts#L30)

## Example

TypeScript:

```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,
});
```

Python:

```python
shards_scalable_target = appscaling.ScalableTarget(self, "ElastiCacheRedisShardsScalableTarget",
    service_namespace=appscaling.ServiceNamespace.ELASTICACHE,
    scalable_dimension="elasticache:replication-group:NodeGroups",
    min_capacity=2,
    max_capacity=10,
    resource_id="replication-group/main-cluster"
)

shards_scalable_target.scale_to_track_metric("ElastiCacheRedisShardsCPUUtilization",
    target_value=20,
    predefined_metric=appscaling.PredefinedMetric.ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION
)
```

Java:

```java
ScalableTarget shardsScalableTarget = ScalableTarget.Builder.create(this, "ElastiCacheRedisShardsScalableTarget")
        .serviceNamespace(ServiceNamespace.ELASTICACHE)
        .scalableDimension("elasticache:replication-group:NodeGroups")
        .minCapacity(2)
        .maxCapacity(10)
        .resourceId("replication-group/main-cluster")
        .build();

shardsScalableTarget.scaleToTrackMetric("ElastiCacheRedisShardsCPUUtilization", BasicTargetTrackingScalingPolicyProps.builder()
        .targetValue(20)
        .predefinedMetric(PredefinedMetric.ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var shardsScalableTarget = new ScalableTarget(this, "ElastiCacheRedisShardsScalableTarget", new ScalableTargetProps {
    ServiceNamespace = ServiceNamespace.ELASTICACHE,
    ScalableDimension = "elasticache:replication-group:NodeGroups",
    MinCapacity = 2,
    MaxCapacity = 10,
    ResourceId = "replication-group/main-cluster"
});

shardsScalableTarget.ScaleToTrackMetric("ElastiCacheRedisShardsCPUUtilization", new BasicTargetTrackingScalingPolicyProps {
    TargetValue = 20,
    PredefinedMetric = PredefinedMetric.ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
shardsScalableTarget := appscaling.NewScalableTarget(this, jsii.String("ElastiCacheRedisShardsScalableTarget"), &ScalableTargetProps{
	ServiceNamespace: appscaling.ServiceNamespace_ELASTICACHE,
	ScalableDimension: jsii.String("elasticache:replication-group:NodeGroups"),
	MinCapacity: jsii.Number(2),
	MaxCapacity: jsii.Number(10),
	ResourceId: jsii.String("replication-group/main-cluster"),
})

shardsScalableTarget.ScaleToTrackMetric(jsii.String("ElastiCacheRedisShardsCPUUtilization"), &BasicTargetTrackingScalingPolicyProps{
	TargetValue: jsii.Number(20),
	PredefinedMetric: appscaling.PredefinedMetric_ELASTICACHE_PRIMARY_ENGINE_CPU_UTILIZATION,
})
```

## Properties

- `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](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — Role that allows Application Auto Scaling to modify your scalable target.

  **Default:** A role is automatically created

- `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](https://docs.aws.amazon.com/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.
