UNPKG

@cloudcamp/aws-runtime

Version:

CloudCamp - Launch faster by building scalable infrastructure in few lines of code.

310 lines (309 loc) 7.35 kB
import * as ecs_patterns from "aws-cdk-lib/aws-ecs-patterns"; import { Construct } from "constructs"; /** * @experimental */ export interface WebServiceProps { /** * (experimental) The path to the Dockerfile to run. * * @experimental */ readonly dockerfile: string; /** * (experimental) The port exposed in the docker container. * * @default 80 * @experimental */ readonly port?: number; /** * (experimental) Environment variables. * * @experimental */ readonly environment?: { [key: string]: string; }; /** * (experimental) TODO. * * @experimental */ readonly domain?: string; /** * (experimental) The number of cpu units. * * Valid values, which determines your range of valid values for the memory parameter: * * - 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB * - 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB * - 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, * 8GB * - 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB * increments * - 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB * increments * * @default 256 * @experimental */ readonly cpu?: number; /** * (experimental) The amount (in MiB) of memory. * * - 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 * vCPU) * - 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu * values: 512 (.5 vCPU) * - 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 * GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU) * - Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - * Available cpu values: 2048 (2 vCPU) * - Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - * Available cpu values: 4096 (4 vCPU) * * @default 512 * @experimental */ readonly memory?: number; /** * @experimental */ readonly desiredCount?: number; /** * @experimental */ readonly healthCheckPath?: string; } /** * @experimental */ export interface AlarmConfiguration { /** * @experimental */ readonly duration?: number; /** * @experimental */ readonly threshold?: number; /** * @experimental */ readonly enabled?: boolean; } /** * @experimental */ export interface SlackConfiguration { /** * @experimental */ readonly workspaceId: string; /** * @experimental */ readonly channelId: string; } /** * @experimental */ export interface WebServiceAlarmProps { /** * @experimental */ readonly slack?: SlackConfiguration; /** * @experimental */ readonly email?: string[]; /** * @experimental */ readonly sms?: string[]; /** * @experimental */ readonly http5xx?: AlarmConfiguration; /** * @experimental */ readonly http4xx?: AlarmConfiguration; /** * @experimental */ readonly rejected?: AlarmConfiguration; /** * @experimental */ readonly slow?: AlarmConfiguration; } /** * @experimental */ export interface ScalingSchedule { /** * @experimental */ readonly id: string; /** * (experimental) The minute to run this rule at. * * @default - Every minute * @experimental */ readonly minute?: string; /** * (experimental) The hour to run this rule at. * * @default - Every hour * @experimental */ readonly hour?: string; /** * (experimental) The day of the month to run this rule at. * * @default - Every day of the month * @experimental */ readonly day?: string; /** * (experimental) The month to run this rule at. * * @default - Every month * @experimental */ readonly month?: string; /** * (experimental) The year to run this rule at. * * @default - Every year * @experimental */ readonly year?: string; /** * (experimental) The day of the week to run this rule at. * * @default - Any day of the week * @experimental */ readonly weekDay?: string; } /** * @experimental */ export interface ScheduleScalingProps { /** * @experimental */ readonly min: number; /** * @experimental */ readonly max: number; /** * @experimental */ readonly schedule: ScalingSchedule[]; } /** * @experimental */ export interface MetricScalingProps { /** * @experimental */ readonly min: number; /** * @experimental */ readonly max: number; /** * @experimental */ readonly cpu?: number; /** * @experimental */ readonly memory?: number; /** * @experimental */ readonly requestCount?: number; } /** * (experimental) A scalable web server running one or more docker containers behind a load balancer. * * `WebService` runs any web application behing a load balancers as docker * containers. For example, this runs a web application as a single container * exposed on port 8080: * * ```ts * void 0; * import { App, WebService } from "@cloudcamp/aws-runtime"; * let app = new App(); * void 'show'; * new WebService(app.production, "prod-web", { * dockerfile: "../Dockerfile", * port: 8080 * }); * ``` * * @experimental * @order 4 */ export declare class WebService extends Construct { /** * (experimental) Initialize a new web service. * * *Examples:* * * To use your own domain and serve traffic via SSL, use the `domain` * and `ssl` properties: * ```ts * void 0; * import { App, WebService } from "@cloudcamp/aws-runtime"; * let app = new App(); * void 'show'; * * new WebService(app.production, "prod", { * dockerfile: "../Dockerfile", * domain: "example.com", * ssl: true * }); * ``` * * See `{@link "command/domain/#domain-create" | domain:create}` and * `{@link "command/cert/#cert-create" | cert:create}` for more information on * setting up domains/SSL. * * @param scope the parent, i.e. a stack. * @param id a unique identifier within the parent scope. * @param props the properties of WebService. * @experimental * @remarks During initialization you can configure: Custom domains, SSL, * machine configuration, health checks and the default number of instances. * @topic Initialization */ constructor(scope: Construct, id: string, props: WebServiceProps); /** * @experimental */ fargateService: ecs_patterns.ApplicationLoadBalancedFargateService; /** * @experimental */ scaleOnSchedule(props: ScheduleScalingProps): void; /** * @experimental */ scaleOnMetric(props: MetricScalingProps): void; /** * @experimental */ alarms(props?: WebServiceAlarmProps): void; private addHttpAlarm; private addRejectedAlarm; private addSlowAlarm; }