UNPKG

11.3 kBTypeScriptView Raw
1import * as cxapi from '@aws-cdk/cx-api';
2import * as cdk_assets from 'cdk-assets';
3import { type BuildAssetsOptions, type PublishAssetsOptions } from './asset-publishing';
4import { type ResourceIdentifierSummaries, ResourcesToImport, Template } from './cloudformation';
5import { DeploymentMethod } from './deployment-method';
6import { DeployStackResult } from './deployment-result';
7import { type RootTemplateWithNestedStacks } from './nested-stack-helpers';
8import type { SdkProvider } from '../aws-auth/sdk-provider';
9import { EnvironmentAccess } from '../environment-access';
10import { HotswapMode, HotswapPropertyOverrides } from '../hotswap/common';
11import type { Tag } from '../tags';
12import { StackActivityProgress } from '../util/cloudformation/stack-activity-monitor';
13export interface DeployStackOptions {
14 /**
15 * Stack to deploy
16 */
17 readonly stack: cxapi.CloudFormationStackArtifact;
18 /**
19 * Execution role for the deployment (pass through to CloudFormation)
20 *
21 * @default - Current role
22 */
23 readonly roleArn?: string;
24 /**
25 * Topic ARNs to send a message when deployment finishes (pass through to CloudFormation)
26 *
27 * @default - No notifications
28 */
29 readonly notificationArns?: string[];
30 /**
31 * Override name under which stack will be deployed
32 *
33 * @default - Use artifact default
34 */
35 readonly deployName?: string;
36 /**
37 * Don't show stack deployment events, just wait
38 *
39 * @default false
40 */
41 readonly quiet?: boolean;
42 /**
43 * Name of the toolkit stack, if not the default name
44 *
45 * @default 'CDKToolkit'
46 */
47 readonly toolkitStackName?: string;
48 /**
49 * List of asset IDs which should NOT be built or uploaded
50 *
51 * @default - Build all assets
52 */
53 readonly reuseAssets?: string[];
54 /**
55 * Stack tags (pass through to CloudFormation)
56 */
57 readonly tags?: Tag[];
58 /**
59 * Stage the change set but don't execute it
60 *
61 * @default - true
62 * @deprecated Use 'deploymentMethod' instead
63 */
64 readonly execute?: boolean;
65 /**
66 * Optional name to use for the CloudFormation change set.
67 * If not provided, a name will be generated automatically.
68 *
69 * @deprecated Use 'deploymentMethod' instead
70 */
71 readonly changeSetName?: string;
72 /**
73 * Select the deployment method (direct or using a change set)
74 *
75 * @default - Change set with default options
76 */
77 readonly deploymentMethod?: DeploymentMethod;
78 /**
79 * Force deployment, even if the deployed template is identical to the one we are about to deploy.
80 * @default false deployment will be skipped if the template is identical
81 */
82 readonly force?: boolean;
83 /**
84 * Extra parameters for CloudFormation
85 * @default - no additional parameters will be passed to the template
86 */
87 readonly parameters?: {
88 [name: string]: string | undefined;
89 };
90 /**
91 * Use previous values for unspecified parameters
92 *
93 * If not set, all parameters must be specified for every deployment.
94 *
95 * @default true
96 */
97 readonly usePreviousParameters?: boolean;
98 /**
99 * Display mode for stack deployment progress.
100 *
101 * @default - StackActivityProgress.Bar - stack events will be displayed for
102 * the resource currently being deployed.
103 */
104 readonly progress?: StackActivityProgress;
105 /**
106 * Whether we are on a CI system
107 *
108 * @default false
109 */
110 readonly ci?: boolean;
111 /**
112 * Rollback failed deployments
113 *
114 * @default true
115 */
116 readonly rollback?: boolean;
117 readonly hotswap?: HotswapMode;
118 /**
119 * Properties that configure hotswap behavior
120 */
121 readonly hotswapPropertyOverrides?: HotswapPropertyOverrides;
122 /**
123 * The extra string to append to the User-Agent header when performing AWS SDK calls.
124 *
125 * @default - nothing extra is appended to the User-Agent header
126 */
127 readonly extraUserAgent?: string;
128 /**
129 * List of existing resources to be IMPORTED into the stack, instead of being CREATED
130 */
131 readonly resourcesToImport?: ResourcesToImport;
132 /**
133 * If present, use this given template instead of the stored one
134 *
135 * @default - Use the stored template
136 */
137 readonly overrideTemplate?: any;
138 /**
139 * Whether to build/publish assets in parallel
140 *
141 * @default true To remain backward compatible.
142 */
143 readonly assetParallelism?: boolean;
144 /**
145 * Whether to deploy if the app contains no stacks.
146 *
147 * @default false
148 */
149 ignoreNoStacks?: boolean;
150}
151export interface RollbackStackOptions {
152 /**
153 * Stack to roll back
154 */
155 readonly stack: cxapi.CloudFormationStackArtifact;
156 /**
157 * Execution role for the deployment (pass through to CloudFormation)
158 *
159 * @default - Current role
160 */
161 readonly roleArn?: string;
162 /**
163 * Don't show stack deployment events, just wait
164 *
165 * @default false
166 */
167 readonly quiet?: boolean;
168 /**
169 * Whether we are on a CI system
170 *
171 * @default false
172 */
173 readonly ci?: boolean;
174 /**
175 * Name of the toolkit stack, if not the default name
176 *
177 * @default 'CDKToolkit'
178 */
179 readonly toolkitStackName?: string;
180 /**
181 * Whether to force a rollback or not
182 *
183 * Forcing a rollback will orphan all undeletable resources.
184 *
185 * @default false
186 */
187 readonly force?: boolean;
188 /**
189 * Orphan the resources with the given logical IDs
190 *
191 * @default - No orphaning
192 */
193 readonly orphanLogicalIds?: string[];
194 /**
195 * Display mode for stack deployment progress.
196 *
197 * @default - StackActivityProgress.Bar - stack events will be displayed for
198 * the resource currently being deployed.
199 */
200 readonly progress?: StackActivityProgress;
201 /**
202 * Whether to validate the version of the bootstrap stack permissions
203 *
204 * @default true
205 */
206 readonly validateBootstrapStackVersion?: boolean;
207}
208export interface RollbackStackResult {
209 readonly notInRollbackableState?: boolean;
210 readonly success?: boolean;
211}
212interface AssetOptions {
213 /**
214 * Stack with assets to build.
215 */
216 readonly stack: cxapi.CloudFormationStackArtifact;
217 /**
218 * Execution role for the building.
219 *
220 * @default - Current role
221 */
222 readonly roleArn?: string;
223}
224export interface BuildStackAssetsOptions extends AssetOptions {
225 /**
226 * Options to pass on to `buildAssets()` function
227 */
228 readonly buildOptions?: BuildAssetsOptions;
229 /**
230 * Stack name this asset is for
231 */
232 readonly stackName?: string;
233}
234interface PublishStackAssetsOptions extends AssetOptions {
235 /**
236 * Options to pass on to `publishAsests()` function
237 */
238 readonly publishOptions?: Omit<PublishAssetsOptions, 'buildAssets'>;
239 /**
240 * Stack name this asset is for
241 */
242 readonly stackName?: string;
243}
244export interface DestroyStackOptions {
245 stack: cxapi.CloudFormationStackArtifact;
246 deployName?: string;
247 roleArn?: string;
248 quiet?: boolean;
249 force?: boolean;
250 ci?: boolean;
251}
252export interface StackExistsOptions {
253 stack: cxapi.CloudFormationStackArtifact;
254 deployName?: string;
255 tryLookupRole?: boolean;
256}
257export interface DeploymentsProps {
258 sdkProvider: SdkProvider;
259 readonly toolkitStackName?: string;
260 readonly quiet?: boolean;
261}
262/**
263 * Scope for a single set of deployments from a set of Cloud Assembly Artifacts
264 *
265 * Manages lookup of SDKs, Bootstrap stacks, etc.
266 */
267export declare class Deployments {
268 private readonly props;
269 readonly envs: EnvironmentAccess;
270 /**
271 * SDK provider for asset publishing (do not use for anything else).
272 *
273 * This SDK provider is only allowed to be used for that purpose, nothing else.
274 *
275 * It's not a different object, but the field name should imply that this
276 * object should not be used directly, except to pass to asset handling routines.
277 */
278 private readonly assetSdkProvider;
279 /**
280 * SDK provider for passing to deployStack
281 *
282 * This SDK provider is only allowed to be used for that purpose, nothing else.
283 *
284 * It's not a different object, but the field name should imply that this
285 * object should not be used directly, except to pass to `deployStack`.
286 */
287 private readonly deployStackSdkProvider;
288 private readonly publisherCache;
289 private _allowCrossAccountAssetPublishing;
290 constructor(props: DeploymentsProps);
291 /**
292 * Resolves the environment for a stack.
293 */
294 resolveEnvironment(stack: cxapi.CloudFormationStackArtifact): Promise<cxapi.Environment>;
295 readCurrentTemplateWithNestedStacks(rootStackArtifact: cxapi.CloudFormationStackArtifact, retrieveProcessedTemplate?: boolean): Promise<RootTemplateWithNestedStacks>;
296 readCurrentTemplate(stackArtifact: cxapi.CloudFormationStackArtifact): Promise<Template>;
297 resourceIdentifierSummaries(stackArtifact: cxapi.CloudFormationStackArtifact): Promise<ResourceIdentifierSummaries>;
298 deployStack(options: DeployStackOptions): Promise<DeployStackResult>;
299 rollbackStack(options: RollbackStackOptions): Promise<RollbackStackResult>;
300 destroyStack(options: DestroyStackOptions): Promise<void>;
301 stackExists(options: StackExistsOptions): Promise<boolean>;
302 private prepareAndValidateAssets;
303 /**
304 * Build all assets in a manifest
305 *
306 * @deprecated Use `buildSingleAsset` instead
307 */
308 buildAssets(asset: cxapi.AssetManifestArtifact, options: BuildStackAssetsOptions): Promise<void>;
309 /**
310 * Publish all assets in a manifest
311 *
312 * @deprecated Use `publishSingleAsset` instead
313 */
314 publishAssets(asset: cxapi.AssetManifestArtifact, options: PublishStackAssetsOptions): Promise<void>;
315 /**
316 * Build a single asset from an asset manifest
317 *
318 * If an assert manifest artifact is given, the bootstrap stack version
319 * will be validated according to the constraints in that manifest artifact.
320 * If that is not necessary, `'no-version-validation'` can be passed.
321 */
322 buildSingleAsset(assetArtifact: cxapi.AssetManifestArtifact | 'no-version-validation', assetManifest: cdk_assets.AssetManifest, asset: cdk_assets.IManifestEntry, options: BuildStackAssetsOptions): Promise<void>;
323 /**
324 * Publish a single asset from an asset manifest
325 */
326 publishSingleAsset(assetManifest: cdk_assets.AssetManifest, asset: cdk_assets.IManifestEntry, options: PublishStackAssetsOptions): Promise<void>;
327 private allowCrossAccountAssetPublishingForEnv;
328 /**
329 * Return whether a single asset has been published already
330 */
331 isSingleAssetPublished(assetManifest: cdk_assets.AssetManifest, asset: cdk_assets.IManifestEntry, options: PublishStackAssetsOptions): Promise<boolean>;
332 /**
333 * Validate that the bootstrap stack has the right version for this stack
334 *
335 * Call into envResources.validateVersion, but prepend the stack name in case of failure.
336 */
337 private validateBootstrapStackVersion;
338 private cachedPublisher;
339}
340export {};