Provides an Application AutoScaling ScalableTarget resource. To manage policies which get attached to the target, see the aws_appautoscaling_policy
resource.
resource "aws_appautoscaling_target" "dynamodb_table_read_target" {
max_capacity = 100
min_capacity = 5
resource_id = "table/${aws_dynamodb_table.example.name}"
scalable_dimension = "dynamodb:table:ReadCapacityUnits"
service_namespace = "dynamodb"
}
resource "aws_appautoscaling_target" "dynamodb_index_read_target" {
max_capacity = 100
min_capacity = 5
resource_id = "table/${aws_dynamodb_table.example.name}/index/${var.index_name}"
scalable_dimension = "dynamodb:index:ReadCapacityUnits"
service_namespace = "dynamodb"
}
resource "aws_appautoscaling_target" "ecs_target" {
max_capacity = 4
min_capacity = 1
resource_id = "service/${aws_ecs_cluster.example.name}/${aws_ecs_service.example.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
}
resource "aws_appautoscaling_target" "replicas" {
service_namespace = "rds"
scalable_dimension = "rds:cluster:ReadReplicaCount"
resource_id = "cluster:${aws_rds_cluster.example.id}"
min_capacity = 1
max_capacity = 15
}
tags_all
Differences For Older Resourcesresource "aws_appautoscaling_target" "ecs_target" {
max_capacity = 4
min_capacity = 1
resource_id = "service/${aws_ecs_cluster.example.name}/${aws_ecs_service.example.name}"
scalable_dimension = "ecs:service:DesiredCount"
service_namespace = "ecs"
lifecycle {
ignore_changes = [
tags_all,
]
}
}
This resource supports the following arguments:
max_capacity
- (Required) Max capacity of the scalable target.min_capacity
- (Required) Min capacity of the scalable target.resource_id
- (Required) Resource type and unique identifier string for the resource associated with the scaling policy. Documentation can be found in the ResourceId
parameter at: AWS Application Auto Scaling API Referencerole_arn
- (Optional) ARN of the IAM role that allows Application AutoScaling to modify your scalable target on your behalf. This defaults to an IAM Service-Linked Role for most services and custom IAM Roles are ignored by the API for those namespaces. See the AWS Application Auto Scaling documentation for more information about how this service interacts with IAM.scalable_dimension
- (Required) Scalable dimension of the scalable target. Documentation can be found in the ScalableDimension
parameter at: AWS Application Auto Scaling API Referenceservice_namespace
- (Required) AWS service namespace of the scalable target. Documentation can be found in the ServiceNamespace
parameter at: AWS Application Auto Scaling API Referencetags
- (Optional) Map of tags to assign to the scalable target. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.This resource exports the following attributes in addition to the arguments above:
arn
- The ARN of the scalable target.tags_all
- Map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.In Terraform v1.5.0 and later, use an import
block to import Application AutoScaling Target using the service-namespace
, resource-id
and scalable-dimension
separated by /
. For example:
import {
to = aws_appautoscaling_target.test-target
id = "service-namespace/resource-id/scalable-dimension"
}
Using terraform import
, import Application AutoScaling Target using the service-namespace
, resource-id
and scalable-dimension
separated by /
. For example:
% terraform import aws_appautoscaling_target.test-target service-namespace/resource-id/scalable-dimension