Skip to content

Resource: awsAppautoscalingScheduledAction

Provides an Application AutoScaling ScheduledAction resource.

Example Usage

DynamoDB Table Autoscaling

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsAppautoscalingTargetDynamodb =
  new aws.appautoscalingTarget.AppautoscalingTarget(this, "dynamodb", {
    maxCapacity: 100,
    minCapacity: 5,
    resourceId: "table/tableName",
    scalableDimension: "dynamodb:table:ReadCapacityUnits",
    serviceNamespace: "dynamodb",
  });
const awsAppautoscalingScheduledActionDynamodb =
  new aws.appautoscalingScheduledAction.AppautoscalingScheduledAction(
    this,
    "dynamodb_1",
    {
      name: "dynamodb",
      resourceId: awsAppautoscalingTargetDynamodb.resourceId,
      scalableDimension: awsAppautoscalingTargetDynamodb.scalableDimension,
      scalableTargetAction: {
        maxCapacity: 200,
        minCapacity: 1,
      },
      schedule: "at(2006-01-02T15:04:05)",
      serviceNamespace: awsAppautoscalingTargetDynamodb.serviceNamespace,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsAppautoscalingScheduledActionDynamodb.overrideLogicalId("dynamodb");

ECS Service Autoscaling

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsAppautoscalingTargetEcs =
  new aws.appautoscalingTarget.AppautoscalingTarget(this, "ecs", {
    maxCapacity: 4,
    minCapacity: 1,
    resourceId: "service/clusterName/serviceName",
    scalableDimension: "ecs:service:DesiredCount",
    serviceNamespace: "ecs",
  });
const awsAppautoscalingScheduledActionEcs =
  new aws.appautoscalingScheduledAction.AppautoscalingScheduledAction(
    this,
    "ecs_1",
    {
      name: "ecs",
      resourceId: awsAppautoscalingTargetEcs.resourceId,
      scalableDimension: awsAppautoscalingTargetEcs.scalableDimension,
      scalableTargetAction: {
        maxCapacity: 10,
        minCapacity: 1,
      },
      schedule: "at(2006-01-02T15:04:05)",
      serviceNamespace: awsAppautoscalingTargetEcs.serviceNamespace,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsAppautoscalingScheduledActionEcs.overrideLogicalId("ecs");

Argument Reference

The following arguments are supported:

  • name - (Required) Name of the scheduled action.
  • serviceNamespace - (Required) Namespace of the AWS service. Documentation can be found in the serviceNamespace parameter at: AWS Application Auto Scaling API Reference Example: ecs
  • resourceId - (Required) Identifier of the resource associated with the scheduled action. Documentation can be found in the resourceId parameter at: AWS Application Auto Scaling API Reference
  • scalableDimension - (Required) Scalable dimension. Documentation can be found in the scalableDimension parameter at: AWS Application Auto Scaling API Reference Example: ecs:service:DesiredCount
  • scalableTargetAction - (Required) New minimum and maximum capacity. You can set both values or just one. See below
  • schedule - (Required) Schedule for this action. The following formats are supported: At expressions - at(yyyy-mm-ddThh:mm:ss), Rate expressions - rate(valueunit), Cron expressions - cron(fields). Times for at expressions and cron expressions are evaluated using the time zone configured in timezone. Documentation can be found in the timezone parameter at: AWS Application Auto Scaling API Reference
  • startTime - (Optional) Date and time for the scheduled action to start in RFC 3339 format. The timezone is not affected by the setting of timezone.
  • endTime - (Optional) Date and time for the scheduled action to end in RFC 3339 format. The timezone is not affected by the setting of timezone.
  • timezone - (Optional) Time zone used when setting a scheduled action by using an at or cron expression. Does not affect timezone for startTime and endTime. Valid values are the canonical names of the IANA time zones supported by Joda-Time, such as etc/gmt+9 or pacific/tahiti. Default is utc.

Scalable Target Action Arguments

  • maxCapacity - (Optional) Maximum capacity. At least one of maxCapacity or minCapacity must be set.
  • minCapacity - (Optional) Minimum capacity. At least one of minCapacity or maxCapacity must be set.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • arn - ARN of the scheduled action.