UNPKG

5.09 kBTypeScriptView Raw
1import * as cxapi from '@aws-cdk/cx-api';
2import { IConstruct, Construct } from 'constructs';
3import { Environment } from './environment';
4import { Construct as CoreConstruct } from './construct-compat';
5/**
6 * Initialization props for a stage.
7 */
8export interface StageProps {
9 /**
10 * Default AWS environment (account/region) for `Stack`s in this `Stage`.
11 *
12 * Stacks defined inside this `Stage` with either `region` or `account` missing
13 * from its env will use the corresponding field given here.
14 *
15 * If either `region` or `account`is is not configured for `Stack` (either on
16 * the `Stack` itself or on the containing `Stage`), the Stack will be
17 * *environment-agnostic*.
18 *
19 * Environment-agnostic stacks can be deployed to any environment, may not be
20 * able to take advantage of all features of the CDK. For example, they will
21 * not be able to use environmental context lookups, will not automatically
22 * translate Service Principals to the right format based on the environment's
23 * AWS partition, and other such enhancements.
24 *
25 * @example
26 *
27 * // Use a concrete account and region to deploy this Stage to
28 * new Stage(app, 'Stage1', {
29 * env: { account: '123456789012', region: 'us-east-1' },
30 * });
31 *
32 * // Use the CLI's current credentials to determine the target environment
33 * new Stage(app, 'Stage2', {
34 * env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
35 * });
36 *
37 * @default - The environments should be configured on the `Stack`s.
38 */
39 readonly env?: Environment;
40 /**
41 * The output directory into which to emit synthesized artifacts.
42 *
43 * Can only be specified if this stage is the root stage (the app). If this is
44 * specified and this stage is nested within another stage, an error will be
45 * thrown.
46 *
47 * @default - for nested stages, outdir will be determined as a relative
48 * directory to the outdir of the app. For apps, if outdir is not specified, a
49 * temporary directory will be created.
50 */
51 readonly outdir?: string;
52}
53/**
54 * An abstract application modeling unit consisting of Stacks that should be
55 * deployed together.
56 *
57 * Derive a subclass of `Stage` and use it to model a single instance of your
58 * application.
59 *
60 * You can then instantiate your subclass multiple times to model multiple
61 * copies of your application which should be be deployed to different
62 * environments.
63 */
64export declare class Stage extends CoreConstruct {
65 /**
66 * Return the stage this construct is contained with, if available. If called
67 * on a nested stage, returns its parent.
68 *
69 */
70 static of(construct: IConstruct): Stage | undefined;
71 /**
72 * Test whether the given construct is a stage.
73 *
74 */
75 static isStage(x: any): x is Stage;
76 /**
77 * The default region for all resources defined within this stage.
78 *
79 */
80 readonly region?: string;
81 /**
82 * The default account for all resources defined within this stage.
83 *
84 */
85 readonly account?: string;
86 /**
87 * The cloud assembly builder that is being used for this App
88 *
89 * @internal
90 */
91 readonly _assemblyBuilder: cxapi.CloudAssemblyBuilder;
92 /**
93 * The name of the stage. Based on names of the parent stages separated by
94 * hypens.
95 *
96 */
97 readonly stageName: string;
98 /**
99 * The parent stage or `undefined` if this is the app.
100 * *
101 */
102 readonly parentStage?: Stage;
103 /**
104 * The cached assembly if it was already built
105 */
106 private assembly?;
107 constructor(scope: Construct, id: string, props?: StageProps);
108 /**
109 * The cloud assembly output directory.
110 */
111 get outdir(): string;
112 /**
113 * The cloud assembly asset output directory.
114 */
115 get assetOutdir(): string;
116 /**
117 * Artifact ID of the assembly if it is a nested stage. The root stage (app)
118 * will return an empty string.
119 *
120 * Derived from the construct path.
121 *
122 */
123 get artifactId(): string;
124 /**
125 * Synthesize this stage into a cloud assembly.
126 *
127 * Once an assembly has been synthesized, it cannot be modified. Subsequent
128 * calls will return the same assembly.
129 */
130 synth(options?: StageSynthesisOptions): cxapi.CloudAssembly;
131 private createBuilder;
132}
133/**
134 * Options for assembly synthesis.
135 */
136export interface StageSynthesisOptions {
137 /**
138 * Should we skip construct validation.
139 * @default - false
140 */
141 readonly skipValidation?: boolean;
142 /**
143 * Whether the stack should be validated after synthesis to check for error metadata
144 *
145 * @default - false
146 */
147 readonly validateOnSynthesis?: boolean;
148 /**
149 * Force a re-synth, even if the stage has already been synthesized.
150 * This is used by tests to allow for incremental verification of the output.
151 * Do not use in production.
152 * @default false
153 */
154 readonly force?: boolean;
155}