1 | import * as cxschema from '@aws-cdk/cloud-assembly-schema';
|
2 | import * as cxapi from '@aws-cdk/cx-api';
|
3 | import { IConstruct, Construct } from 'constructs';
|
4 | import { ArnComponents, ArnFormat } from './arn';
|
5 | import { DockerImageAssetLocation, DockerImageAssetSource, FileAssetLocation, FileAssetSource } from './assets';
|
6 | import { CfnElement } from './cfn-element';
|
7 | import { CfnResource } from './cfn-resource';
|
8 | import { ISynthesisSession } from './construct-compat';
|
9 | import { Environment } from './environment';
|
10 | import { Construct as CoreConstruct } from './construct-compat';
|
11 | export declare const STACK_RESOURCE_LIMIT_CONTEXT = "@aws-cdk/core:stackResourceLimit";
|
12 | export interface StackProps {
|
13 | /**
|
14 | * A description of the stack.
|
15 | *
|
16 | * @default - No description.
|
17 | */
|
18 | readonly description?: string;
|
19 | /**
|
20 | * The AWS environment (account/region) where this stack will be deployed.
|
21 | *
|
22 | * Set the `region`/`account` fields of `env` to either a concrete value to
|
23 | * select the indicated environment (recommended for production stacks), or to
|
24 | * the values of environment variables
|
25 | * `CDK_DEFAULT_REGION`/`CDK_DEFAULT_ACCOUNT` to let the target environment
|
26 | * depend on the AWS credentials/configuration that the CDK CLI is executed
|
27 | * under (recommended for development stacks).
|
28 | *
|
29 | * If the `Stack` is instantiated inside a `Stage`, any undefined
|
30 | * `region`/`account` fields from `env` will default to the same field on the
|
31 | * encompassing `Stage`, if configured there.
|
32 | *
|
33 | * If either `region` or `account` are not set nor inherited from `Stage`, the
|
34 | * Stack will be considered "*environment-agnostic*"". Environment-agnostic
|
35 | * stacks can be deployed to any environment but may not be able to take
|
36 | * advantage of all features of the CDK. For example, they will not be able to
|
37 | * use environmental context lookups such as `ec2.Vpc.fromLookup` and will not
|
38 | * automatically translate Service Principals to the right format based on the
|
39 | * environment's AWS partition, and other such enhancements.
|
40 | *
|
41 | * @example
|
42 | *
|
43 | * // Use a concrete account and region to deploy this stack to:
|
44 | * // `.account` and `.region` will simply return these values.
|
45 | * new Stack(app, 'Stack1', {
|
46 | * env: {
|
47 | * account: '123456789012',
|
48 | * region: 'us-east-1'
|
49 | * },
|
50 | * });
|
51 | *
|
52 | * // Use the CLI's current credentials to determine the target environment:
|
53 | * // `.account` and `.region` will reflect the account+region the CLI
|
54 | * // is configured to use (based on the user CLI credentials)
|
55 | * new Stack(app, 'Stack2', {
|
56 | * env: {
|
57 | * account: process.env.CDK_DEFAULT_ACCOUNT,
|
58 | * region: process.env.CDK_DEFAULT_REGION
|
59 | * },
|
60 | * });
|
61 | *
|
62 | * // Define multiple stacks stage associated with an environment
|
63 | * const myStage = new Stage(app, 'MyStage', {
|
64 | * env: {
|
65 | * account: '123456789012',
|
66 | * region: 'us-east-1'
|
67 | * }
|
68 | * });
|
69 | *
|
70 | * // both of these stacks will use the stage's account/region:
|
71 | * // `.account` and `.region` will resolve to the concrete values as above
|
72 | * new MyStack(myStage, 'Stack1');
|
73 | * new YourStack(myStage, 'Stack2');
|
74 | *
|
75 | * // Define an environment-agnostic stack:
|
76 | * // `.account` and `.region` will resolve to `{ "Ref": "AWS::AccountId" }` and `{ "Ref": "AWS::Region" }` respectively.
|
77 | * // which will only resolve to actual values by CloudFormation during deployment.
|
78 | * new MyStack(app, 'Stack1');
|
79 | *
|
80 | * @default - The environment of the containing `Stage` if available,
|
81 | * otherwise create the stack will be environment-agnostic.
|
82 | */
|
83 | readonly env?: Environment;
|
84 | /**
|
85 | * Name to deploy the stack with
|
86 | *
|
87 | * @default - Derived from construct path.
|
88 | */
|
89 | readonly stackName?: string;
|
90 | /**
|
91 | * Stack tags that will be applied to all the taggable resources and the stack itself.
|
92 | *
|
93 | * @default {}
|
94 | */
|
95 | readonly tags?: {
|
96 | [key: string]: string;
|
97 | };
|
98 | /**
|
99 | * Synthesis method to use while deploying this stack
|
100 | *
|
101 | * @default - `DefaultStackSynthesizer` if the `@aws-cdk/core:newStyleStackSynthesis` feature flag
|
102 | * is set, `LegacyStackSynthesizer` otherwise.
|
103 | */
|
104 | readonly synthesizer?: IStackSynthesizer;
|
105 | /**
|
106 | * Whether to enable termination protection for this stack.
|
107 | *
|
108 | * @default false
|
109 | */
|
110 | readonly terminationProtection?: boolean;
|
111 | /**
|
112 | * Include runtime versioning information in this Stack
|
113 | *
|
114 | * @default `analyticsReporting` setting of containing `App`, or value of
|
115 | * 'aws:cdk:version-reporting' context key
|
116 | */
|
117 | readonly analyticsReporting?: boolean;
|
118 | }
|
119 | /**
|
120 | * A root construct which represents a single CloudFormation stack.
|
121 | */
|
122 | export declare class Stack extends CoreConstruct implements ITaggable {
|
123 | /**
|
124 | * Return whether the given object is a Stack.
|
125 | *
|
126 | * We do attribute detection since we can't reliably use 'instanceof'.
|
127 | */
|
128 | static isStack(x: any): x is Stack;
|
129 | /**
|
130 | * Looks up the first stack scope in which `construct` is defined. Fails if there is no stack up the tree.
|
131 | * @param construct The construct to start the search from.
|
132 | */
|
133 | static of(construct: IConstruct): Stack;
|
134 | /**
|
135 | * Tags to be applied to the stack.
|
136 | */
|
137 | readonly tags: TagManager;
|
138 | /**
|
139 | * Options for CloudFormation template (like version, transform, description).
|
140 | */
|
141 | readonly templateOptions: ITemplateOptions;
|
142 | /**
|
143 | * The AWS region into which this stack will be deployed (e.g. `us-west-2`).
|
144 | *
|
145 | * This value is resolved according to the following rules:
|
146 | *
|
147 | * 1. The value provided to `env.region` when the stack is defined. This can
|
148 | * either be a concerete region (e.g. `us-west-2`) or the `Aws.region`
|
149 | * token.
|
150 | * 3. `Aws.region`, which is represents the CloudFormation intrinsic reference
|
151 | * `{ "Ref": "AWS::Region" }` encoded as a string token.
|
152 | *
|
153 | * Preferably, you should use the return value as an opaque string and not
|
154 | * attempt to parse it to implement your logic. If you do, you must first
|
155 | * check that it is a concerete value an not an unresolved token. If this
|
156 | * value is an unresolved token (`Token.isUnresolved(stack.region)` returns
|
157 | * `true`), this implies that the user wishes that this stack will synthesize
|
158 | * into a **region-agnostic template**. In this case, your code should either
|
159 | * fail (throw an error, emit a synth error using `Annotations.of(construct).addError()`) or
|
160 | * implement some other region-agnostic behavior.
|
161 | */
|
162 | readonly region: string;
|
163 | /**
|
164 | * The AWS account into which this stack will be deployed.
|
165 | *
|
166 | * This value is resolved according to the following rules:
|
167 | *
|
168 | * 1. The value provided to `env.account` when the stack is defined. This can
|
169 | * either be a concerete account (e.g. `585695031111`) or the
|
170 | * `Aws.accountId` token.
|
171 | * 3. `Aws.accountId`, which represents the CloudFormation intrinsic reference
|
172 | * `{ "Ref": "AWS::AccountId" }` encoded as a string token.
|
173 | *
|
174 | * Preferably, you should use the return value as an opaque string and not
|
175 | * attempt to parse it to implement your logic. If you do, you must first
|
176 | * check that it is a concerete value an not an unresolved token. If this
|
177 | * value is an unresolved token (`Token.isUnresolved(stack.account)` returns
|
178 | * `true`), this implies that the user wishes that this stack will synthesize
|
179 | * into a **account-agnostic template**. In this case, your code should either
|
180 | * fail (throw an error, emit a synth error using `Annotations.of(construct).addError()`) or
|
181 | * implement some other region-agnostic behavior.
|
182 | */
|
183 | readonly account: string;
|
184 | /**
|
185 | * The environment coordinates in which this stack is deployed. In the form
|
186 | * `aws://account/region`. Use `stack.account` and `stack.region` to obtain
|
187 | * the specific values, no need to parse.
|
188 | *
|
189 | * You can use this value to determine if two stacks are targeting the same
|
190 | * environment.
|
191 | *
|
192 | * If either `stack.account` or `stack.region` are not concrete values (e.g.
|
193 | * `Aws.account` or `Aws.region`) the special strings `unknown-account` and/or
|
194 | * `unknown-region` will be used respectively to indicate this stack is
|
195 | * region/account-agnostic.
|
196 | */
|
197 | readonly environment: string;
|
198 | /**
|
199 | * Whether termination protection is enabled for this stack.
|
200 | */
|
201 | readonly terminationProtection?: boolean;
|
202 | /**
|
203 | * If this is a nested stack, this represents its `AWS::CloudFormation::Stack`
|
204 | * resource. `undefined` for top-level (non-nested) stacks.
|
205 | *
|
206 | */
|
207 | readonly nestedStackResource?: CfnResource;
|
208 | /**
|
209 | * The name of the CloudFormation template file emitted to the output
|
210 | * directory during synthesis.
|
211 | *
|
212 | * Example value: `MyStack.template.json`
|
213 | */
|
214 | readonly templateFile: string;
|
215 | /**
|
216 | * The ID of the cloud assembly artifact for this stack.
|
217 | */
|
218 | readonly artifactId: string;
|
219 | /**
|
220 | * Synthesis method for this stack
|
221 | *
|
222 | */
|
223 | readonly synthesizer: IStackSynthesizer;
|
224 | /**
|
225 | * Whether version reporting is enabled for this stack
|
226 | *
|
227 | * Controls whether the CDK Metadata resource is injected
|
228 | *
|
229 | * @internal
|
230 | */
|
231 | readonly _versionReportingEnabled: boolean;
|
232 | /**
|
233 | * Logical ID generation strategy
|
234 | */
|
235 | private readonly _logicalIds;
|
236 | /**
|
237 | * Other stacks this stack depends on
|
238 | */
|
239 | private readonly _stackDependencies;
|
240 | /**
|
241 | * Lists all missing contextual information.
|
242 | * This is returned when the stack is synthesized under the 'missing' attribute
|
243 | * and allows tooling to obtain the context and re-synthesize.
|
244 | */
|
245 | private readonly _missingContext;
|
246 | private readonly _stackName;
|
247 | /**
|
248 | * Creates a new stack.
|
249 | *
|
250 | * @param scope Parent of this stack, usually an `App` or a `Stage`, but could be any construct.
|
251 | * @param id The construct ID of this stack. If `stackName` is not explicitly
|
252 | * defined, this id (and any parent IDs) will be used to determine the
|
253 | * physical ID of the stack.
|
254 | * @param props Stack properties.
|
255 | */
|
256 | constructor(scope?: Construct, id?: string, props?: StackProps);
|
257 | /**
|
258 | * Resolve a tokenized value in the context of the current stack.
|
259 | */
|
260 | resolve(obj: any): any;
|
261 | /**
|
262 | * Convert an object, potentially containing tokens, to a JSON string
|
263 | */
|
264 | toJsonString(obj: any, space?: number): string;
|
265 | /**
|
266 | * DEPRECATED
|
267 | * @deprecated use `reportMissingContextKey()`
|
268 | */
|
269 | reportMissingContext(report: cxapi.MissingContext): void;
|
270 | /**
|
271 | * Indicate that a context key was expected
|
272 | *
|
273 | * Contains instructions which will be emitted into the cloud assembly on how
|
274 | * the key should be supplied.
|
275 | *
|
276 | * @param report The set of parameters needed to obtain the context
|
277 | */
|
278 | reportMissingContextKey(report: cxschema.MissingContext): void;
|
279 | /**
|
280 | * Rename a generated logical identities
|
281 | *
|
282 | * To modify the naming scheme strategy, extend the `Stack` class and
|
283 | * override the `allocateLogicalId` method.
|
284 | */
|
285 | renameLogicalId(oldId: string, newId: string): void;
|
286 | /**
|
287 | * Allocates a stack-unique CloudFormation-compatible logical identity for a
|
288 | * specific resource.
|
289 | *
|
290 | * This method is called when a `CfnElement` is created and used to render the
|
291 | * initial logical identity of resources. Logical ID renames are applied at
|
292 | * this stage.
|
293 | *
|
294 | * This method uses the protected method `allocateLogicalId` to render the
|
295 | * logical ID for an element. To modify the naming scheme, extend the `Stack`
|
296 | * class and override this method.
|
297 | *
|
298 | * @param element The CloudFormation element for which a logical identity is
|
299 | * needed.
|
300 | */
|
301 | getLogicalId(element: CfnElement): string;
|
302 | /**
|
303 | * Add a dependency between this stack and another stack.
|
304 | *
|
305 | * This can be used to define dependencies between any two stacks within an
|
306 | * app, and also supports nested stacks.
|
307 | */
|
308 | addDependency(target: Stack, reason?: string): void;
|
309 | /**
|
310 | * Return the stacks this stack depends on
|
311 | */
|
312 | get dependencies(): Stack[];
|
313 | /**
|
314 | * The concrete CloudFormation physical stack name.
|
315 | *
|
316 | * This is either the name defined explicitly in the `stackName` prop or
|
317 | * allocated based on the stack's location in the construct tree. Stacks that
|
318 | * are directly defined under the app use their construct `id` as their stack
|
319 | * name. Stacks that are defined deeper within the tree will use a hashed naming
|
320 | * scheme based on the construct path to ensure uniqueness.
|
321 | *
|
322 | * If you wish to obtain the deploy-time AWS::StackName intrinsic,
|
323 | * you can use `Aws.stackName` directly.
|
324 | */
|
325 | get stackName(): string;
|
326 | /**
|
327 | * The partition in which this stack is defined
|
328 | */
|
329 | get partition(): string;
|
330 | /**
|
331 | * The Amazon domain suffix for the region in which this stack is defined
|
332 | */
|
333 | get urlSuffix(): string;
|
334 | /**
|
335 | * The ID of the stack
|
336 | *
|
337 | * @example
|
338 | * // After resolving, looks like
|
339 | * 'arn:aws:cloudformation:us-west-2:123456789012:stack/teststack/51af3dc0-da77-11e4-872e-1234567db123'
|
340 | */
|
341 | get stackId(): string;
|
342 | /**
|
343 | * Returns the list of notification Amazon Resource Names (ARNs) for the current stack.
|
344 | */
|
345 | get notificationArns(): string[];
|
346 | /**
|
347 | * Indicates if this is a nested stack, in which case `parentStack` will include a reference to it's parent.
|
348 | */
|
349 | get nested(): boolean;
|
350 | /**
|
351 | * Creates an ARN from components.
|
352 | *
|
353 | * If `partition`, `region` or `account` are not specified, the stack's
|
354 | * partition, region and account will be used.
|
355 | *
|
356 | * If any component is the empty string, an empty string will be inserted
|
357 | * into the generated ARN at the location that component corresponds to.
|
358 | *
|
359 | * The ARN will be formatted as follows:
|
360 | *
|
361 | * arn:{partition}:{service}:{region}:{account}:{resource}{sep}}{resource-name}
|
362 | *
|
363 | * The required ARN pieces that are omitted will be taken from the stack that
|
364 | * the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope
|
365 | * can be 'undefined'.
|
366 | */
|
367 | formatArn(components: ArnComponents): string;
|
368 | /**
|
369 | * Given an ARN, parses it and returns components.
|
370 | *
|
371 | * IF THE ARN IS A CONCRETE STRING...
|
372 | *
|
373 | * ...it will be parsed and validated. The separator (`sep`) will be set to '/'
|
374 | * if the 6th component includes a '/', in which case, `resource` will be set
|
375 | * to the value before the '/' and `resourceName` will be the rest. In case
|
376 | * there is no '/', `resource` will be set to the 6th components and
|
377 | * `resourceName` will be set to the rest of the string.
|
378 | *
|
379 | * IF THE ARN IS A TOKEN...
|
380 | *
|
381 | * ...it cannot be validated, since we don't have the actual value yet at the
|
382 | * time of this function call. You will have to supply `sepIfToken` and
|
383 | * whether or not ARNs of the expected format usually have resource names
|
384 | * in order to parse it properly. The resulting `ArnComponents` object will
|
385 | * contain tokens for the subexpressions of the ARN, not string literals.
|
386 | *
|
387 | * If the resource name could possibly contain the separator char, the actual
|
388 | * resource name cannot be properly parsed. This only occurs if the separator
|
389 | * char is '/', and happens for example for S3 object ARNs, IAM Role ARNs,
|
390 | * IAM OIDC Provider ARNs, etc. To properly extract the resource name from a
|
391 | * Tokenized ARN, you must know the resource type and call
|
392 | * `Arn.extractResourceName`.
|
393 | *
|
394 | * @param arn The ARN string to parse
|
395 | * @param sepIfToken The separator used to separate resource from resourceName
|
396 | * @param hasName Whether there is a name component in the ARN at all. For
|
397 | * example, SNS Topics ARNs have the 'resource' component contain the topic
|
398 | * name, and no 'resourceName' component.
|
399 | *
|
400 | * @returns an ArnComponents object which allows access to the various
|
401 | * components of the ARN.
|
402 | *
|
403 | * @returns an ArnComponents object which allows access to the various
|
404 | * components of the ARN.
|
405 | *
|
406 | * @deprecated use splitArn instead
|
407 | */
|
408 | parseArn(arn: string, sepIfToken?: string, hasName?: boolean): ArnComponents;
|
409 | /**
|
410 | * Splits the provided ARN into its components.
|
411 | * Works both if 'arn' is a string like 'arn:aws:s3:::bucket',
|
412 | * and a Token representing a dynamic CloudFormation expression
|
413 | * (in which case the returned components will also be dynamic CloudFormation expressions,
|
414 | * encoded as Tokens).
|
415 | *
|
416 | * @param arn the ARN to split into its components
|
417 | * @param arnFormat the expected format of 'arn' - depends on what format the service 'arn' represents uses
|
418 | */
|
419 | splitArn(arn: string, arnFormat: ArnFormat): ArnComponents;
|
420 | /**
|
421 | * Returns the list of AZs that are available in the AWS environment
|
422 | * (account/region) associated with this stack.
|
423 | *
|
424 | * If the stack is environment-agnostic (either account and/or region are
|
425 | * tokens), this property will return an array with 2 tokens that will resolve
|
426 | * at deploy-time to the first two availability zones returned from CloudFormation's
|
427 | * `Fn::GetAZs` intrinsic function.
|
428 | *
|
429 | * If they are not available in the context, returns a set of dummy values and
|
430 | * reports them as missing, and let the CLI resolve them by calling EC2
|
431 | * `DescribeAvailabilityZones` on the target environment.
|
432 | *
|
433 | * To specify a different strategy for selecting availability zones override this method.
|
434 | */
|
435 | get availabilityZones(): string[];
|
436 | /**
|
437 | * Register a file asset on this Stack
|
438 | *
|
439 | * @deprecated Use `stack.synthesizer.addFileAsset()` if you are calling,
|
440 | * and a different IStackSynthesizer class if you are implementing.
|
441 | */
|
442 | addFileAsset(asset: FileAssetSource): FileAssetLocation;
|
443 | /**
|
444 | * Register a docker image asset on this Stack
|
445 | *
|
446 | * @deprecated Use `stack.synthesizer.addDockerImageAsset()` if you are calling,
|
447 | * and a different `IStackSynthesizer` class if you are implementing.
|
448 | */
|
449 | addDockerImageAsset(asset: DockerImageAssetSource): DockerImageAssetLocation;
|
450 | /**
|
451 | * If this is a nested stack, returns it's parent stack.
|
452 | */
|
453 | get nestedStackParent(): Stack | undefined;
|
454 | /**
|
455 | * Returns the parent of a nested stack.
|
456 | *
|
457 | * @deprecated use `nestedStackParent`
|
458 | */
|
459 | get parentStack(): Stack | undefined;
|
460 | /**
|
461 | * Add a Transform to this stack. A Transform is a macro that AWS
|
462 | * CloudFormation uses to process your template.
|
463 | *
|
464 | * Duplicate values are removed when stack is synthesized.
|
465 | *
|
466 | * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
|
467 | * @param transform The transform to add
|
468 | *
|
469 | * @example
|
470 | * declare const stack: Stack;
|
471 | *
|
472 | * stack.addTransform('AWS::Serverless-2016-10-31')
|
473 | */
|
474 | addTransform(transform: string): void;
|
475 | /**
|
476 | * Called implicitly by the `addDependency` helper function in order to
|
477 | * realize a dependency between two top-level stacks at the assembly level.
|
478 | *
|
479 | * Use `stack.addDependency` to define the dependency between any two stacks,
|
480 | * and take into account nested stack relationships.
|
481 | *
|
482 | * @internal
|
483 | */
|
484 | _addAssemblyDependency(target: Stack, reason?: string): void;
|
485 | /**
|
486 | * Synthesizes the cloudformation template into a cloud assembly.
|
487 | * @internal
|
488 | */
|
489 | _synthesizeTemplate(session: ISynthesisSession, lookupRoleArn?: string): void;
|
490 | /**
|
491 | * Look up a fact value for the given fact for the region of this stack
|
492 | *
|
493 | * Will return a definite value only if the region of the current stack is resolved.
|
494 | * If not, a lookup map will be added to the stack and the lookup will be done at
|
495 | * CDK deployment time.
|
496 | *
|
497 | * What regions will be included in the lookup map is controlled by the
|
498 | * `@aws-cdk/core:target-partitions` context value: it must be set to a list
|
499 | * of partitions, and only regions from the given partitions will be included.
|
500 | * If no such context key is set, all regions will be included.
|
501 | *
|
502 | * This function is intended to be used by construct library authors. Application
|
503 | * builders can rely on the abstractions offered by construct libraries and do
|
504 | * not have to worry about regional facts.
|
505 | *
|
506 | * If `defaultValue` is not given, it is an error if the fact is unknown for
|
507 | * the given region.
|
508 | */
|
509 | regionalFact(factName: string, defaultValue?: string): string;
|
510 | /**
|
511 | * Create a CloudFormation Export for a value
|
512 | *
|
513 | * Returns a string representing the corresponding `Fn.importValue()`
|
514 | * expression for this Export. You can control the name for the export by
|
515 | * passing the `name` option.
|
516 | *
|
517 | * If you don't supply a value for `name`, the value you're exporting must be
|
518 | * a Resource attribute (for example: `bucket.bucketName`) and it will be
|
519 | * given the same name as the automatic cross-stack reference that would be created
|
520 | * if you used the attribute in another Stack.
|
521 | *
|
522 | * One of the uses for this method is to *remove* the relationship between
|
523 | * two Stacks established by automatic cross-stack references. It will
|
524 | * temporarily ensure that the CloudFormation Export still exists while you
|
525 | * remove the reference from the consuming stack. After that, you can remove
|
526 | * the resource and the manual export.
|
527 | *
|
528 | * ## Example
|
529 | *
|
530 | * Here is how the process works. Let's say there are two stacks,
|
531 | * `producerStack` and `consumerStack`, and `producerStack` has a bucket
|
532 | * called `bucket`, which is referenced by `consumerStack` (perhaps because
|
533 | * an AWS Lambda Function writes into it, or something like that).
|
534 | *
|
535 | * It is not safe to remove `producerStack.bucket` because as the bucket is being
|
536 | * deleted, `consumerStack` might still be using it.
|
537 | *
|
538 | * Instead, the process takes two deployments:
|
539 | *
|
540 | * ### Deployment 1: break the relationship
|
541 | *
|
542 | * - Make sure `consumerStack` no longer references `bucket.bucketName` (maybe the consumer
|
543 | * stack now uses its own bucket, or it writes to an AWS DynamoDB table, or maybe you just
|
544 | * remove the Lambda Function altogether).
|
545 | * - In the `ProducerStack` class, call `this.exportValue(this.bucket.bucketName)`. This
|
546 | * will make sure the CloudFormation Export continues to exist while the relationship
|
547 | * between the two stacks is being broken.
|
548 | * - Deploy (this will effectively only change the `consumerStack`, but it's safe to deploy both).
|
549 | *
|
550 | * ### Deployment 2: remove the bucket resource
|
551 | *
|
552 | * - You are now free to remove the `bucket` resource from `producerStack`.
|
553 | * - Don't forget to remove the `exportValue()` call as well.
|
554 | * - Deploy again (this time only the `producerStack` will be changed -- the bucket will be deleted).
|
555 | */
|
556 | exportValue(exportedValue: any, options?: ExportValueOptions): string;
|
557 | /**
|
558 | * Returns the naming scheme used to allocate logical IDs. By default, uses
|
559 | * the `HashedAddressingScheme` but this method can be overridden to customize
|
560 | * this behavior.
|
561 | *
|
562 | * In order to make sure logical IDs are unique and stable, we hash the resource
|
563 | * construct tree path (i.e. toplevel/secondlevel/.../myresource) and add it as
|
564 | * a suffix to the path components joined without a separator (CloudFormation
|
565 | * IDs only allow alphanumeric characters).
|
566 | *
|
567 | * The result will be:
|
568 | *
|
569 | * <path.join('')><md5(path.join('/')>
|
570 | * "human" "hash"
|
571 | *
|
572 | * If the "human" part of the ID exceeds 240 characters, we simply trim it so
|
573 | * the total ID doesn't exceed CloudFormation's 255 character limit.
|
574 | *
|
575 | * We only take 8 characters from the md5 hash (0.000005 chance of collision).
|
576 | *
|
577 | * Special cases:
|
578 | *
|
579 | * - If the path only contains a single component (i.e. it's a top-level
|
580 | * resource), we won't add the hash to it. The hash is not needed for
|
581 | * disamiguation and also, it allows for a more straightforward migration an
|
582 | * existing CloudFormation template to a CDK stack without logical ID changes
|
583 | * (or renames).
|
584 | * - For aesthetic reasons, if the last components of the path are the same
|
585 | * (i.e. `L1/L2/Pipeline/Pipeline`), they will be de-duplicated to make the
|
586 | * resulting human portion of the ID more pleasing: `L1L2Pipeline<HASH>`
|
587 | * instead of `L1L2PipelinePipeline<HASH>`
|
588 | * - If a component is named "Default" it will be omitted from the path. This
|
589 | * allows refactoring higher level abstractions around constructs without affecting
|
590 | * the IDs of already deployed resources.
|
591 | * - If a component is named "Resource" it will be omitted from the user-visible
|
592 | * path, but included in the hash. This reduces visual noise in the human readable
|
593 | * part of the identifier.
|
594 | *
|
595 | * @param cfnElement The element for which the logical ID is allocated.
|
596 | */
|
597 | protected allocateLogicalId(cfnElement: CfnElement): string;
|
598 | /**
|
599 | * Validate stack name
|
600 | *
|
601 | * CloudFormation stack names can include dashes in addition to the regular identifier
|
602 | * character classes, and we don't allow one of the magic markers.
|
603 | *
|
604 | * @internal
|
605 | */
|
606 | protected _validateId(name: string): void;
|
607 | /**
|
608 | * Returns the CloudFormation template for this stack by traversing
|
609 | * the tree and invoking _toCloudFormation() on all Entity objects.
|
610 | *
|
611 | * @internal
|
612 | */
|
613 | protected _toCloudFormation(): any;
|
614 | /**
|
615 | * Deprecated.
|
616 | *
|
617 | * @see https://github.com/aws/aws-cdk/pull/7187
|
618 | * @returns reference itself without any change
|
619 | * @deprecated cross reference handling has been moved to `App.prepare()`.
|
620 | */
|
621 | protected prepareCrossReference(_sourceStack: Stack, reference: Reference): IResolvable;
|
622 | /**
|
623 | * Determine the various stack environment attributes.
|
624 | *
|
625 | */
|
626 | private parseEnvironment;
|
627 | /**
|
628 | * Maximum number of resources in the stack
|
629 | *
|
630 | * Set to 0 to mean "unlimited".
|
631 | */
|
632 | private get maxResources();
|
633 | /**
|
634 | * Check whether this stack has a (transitive) dependency on another stack
|
635 | *
|
636 | * Returns the list of reasons on the dependency path, or undefined
|
637 | * if there is no dependency.
|
638 | */
|
639 | private stackDependencyReasons;
|
640 | /**
|
641 | * Calculate the stack name based on the construct path
|
642 | *
|
643 | * The stack name is the name under which we'll deploy the stack,
|
644 | * and incorporates containing Stage names by default.
|
645 | *
|
646 | * Generally this looks a lot like how logical IDs are calculated.
|
647 | * The stack name is calculated based on the construct root path,
|
648 | * as follows:
|
649 | *
|
650 | * - Path is calculated with respect to containing App or Stage (if any)
|
651 | * - If the path is one component long just use that component, otherwise
|
652 | * combine them with a hash.
|
653 | *
|
654 | * Since the hash is quite ugly and we'd like to avoid it if possible -- but
|
655 | * we can't anymore in the general case since it has been written into legacy
|
656 | * stacks. The introduction of Stages makes it possible to make this nicer however.
|
657 | * When a Stack is nested inside a Stage, we use the path components below the
|
658 | * Stage, and prefix the path components of the Stage before it.
|
659 | */
|
660 | private generateStackName;
|
661 | /**
|
662 | * The artifact ID for this stack
|
663 | *
|
664 | * Stack artifact ID is unique within the App's Cloud Assembly.
|
665 | */
|
666 | private generateStackArtifactId;
|
667 | /**
|
668 | * Generate an ID with respect to the given container construct.
|
669 | */
|
670 | private generateStackId;
|
671 | /**
|
672 | * Indicates whether the stack requires bundling or not
|
673 | */
|
674 | get bundlingRequired(): boolean;
|
675 | }
|
676 | /**
|
677 | * CloudFormation template options for a stack.
|
678 | */
|
679 | export interface ITemplateOptions {
|
680 | /**
|
681 | * Gets or sets the description of this stack.
|
682 | * If provided, it will be included in the CloudFormation template's "Description" attribute.
|
683 | */
|
684 | description?: string;
|
685 | /**
|
686 | * Gets or sets the AWSTemplateFormatVersion field of the CloudFormation template.
|
687 | */
|
688 | templateFormatVersion?: string;
|
689 | /**
|
690 | * Gets or sets the top-level template transform for this stack (e.g. "AWS::Serverless-2016-10-31").
|
691 | *
|
692 | * @deprecated use `transforms` instead.
|
693 | */
|
694 | transform?: string;
|
695 | /**
|
696 | * Gets or sets the top-level template transform(s) for this stack (e.g. `["AWS::Serverless-2016-10-31"]`).
|
697 | */
|
698 | transforms?: string[];
|
699 | /**
|
700 | * Metadata associated with the CloudFormation template.
|
701 | */
|
702 | metadata?: {
|
703 | [key: string]: any;
|
704 | };
|
705 | }
|
706 | /**
|
707 | * Return the construct root path of the given construct relative to the given ancestor
|
708 | *
|
709 | * If no ancestor is given or the ancestor is not found, return the entire root path.
|
710 | */
|
711 | export declare function rootPathTo(construct: IConstruct, ancestor?: IConstruct): IConstruct[];
|
712 | /**
|
713 | * Options for the `stack.exportValue()` method
|
714 | */
|
715 | export interface ExportValueOptions {
|
716 | /**
|
717 | * The name of the export to create
|
718 | *
|
719 | * @default - A name is automatically chosen
|
720 | */
|
721 | readonly name?: string;
|
722 | }
|
723 | import { Reference } from './reference';
|
724 | import { IResolvable } from './resolvable';
|
725 | import { IStackSynthesizer } from './stack-synthesizers';
|
726 | import { ITaggable, TagManager } from './tag-manager';
|