316 lines
11 KiB
TypeScript
316 lines
11 KiB
TypeScript
import type { Construct } from 'constructs';
|
|
import type { Architecture } from './architecture';
|
|
import type { IFunction } from './function-base';
|
|
import type * as ec2 from '../../aws-ec2';
|
|
import * as iam from '../../aws-iam';
|
|
import type * as kms from '../../aws-kms';
|
|
import type { IResource } from '../../core';
|
|
import { Resource } from '../../core';
|
|
import type { CapacityProviderReference, ICapacityProviderRef } from '../../interfaces/generated/aws-lambda-interfaces.generated';
|
|
/**
|
|
* Represents a Lambda capacity provider.
|
|
*/
|
|
export interface ICapacityProvider extends IResource, ICapacityProviderRef {
|
|
/**
|
|
* The ARN of the capacity provider.
|
|
*
|
|
* @attribute
|
|
*/
|
|
readonly capacityProviderArn: string;
|
|
/**
|
|
* The name of the capacity provider.
|
|
*
|
|
* @attribute
|
|
*/
|
|
readonly capacityProviderName: string;
|
|
}
|
|
/**
|
|
* Properties for creating a Lambda capacity provider.
|
|
*/
|
|
export interface CapacityProviderProps {
|
|
/**
|
|
* The name of the capacity provider. The name must be unique within the AWS account and region.
|
|
*
|
|
* @default - AWS CloudFormation generates a unique physical ID and uses that
|
|
* ID for the capacity provider's name.
|
|
*/
|
|
readonly capacityProviderName?: string;
|
|
/**
|
|
* A list of security group IDs to associate with EC2 instances launched by the capacity provider.
|
|
* Up to 5 security groups can be specified.
|
|
*/
|
|
readonly securityGroups: ec2.ISecurityGroup[];
|
|
/**
|
|
* A list of subnets where the capacity provider can launch EC2 instances.
|
|
* At least one subnet must be specified, and up to 16 subnets are supported.
|
|
*/
|
|
readonly subnets: ec2.ISubnet[];
|
|
/**
|
|
* The IAM role that the Lambda service assumes to manage the capacity provider.
|
|
*
|
|
* @default - A role will be generated containing the AWSLambdaManagedEC2ResourceOperator managed policy
|
|
*/
|
|
readonly operatorRole?: iam.IRole;
|
|
/**
|
|
* The instruction set architecture required for compute instances.
|
|
* Only one architecture can be specified per capacity provider.
|
|
*
|
|
* @default - No architecture constraints specified
|
|
*/
|
|
readonly architectures?: Architecture[];
|
|
/**
|
|
* Configuration for filtering instance types that the capacity provider can use.
|
|
*
|
|
* @default - No instance type filtering applied
|
|
*/
|
|
readonly instanceTypeFilter?: InstanceTypeFilter;
|
|
/**
|
|
* The maximum number of vCPUs that the capacity provider can scale up to.
|
|
*
|
|
* @default - No maximum limit specified, service default is 400
|
|
*/
|
|
readonly maxVCpuCount?: number;
|
|
/**
|
|
* The options for scaling a capacity provider, including scaling policies.
|
|
*
|
|
* @default - The `Auto` option is applied by default
|
|
*/
|
|
readonly scalingOptions?: ScalingOptions;
|
|
/**
|
|
* The AWS Key Management Service (KMS) key used to encrypt data associated with the capacity provider.
|
|
*
|
|
* @default - No KMS key specified, uses an AWS-managed key instead
|
|
*/
|
|
readonly kmsKey?: kms.IKey;
|
|
}
|
|
/**
|
|
* Configuration for filtering instance types that a capacity provider can use. Instances types can either be allowed or excluded, not both.
|
|
*/
|
|
export declare class InstanceTypeFilter {
|
|
/**
|
|
* Creates an instance type filter that allows only the specified instance types.
|
|
*
|
|
* @param instanceTypes A list of instance types that the capacity provider is allowed to use.
|
|
*/
|
|
static allow(instanceTypes: ec2.InstanceType[]): InstanceTypeFilter;
|
|
/**
|
|
* Creates an instance type filter that excludes the specified instance types.
|
|
*
|
|
* @param instanceTypes A list of instance types that the capacity provider should not use.
|
|
*/
|
|
static exclude(instanceTypes: ec2.InstanceType[]): InstanceTypeFilter;
|
|
/**
|
|
* A list of instance types that the capacity provider is allowed to use.
|
|
*/
|
|
readonly allowedInstanceTypes?: ec2.InstanceType[];
|
|
/**
|
|
* A list of instance types that the capacity provider should not use.
|
|
*/
|
|
readonly excludedInstanceTypes?: ec2.InstanceType[];
|
|
/**
|
|
* Creates a new InstanceTypeFilter.
|
|
*
|
|
* @param instanceTypes The instance type configuration
|
|
*/
|
|
private constructor();
|
|
}
|
|
/**
|
|
* Configuration options for scaling a capacity provider, including scaling mode and policies.
|
|
*/
|
|
export declare class ScalingOptions {
|
|
/**
|
|
* Creates scaling options where the capacity provider manages scaling automatically.
|
|
*/
|
|
static auto(): ScalingOptions;
|
|
/**
|
|
* Creates manual scaling options with custom target tracking scaling policies. At least one policy is required.
|
|
*
|
|
* @param scalingPolicies The target tracking scaling policies to use for manual scaling.
|
|
*/
|
|
static manual(scalingPolicies: TargetTrackingScalingPolicy[]): ScalingOptions;
|
|
/**
|
|
* The scaling mode for the capacity provider.
|
|
*/
|
|
readonly scalingMode: string;
|
|
/**
|
|
* The target tracking scaling policies used when scaling mode is 'Manual'.
|
|
*/
|
|
readonly scalingPolicies?: TargetTrackingScalingPolicy[];
|
|
/**
|
|
* Creates a new ScalingOptions.
|
|
*
|
|
* @param scalingMode The scaling mode for the capacity provider
|
|
* @param scalingPolicies The target tracking scaling policies for manual scaling
|
|
*/
|
|
private constructor();
|
|
}
|
|
/**
|
|
* A target tracking scaling policy that automatically adjusts the capacity provider's compute resources
|
|
* to maintain a specified target value by tracking the required CloudWatch metric.
|
|
*/
|
|
export declare class TargetTrackingScalingPolicy {
|
|
readonly metricType: string;
|
|
readonly value: number;
|
|
/**
|
|
* Creates a target tracking scaling policy for CPU utilization.
|
|
*
|
|
* @param targetCpuUtilization The target value for CPU utilization. The capacity provider will scale resources to maintain this target value.
|
|
*/
|
|
static cpuUtilization(targetCpuUtilization: number): TargetTrackingScalingPolicy;
|
|
/**
|
|
* The predefined metric type for this scaling policy.
|
|
*/
|
|
readonly predefinedMetricType: string;
|
|
/**
|
|
* The target value for the specified metric as a percentage. The capacity provider will scale resources to maintain this target value.
|
|
*/
|
|
readonly targetValue: number;
|
|
/**
|
|
* Creates a new TargetTrackingScalingPolicy.
|
|
*
|
|
* @param metricType The predefined metric type
|
|
* @param value The target value for the metric
|
|
*/
|
|
private constructor();
|
|
}
|
|
/**
|
|
* Base class for a Lambda capacity provider.
|
|
*/
|
|
declare abstract class CapacityProviderBase extends Resource implements ICapacityProvider {
|
|
/**
|
|
* The name of the capacity provider.
|
|
*/
|
|
abstract readonly capacityProviderName: string;
|
|
/**
|
|
* The Amazon Resource Name (ARN) of the capacity provider.
|
|
*/
|
|
abstract readonly capacityProviderArn: string;
|
|
get capacityProviderRef(): CapacityProviderReference;
|
|
}
|
|
/**
|
|
* Attributes for importing an existing Lambda capacity provider.
|
|
*/
|
|
export interface CapacityProviderAttributes {
|
|
/**
|
|
* The Amazon Resource Name (ARN) of the capacity provider.
|
|
*
|
|
* Format: arn:<partition>:lambda:<region>:<account-id>:capacity-provider:<capacity-provider-name>
|
|
*/
|
|
readonly capacityProviderArn: string;
|
|
}
|
|
/**
|
|
* Options for creating a function associated with a capacity provider.
|
|
*/
|
|
export interface CapacityProviderFunctionOptions {
|
|
/**
|
|
* Specifies the maximum number of concurrent invokes a single execution environment can handle.
|
|
*
|
|
* @default Maximum is set to 10
|
|
*/
|
|
readonly perExecutionEnvironmentMaxConcurrency?: number;
|
|
/**
|
|
* Specifies the execution environment memory per VCPU, in GiB.
|
|
*
|
|
* @default 2.0
|
|
*/
|
|
readonly executionEnvironmentMemoryGiBPerVCpu?: number;
|
|
/**
|
|
* A boolean determining whether or not to automatically publish to the $LATEST.PUBLISHED version.
|
|
*
|
|
* @default - True
|
|
*/
|
|
readonly publishToLatestPublished?: boolean;
|
|
/**
|
|
* The scaling options that are applied to the $LATEST.PUBLISHED version.
|
|
*
|
|
* @default - No scaling limitations are applied to the $LATEST.PUBLISHED version.
|
|
*/
|
|
readonly latestPublishedScalingConfig?: LatestPublishedScalingConfig;
|
|
}
|
|
/**
|
|
* The scaling configuration that will be applied to the $LATEST.PUBLISHED version.
|
|
*/
|
|
export interface LatestPublishedScalingConfig {
|
|
/**
|
|
* The minimum number of execution environments to maintain for the $LATEST.PUBLISHED version
|
|
* when published into a capacity provider.
|
|
*
|
|
* This setting ensures that at least this many execution environments are always
|
|
* available to handle function invocations for this specific version, reducing cold start latency.
|
|
*
|
|
* @default - 3 execution environments are set to be the minimum
|
|
*/
|
|
readonly minExecutionEnvironments?: number;
|
|
/**
|
|
* The maximum number of execution environments allowed for the $LATEST.PUBLISHED version
|
|
* when published into a capacity provider.
|
|
*
|
|
* This setting limits the total number of execution environments that can be created
|
|
* to handle concurrent invocations of this specific version.
|
|
*
|
|
* @default - No maximum specified
|
|
*/
|
|
readonly maxExecutionEnvironments?: number;
|
|
}
|
|
/**
|
|
* A Lambda capacity provider that manages compute resources for Lambda functions.
|
|
*/
|
|
export declare class CapacityProvider extends CapacityProviderBase {
|
|
/** Uniquely identifies this class. */
|
|
static readonly PROPERTY_INJECTION_ID: string;
|
|
/**
|
|
* Import an existing capacity provider by name.
|
|
*
|
|
* @param scope The parent construct
|
|
* @param id The construct ID
|
|
* @param capacityProviderName The name of the capacity provider to import
|
|
*/
|
|
static fromCapacityProviderName(scope: Construct, id: string, capacityProviderName: string): ICapacityProvider;
|
|
/**
|
|
* Import an existing capacity provider by ARN.
|
|
*
|
|
* @param scope The parent construct
|
|
* @param id The construct ID
|
|
* @param capacityProviderArn The ARN of the capacity provider to import
|
|
*/
|
|
static fromCapacityProviderArn(scope: Construct, id: string, capacityProviderArn: string): ICapacityProvider;
|
|
/**
|
|
* Import an existing capacity provider using its attributes.
|
|
*
|
|
* @param scope The parent construct
|
|
* @param id The construct ID
|
|
* @param attrs The capacity provider attributes
|
|
*/
|
|
static fromCapacityProviderAttributes(scope: Construct, id: string, attrs: CapacityProviderAttributes): ICapacityProvider;
|
|
private readonly capacityProvider;
|
|
/**
|
|
* The name of the capacity provider.
|
|
*/
|
|
get capacityProviderName(): string;
|
|
/**
|
|
* The Amazon Resource Name (ARN) of the capacity provider.
|
|
*/
|
|
get capacityProviderArn(): string;
|
|
/**
|
|
* Creates a new Lambda capacity provider.
|
|
*
|
|
* @param scope The parent construct
|
|
* @param id The construct ID
|
|
* @param props The capacity provider properties
|
|
*/
|
|
constructor(scope: Construct, id: string, props: CapacityProviderProps);
|
|
private validateCapacityProviderProps;
|
|
private validateCapacityProviderName;
|
|
private validateScalingPolicies;
|
|
private validateInstanceTypeFilter;
|
|
/**
|
|
* Configures a Lambda function to use this capacity provider.
|
|
*
|
|
* @param func The Lambda function to configure
|
|
* @param options Optional configuration for the function's capacity provider settings
|
|
*/
|
|
addFunction(func: IFunction, options?: CapacityProviderFunctionOptions): void;
|
|
private validateFunctionScalingConfig;
|
|
}
|
|
export {};
|