314 lines
11 KiB
TypeScript
314 lines
11 KiB
TypeScript
import type { Construct } from 'constructs';
|
|
import type { EnvironmentType } from './environment-type';
|
|
import * as ec2 from '../../aws-ec2';
|
|
import * as iam from '../../aws-iam';
|
|
import type { IResource, Size } from '../../core';
|
|
import { Resource } from '../../core';
|
|
import type { IFleetRef, FleetReference } from '../../interfaces/generated/aws-codebuild-interfaces.generated';
|
|
/**
|
|
* Construction properties of a CodeBuild Fleet.
|
|
*/
|
|
export interface FleetProps {
|
|
/**
|
|
* The name of the Fleet.
|
|
*
|
|
* @default - CloudFormation generated name
|
|
*/
|
|
readonly fleetName?: string;
|
|
/**
|
|
* The number of machines allocated to the compute fleet.
|
|
* Defines the number of builds that can run in parallel.
|
|
*
|
|
* Minimum value of 1.
|
|
*/
|
|
readonly baseCapacity: number;
|
|
/**
|
|
* The instance type of the compute fleet.
|
|
*
|
|
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ComputeType.html
|
|
*/
|
|
readonly computeType: FleetComputeType;
|
|
/**
|
|
* The build environment (operating system/architecture/accelerator) type
|
|
* made available to projects using this fleet
|
|
*/
|
|
readonly environmentType: EnvironmentType;
|
|
/**
|
|
* The compute configuration of the compute fleet.
|
|
*
|
|
* This is only permitted if `computeType` is set to ATTRIBUTE_BASED or
|
|
* CUSTOM_INSTANCE_TYPE. In such cases, this is required.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment-reserved-capacity.types
|
|
*
|
|
* @default - do not specify compute configuration
|
|
*/
|
|
readonly computeConfiguration?: ComputeConfiguration;
|
|
/**
|
|
* The compute fleet overflow behavior.
|
|
*
|
|
* For overflow behavior `QUEUE`, overflow builds need to wait on the existing fleet instances to become available.
|
|
*
|
|
* For overflow behavior `ON_DEMAND`, overflow builds run on CodeBuild on-demand.
|
|
*
|
|
* @default undefined - AWS CodeBuild default behavior is QUEUE
|
|
*/
|
|
readonly overflowBehavior?: FleetOverflowBehavior;
|
|
/**
|
|
* Service Role assumed by Fleet instances.
|
|
*
|
|
* This Role is not used by Project builds running on Fleet instances; Project
|
|
* builds assume the `role` on Project instead.
|
|
*
|
|
* @default - A role will be created if any permissions are granted
|
|
*/
|
|
readonly role?: iam.IRole;
|
|
/**
|
|
* VPC network to place fleet instance network interfaces.
|
|
*
|
|
* Specify this if the fleet needs to access resources in a VPC.
|
|
*
|
|
* @default - No VPC is specified.
|
|
*/
|
|
readonly vpc?: ec2.IVpc;
|
|
/**
|
|
* Where to place the network interfaces within the VPC.
|
|
*
|
|
* To access AWS services, your fleet needs to be in one of the following types of subnets:
|
|
*
|
|
* 1. Subnets with access to the internet (of type PRIVATE_WITH_EGRESS).
|
|
* 2. Private subnets unconnected to the internet, but with [VPC endpoints](https://docs.aws.amazon.com/codebuild/latest/userguide/use-vpc-endpoints-with-codebuild.html) for the necessary services.
|
|
*
|
|
* If you don't specify a subnet selection, the default behavior is to use PRIVATE_WITH_EGRESS subnets first if they exist,
|
|
* then PRIVATE_WITHOUT_EGRESS, and finally PUBLIC subnets. If your VPC doesn't have PRIVATE_WITH_EGRESS subnets but you need
|
|
* AWS service access, add VPC Endpoints to your private subnets.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/vpc-support.html
|
|
*
|
|
* @default - private subnets if available else public subnets
|
|
*/
|
|
readonly subnetSelection?: ec2.SubnetSelection;
|
|
/**
|
|
* What security groups to associate with the fleet's network interfaces.
|
|
* If none are provided, one will be created automatically.
|
|
*
|
|
* Only used if `vpc` is supplied.
|
|
*
|
|
* @default - A security group will be automatically created.
|
|
*/
|
|
readonly securityGroups?: ec2.ISecurityGroup[];
|
|
}
|
|
/**
|
|
* The compute type of the fleet.
|
|
*/
|
|
export declare enum MachineType {
|
|
/**
|
|
* General purpose compute type.
|
|
*/
|
|
GENERAL = "GENERAL",
|
|
/**
|
|
* Non-Volatile Memory Express (NVMe) storage optimized compute type.
|
|
*/
|
|
NVME = "NVME"
|
|
}
|
|
/**
|
|
* The compute configuration for the fleet.
|
|
*/
|
|
export interface ComputeConfiguration {
|
|
/**
|
|
* When using ATTRIBUTE_BASED, the amount of disk
|
|
* space of the instance type included in your fleet. When using CUSTOM_INSTANCE_TYPE,
|
|
* the additional amount of disk space to provision over the 64GB included by
|
|
* default.
|
|
*
|
|
* @default - No requirement, the actual value will be based on the other selected configuration properties
|
|
*/
|
|
readonly disk?: Size;
|
|
/**
|
|
* When using ATTRIBUTE_BASED, the machine type of the instance type included in your fleet.
|
|
*
|
|
* @default - No requirement, the actual value will be based on the other selected configuration properties
|
|
*/
|
|
readonly machineType?: MachineType;
|
|
/**
|
|
* When using ATTRIBUTE_BASED, the amount of memory of the instance type included in your fleet.
|
|
*
|
|
* @default - No requirement, the actual value will be based on the other selected configuration properties
|
|
*/
|
|
readonly memory?: Size;
|
|
/**
|
|
* When using ATTRIBUTE_BASED, the number of vCPUs of the instance type included in your fleet.
|
|
*
|
|
* @default - No requirement, the actual value will be based on the other selected configuration properties
|
|
*/
|
|
readonly vCpu?: number;
|
|
/**
|
|
* When using CUSTOM_INSTANCE_TYPE, the EC2 instance type to use for fleet instances.
|
|
*
|
|
* Not all instance types are supported by CodeBuild. If you use a disallowed type, the
|
|
* CloudFormation deployment will fail.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment-reserved-capacity.instance-types
|
|
* @default none
|
|
*/
|
|
readonly instanceType?: ec2.InstanceType;
|
|
}
|
|
/**
|
|
* Represents a Fleet for a reserved capacity CodeBuild project.
|
|
*/
|
|
export interface IFleet extends IResource, iam.IGrantable, ec2.IConnectable, IFleetRef {
|
|
/**
|
|
* The ARN of the fleet.
|
|
* @attribute
|
|
*/
|
|
readonly fleetArn: string;
|
|
/**
|
|
* The name of the fleet.
|
|
* @attribute
|
|
*/
|
|
readonly fleetName: string;
|
|
/**
|
|
* The compute type of the fleet.
|
|
*
|
|
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ComputeType.html
|
|
*/
|
|
readonly computeType: FleetComputeType;
|
|
/**
|
|
* The build environment (operating system/architecture/accelerator) type
|
|
* made available to projects using this fleet
|
|
*/
|
|
readonly environmentType: EnvironmentType;
|
|
}
|
|
/**
|
|
* Fleet for a reserved capacity CodeBuild project.
|
|
*
|
|
* Fleets allow for process builds or tests to run immediately and reduces build durations,
|
|
* by reserving compute resources for your projects.
|
|
*
|
|
* You will be charged for the resources in the fleet, even if they are idle.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/fleets.html
|
|
*/
|
|
export declare class Fleet extends Resource implements IFleet {
|
|
/** Uniquely identifies this class. */
|
|
static readonly PROPERTY_INJECTION_ID: string;
|
|
/**
|
|
* Creates a Fleet construct that represents an external fleet.
|
|
*
|
|
* @param scope The scope creating construct (usually `this`).
|
|
* @param id The construct's id.
|
|
* @param fleetArn The ARN of the fleet.
|
|
*/
|
|
static fromFleetArn(scope: Construct, id: string, fleetArn: string): IFleet;
|
|
/**
|
|
* The ARN of the fleet.
|
|
*/
|
|
get fleetArn(): string;
|
|
/**
|
|
* The name of the fleet.
|
|
*/
|
|
get fleetName(): string;
|
|
/**
|
|
* The compute type of the fleet.
|
|
*
|
|
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.ComputeType.html
|
|
*/
|
|
readonly computeType: FleetComputeType;
|
|
/**
|
|
* The build environment (operating system/architecture/accelerator) type
|
|
* made available to projects using this fleet
|
|
*/
|
|
readonly environmentType: EnvironmentType;
|
|
get fleetRef(): FleetReference;
|
|
private _connections?;
|
|
private readonly resource;
|
|
/**
|
|
* The network connections associated with this Fleet's security group(s) in
|
|
* the configured VPC.
|
|
*/
|
|
get connections(): ec2.Connections;
|
|
private role;
|
|
/**
|
|
* The grant principal for this Fleet's service role.
|
|
*/
|
|
get grantPrincipal(): iam.IPrincipal;
|
|
constructor(scope: Construct, id: string, props: FleetProps);
|
|
private validatePositiveInteger;
|
|
private configureVpc;
|
|
}
|
|
/**
|
|
* Fleet build machine compute type. Subset of Fleet compatible ComputeType values.
|
|
*
|
|
* The allocated memory, vCPU count and disk space of the build machine for a
|
|
* given compute type are dependent on the environment type.
|
|
* Some compute types may also not be available for all environment types.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment.types
|
|
*/
|
|
export declare enum FleetComputeType {
|
|
/**
|
|
* Small compute type
|
|
*
|
|
* May not be available for all environment types.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment.types
|
|
*/
|
|
SMALL = "BUILD_GENERAL1_SMALL",
|
|
/**
|
|
* Medium compute type
|
|
*
|
|
* May not be available for all environment types.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment.types
|
|
*/
|
|
MEDIUM = "BUILD_GENERAL1_MEDIUM",
|
|
/** Large compute type */
|
|
LARGE = "BUILD_GENERAL1_LARGE",
|
|
/**
|
|
* Extra Large compute type
|
|
*
|
|
* May not be available for all environment types.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment.types
|
|
*/
|
|
X_LARGE = "BUILD_GENERAL1_XLARGE",
|
|
/**
|
|
* Extra, Extra Large compute type
|
|
*
|
|
* May not be available for all environment types.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment.types
|
|
*/
|
|
X2_LARGE = "BUILD_GENERAL1_2XLARGE",
|
|
/**
|
|
* Specify the amount of vCPUs, memory, disk space, and the type of machine.
|
|
*
|
|
* AWS CodeBuild will select the cheapest instance that satisfies your specified attributes from `computeConfiguration`.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment-reserved-capacity.types
|
|
*/
|
|
ATTRIBUTE_BASED = "ATTRIBUTE_BASED_COMPUTE",
|
|
/**
|
|
* Specify a specific EC2 instance type to use for compute.
|
|
*
|
|
* You must set `instanceType` on `computeConfiguration`, and optionally set a
|
|
* `disk` size if the provided 64GB is insufficient.
|
|
*
|
|
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html#environment-reserved-capacity.instance-types
|
|
*/
|
|
CUSTOM_INSTANCE_TYPE = "CUSTOM_INSTANCE_TYPE"
|
|
}
|
|
/**
|
|
* The compute fleet overflow behavior.
|
|
*/
|
|
export declare enum FleetOverflowBehavior {
|
|
/**
|
|
* Overflow builds wait for existing fleet instances to become available.
|
|
*/
|
|
QUEUE = "QUEUE",
|
|
/**
|
|
* Overflow builds run on CodeBuild on-demand instances.
|
|
*/
|
|
ON_DEMAND = "ON_DEMAND"
|
|
}
|