UNPKG

@cloudcamp/aws-runtime

Version:

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

207 lines (206 loc) 5.88 kB
import * as cdk from "aws-cdk-lib/core"; import { Stage } from "./stage"; import * as cxapi from "aws-cdk-lib/cx-api"; import * as pipelines from "aws-cdk-lib/pipelines"; import { Stack } from "./stack"; /** * @experimental */ export interface Configuration { /** * @experimental */ readonly name: string; /** * @experimental */ readonly repository: string; /** * @experimental */ readonly account: string; /** * @experimental */ readonly region: string; /** * @experimental */ readonly branch: string; /** * @experimental */ readonly vpcId: string; /** * @experimental */ readonly repositoryTokenSecret: string; } /** * (experimental) App represents your application running in the cloud․ Every app contains one or more ``{@link Stack | Stacks}``, which you can use to add your own resources, like a ``{@link WebService | WebService}`` or a ``{@link Database | Database}``. * * An app can be as big or small as you like - from a single webserver to * dozens of load-balanced instances serving different parts of your * application. * * This example adds a ``{@link WebService | WebService}`` to the * ``{@link App.production | production}`` stack: * * ```ts * import { App, WebService } from "@cloudcamp/aws-runtime"; * * let app = new App(); * * new WebService(app.production, "prod-web", { * dockerfile: "../Dockerfile" * }); * ``` * * @experimental * @order 1 */ export declare class App extends cdk.App { private static INSTANCE?; /** * (experimental) Initialize your cloudcamp application. * * @experimental * @remarks App is a singleton class - it is instantiated exactly once, before * any other resources are created. * @topic Initialization */ constructor(); private getContextOrThrow; /** * (experimental) Returns the global App singleton instance. * * Throws an exception if App has not been instantiated yet. * * @experimental */ static get instance(): App; /** * (experimental) Use this stack for anything related to the network, for example DNS entries. * * @experimental * @topic Stacks * @remarks To deploy resources to the cloud, they are added to a ``Stack``. * CloudCamp comes with three default stacks: */ get network(): Stack; /** * (experimental) This stack can be used to create an environment for testing changes before deploying to production. * * @experimental */ get staging(): Stack; /** * (experimental) The production stack. * * @experimental */ get production(): Stack; /** * (experimental) Get an existing stack by name. * * @param name The name of the stack. * @experimental * @topic Adding custom stacks * @remarks In addition to the default stacks provided by cloudcamp, you can * create your own stacks. */ getStack(name: string): Stack; /** * (experimental) Add a new stack to your application. * * Pass a stack name to create a new, empty stack: * * ```ts * void 0; * import { App, WebService, Stack} from "@cloudcamp/aws-runtime"; * const app = new App(); * void 'show'; * const devStack = app.stack("development"); * ``` * * @param name The name of the stack. * @experimental */ stack(name: string): Stack; private stages; private getOrAddStage; /** * (experimental) Get an existing stage by name. * * Stages can be obtained by their name to modify their attributes. A common * use case is to require manual approval to deploy to the production stage: * * ```ts * const stage = app.getStage("production"); * stage.needsManualApproval = true; * ``` * * @param name The name of the stage. * @experimental * @topic Stages * @remarks Stages are responsible for building your stacks. By default, * CloudCamp creates a stage for each stack and gives it the same name. You * can customize this behaviour by adding your own stages. */ getStage(name: string): Stage; /** * (experimental) Add a new stage. * * This method can be used to add a stage with a custom ``Stack`` subclass. * ```ts * import { App, WebService, Stack } from "@cloudcamp/aws-runtime"; * * class CustomStack extends Stack { * constructor(scope: cdk.Construct, id: string, props: cdk.StackProps) { * super(scope, id, props); * new WebService(this, "web", { * dockerfile: "../Dockerfile" * }); * } * } * * // later in the code... * const app = new App(); * const stage = app.stage("dev"); * const stack = new CustomStack(stage, "dev"); * * // stack is automatically set to the new stack we created * if (stage.stack == stack) { * // outputs "True!" * console.log("True!"); * } * ``` * * @param name The name of the stage. * @param stage An optional stage object. * @experimental */ stage(name: string, stage?: Stage): Stage; /** * @experimental * @ignore true */ configuration: Configuration; private pipelineStack; /** * @experimental * @ignore true */ get pipeline(): pipelines.CodePipeline; private setupCodePipeline; /** * (experimental) Synthesize this stage into a cloud assembly. * * Once an assembly has been synthesized, it cannot be modified. Subsequent * calls will return the same assembly. * * @experimental * @ignore true */ synth(options?: cdk.StageSynthesisOptions): cxapi.CloudAssembly; }