This AWS CDK construct enables autoscaling for AWS AppRunner services on CloudFormation. The construct is written in TypeScript and uses the AWS CDK Custom Resources to create the required AWS resources.
Aws has published the new constructs for this configuration, use them instead, doc here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apprunner.CfnAutoScalingConfiguration.html
Requirements To use this construct, you'll need the following:
- An AWS account with the necessary permissions to create AWS AppRunner and AWS CloudFormation resources.
- AWS CDK v2 installed and configured on your development machine.
- Node.js and TypeScript installed on your development machine.
To get started with this library, follow these steps:
- Install the library in your AWS CDK project by running the following command:
npm install cdk-apprunner-autoscaling
or, with yarn:
yarn add cdk-apprunner-autoscaling
- Import it in your CDK stack:
import { AppRunnerAutoScaling } from "cdk-apprunner-autoscaling";
- Instantiate the AppRunnerAutoscaling construct in your AWS CDK stack and provide the required parameters:
const scaling = new AppRunnerAutoScaling(this, "AutoScaling", {
AutoScalingConfigurationName: `my-scaling-config`,
MaxConcurrency: 200,
MinSize: 1,
MaxSize: 3,
});
- On your
CfnService
Construct (L1), reference thescaling
configuration as follows:
const service = new apprunner.CfnService(this, "AppRunnerService", {
serviceName: id,
autoScalingConfigurationArn: scaling.arn, // <-- Reference here.
/** Other config... **/
});
- When you deploy again, you will have that autoscaling config set.