# ServiceNamespace

The service that supports Application AutoScaling.

- 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#L326)
- Type last changed: v2.182.0 · 5 Mar 2025

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

## Members

| Member | Description |
| --- | --- |
| `ECS` | Elastic Container Service. |
| `ELASTIC_MAP_REDUCE` | Elastic Map Reduce. |
| `EC2` | Elastic Compute Cloud. |
| `APPSTREAM` | App Stream. |
| `DYNAMODB` | Dynamo DB. |
| `RDS` | Relational Database Service. |
| `SAGEMAKER` | SageMaker. |
| `CUSTOM_RESOURCE` | Custom Resource. |
| `LAMBDA` | Lambda. |
| `COMPREHEND` | Comprehend. |
| `KAFKA` | Kafka. |
| `ELASTICACHE` | ElastiCache. |
| `NEPTUNE` | Neptune. |
| `CASSANDRA` | Cassandra. |
| `WORKSPACES` | Workspaces. |

## Referenced by

- [`BaseScalableAttributeProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_applicationautoscaling.BaseScalableAttributeProps.html).serviceNamespace
- [`ScalableTargetProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_applicationautoscaling.ScalableTargetProps.html).serviceNamespace
