How to use @aws-cdk/aws-applicationautoscaling - 4 common examples

To help you get started, we’ve selected a few @aws-cdk/aws-applicationautoscaling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / @aws-cdk / aws-dynamodb / lib / scalable-table-attribute.ts View on Github external
import * as appscaling from '@aws-cdk/aws-applicationautoscaling';
import { UtilizationScalingProps } from './scalable-attribute-api';

/**
 * A scalable table attribute
 */
export class ScalableTableAttribute extends appscaling.BaseScalableAttribute {
  /**
   * Scale out or in based on time
   */
  public scaleOnSchedule(id: string, action: appscaling.ScalingSchedule) {
    super.doScaleOnSchedule(id, action);
  }

  /**
   * Scale out or in to keep utilization at a given level
   */
  public scaleOnUtilization(props: UtilizationScalingProps) {
    if (props.targetUtilizationPercent < 10 || props.targetUtilizationPercent > 90) {
      // tslint:disable-next-line:max-line-length
      throw new RangeError(`targetUtilizationPercent for DynamoDB scaling must be between 10 and 90 percent, got: ${props.targetUtilizationPercent}`);
    }
    const predefinedMetric = this.props.dimension.indexOf('ReadCapacity') === -1
github aws / aws-cdk / packages / @aws-cdk / aws-ecs / lib / base / scalable-task-count.ts View on Github external
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
import { Construct } from '@aws-cdk/core';

/**
 * The properties of a scalable attribute representing task count.
 */
// tslint:disable-next-line:no-empty-interface
export interface ScalableTaskCountProps extends appscaling.BaseScalableAttributeProps {

}

/**
 * The scalable attribute representing task count.
 */
export class ScalableTaskCount extends appscaling.BaseScalableAttribute {

  /**
   * Constructs a new instance of the ScalableTaskCount class.
   */
  constructor(scope: Construct, id: string, props: ScalableTaskCountProps) {
    super(scope, id, props);
  }

  /**
   * Scales in or out based on a specified scheduled time.
   */
  public scaleOnSchedule(id: string, props: appscaling.ScalingSchedule) {
    return super.doScaleOnSchedule(id, props);
  }

  /**
github aws / aws-cdk / packages / @aws-cdk / aws-dynamodb / lib / scalable-table-attribute.ts View on Github external
public scaleOnUtilization(props: UtilizationScalingProps) {
    if (props.targetUtilizationPercent < 10 || props.targetUtilizationPercent > 90) {
      // tslint:disable-next-line:max-line-length
      throw new RangeError(`targetUtilizationPercent for DynamoDB scaling must be between 10 and 90 percent, got: ${props.targetUtilizationPercent}`);
    }
    const predefinedMetric = this.props.dimension.indexOf('ReadCapacity') === -1
        ? appscaling.PredefinedMetric.DYANMODB_WRITE_CAPACITY_UTILIZATION
        : appscaling.PredefinedMetric.DYNAMODB_READ_CAPACITY_UTILIZATION;

    super.doScaleToTrackMetric('Tracking', {
      policyName: props.policyName,
      disableScaleIn: props.disableScaleIn,
      scaleInCooldown: props.scaleInCooldown,
      scaleOutCooldown: props.scaleOutCooldown,
      targetValue: props.targetUtilizationPercent,
      predefinedMetric,
    });
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-ecs / lib / base / scalable-task-count.ts View on Github external
public scaleOnCpuUtilization(id: string, props: CpuUtilizationScalingProps) {
    return super.doScaleToTrackMetric(id, {
      predefinedMetric: appscaling.PredefinedMetric.ECS_SERVICE_AVERAGE_CPU_UTILIZATION,
      policyName: props.policyName,
      disableScaleIn: props.disableScaleIn,
      targetValue: props.targetUtilizationPercent,
      scaleInCooldown: props.scaleInCooldown,
      scaleOutCooldown: props.scaleOutCooldown
    });
  }

@aws-cdk/aws-applicationautoscaling

The CDK Construct Library for AWS::ApplicationAutoScaling

Apache-2.0
Latest version published 6 days ago

Package Health Score

92 / 100
Full package analysis