What is @aws-cdk/aws-applicationautoscaling?
@aws-cdk/aws-applicationautoscaling is an AWS CDK library that allows you to configure application auto-scaling for various AWS resources. It provides constructs for defining scaling policies and targets, enabling you to automatically adjust capacity based on demand.
What are @aws-cdk/aws-applicationautoscaling's main functionalities?
Auto-scaling for DynamoDB
This feature allows you to set up auto-scaling for a DynamoDB table. The code sample demonstrates how to create a DynamoDB table and configure auto-scaling for its read capacity based on utilization.
const app = new cdk.App();
const stack = new cdk.Stack(app, 'AutoScalingStack');
const table = new dynamodb.Table(stack, 'MyTable', {
partitionKey: { name: 'id', type: dynamodb.AttributeType.STRING },
billingMode: dynamodb.BillingMode.PROVISIONED,
});
const readScaling = table.autoScaleReadCapacity({
minCapacity: 1,
maxCapacity: 10,
});
readScaling.scaleOnUtilization({
targetUtilizationPercent: 75,
});
Auto-scaling for ECS Services
This feature allows you to set up auto-scaling for ECS services. The code sample demonstrates how to create an ECS Fargate service and configure auto-scaling based on CPU utilization.
const app = new cdk.App();
const stack = new cdk.Stack(app, 'AutoScalingStack');
const cluster = new ecs.Cluster(stack, 'Cluster', {
vpc,
});
const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef');
const container = taskDefinition.addContainer('WebContainer', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
memoryLimitMiB: 512,
});
const service = new ecs.FargateService(stack, 'Service', {
cluster,
taskDefinition,
});
const scaling = service.autoScaleTaskCount({
minCapacity: 1,
maxCapacity: 10,
});
scaling.scaleOnCpuUtilization('CpuScaling', {
targetUtilizationPercent: 50,
});
Auto-scaling for Lambda Functions
This feature allows you to set up auto-scaling for Lambda functions. The code sample demonstrates how to create a Lambda function and configure auto-scaling based on utilization.
const app = new cdk.App();
const stack = new cdk.Stack(app, 'AutoScalingStack');
const fn = new lambda.Function(stack, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromAsset('lambda'),
});
const alias = new lambda.Alias(stack, 'Alias', {
aliasName: 'prod',
version: fn.currentVersion,
});
const scaling = alias.addAutoScaling({
minCapacity: 1,
maxCapacity: 10,
});
scaling.scaleOnUtilization({
utilizationTarget: 0.75,
});
Other packages similar to @aws-cdk/aws-applicationautoscaling
aws-sdk
The aws-sdk package provides a comprehensive set of tools for interacting with AWS services, including auto-scaling. However, it requires more manual setup and configuration compared to the higher-level abstractions provided by @aws-cdk/aws-applicationautoscaling.
serverless
The serverless framework allows you to deploy and manage serverless applications on AWS and other cloud providers. It includes support for auto-scaling Lambda functions and other resources, but it is more focused on serverless architectures compared to the broader scope of @aws-cdk/aws-applicationautoscaling.
terraform
Terraform is an infrastructure as code tool that allows you to define and provision infrastructure using a declarative configuration language. It supports auto-scaling for various AWS resources, but it uses a different approach and syntax compared to the AWS CDK.
0.12.0 (2018-10-12)
IMPORTANT NOTE: This release includes a fix for a bug that would make the toolkit unusable for multi-stack applications. In order to benefit from this fix, a globally installed CDK toolkit must also be updated:
$ npm i -g aws-cdk
$ cdk --version
0.12.0 (build ...)
Like always, you will also need to update your project's library versions:
Language | Update?
--------------------------- | ------------------------------------------------------------------------------------------------------------------
JavaScript/TypeScript (npm) | npx npm-check-updates -u
Java (maven) | mvn versions:use-latest-versions
.NET (NuGet) | nuget update
Bug Fixes
- aws-codebuild: allow passing oauth token to GitHubEnterpriseSource (#908) (c23da91)
- toolkit: multi-stack apps cannot be synthesized or deployed (#911) (5511076), closes #868 #294 #910
Features
- aws-cloudformation: add permission management to CreateUpdate and Delete Stack CodePipeline Actions. (#880) (8b3ae43)
- aws-codepipeline: make input and output artifact names optional when creating Actions. (#845) (3d91c93)
BREAKING CHANGES TO EXPERIMENTAL FEATURES
Previously, we always required customers to explicitly name the output artifacts the Actions used in the Pipeline, and to explicitly "wire together" the outputs of one Action as inputs to another. With this change, the CodePipeline Construct generates artifact names, if the customer didn't provide one explicitly, and tries to find the first available output artifact to use as input to a newly created Action that needs it, thus turning both the input and output artifacts from required to optional properties.