UNPKG

4.87 kBTypeScriptView Raw
1import { Construct } from 'constructs';
2import { Construct as CoreConstruct } from './construct-compat';
3/**
4 * An element of a CloudFormation stack.
5 */
6export declare abstract class CfnElement extends CoreConstruct {
7 /**
8 * Returns `true` if a construct is a stack element (i.e. part of the
9 * synthesized cloudformation template).
10 *
11 * Uses duck-typing instead of `instanceof` to allow stack elements from different
12 * versions of this library to be included in the same stack.
13 *
14 * @returns The construct as a stack element or undefined if it is not a stack element.
15 */
16 static isCfnElement(x: any): x is CfnElement;
17 /**
18 * The logical ID for this CloudFormation stack element. The logical ID of the element
19 * is calculated from the path of the resource node in the construct tree.
20 *
21 * To override this value, use `overrideLogicalId(newLogicalId)`.
22 *
23 * @returns the logical ID as a stringified token. This value will only get
24 * resolved during synthesis.
25 */
26 readonly logicalId: string;
27 /**
28 * The stack in which this element is defined. CfnElements must be defined within a stack scope (directly or indirectly).
29 */
30 readonly stack: Stack;
31 /**
32 * An explicit logical ID provided by `overrideLogicalId`.
33 */
34 private _logicalIdOverride?;
35 /**
36 * If the logicalId is locked then it can no longer be overridden.
37 * This is needed for cases where the logicalId is consumed prior to synthesis
38 * (i.e. Stack.exportValue).
39 */
40 private _logicalIdLocked?;
41 /**
42 * Creates an entity and binds it to a tree.
43 * Note that the root of the tree must be a Stack object (not just any Root).
44 *
45 * @param scope The parent construct
46 * @param props Construct properties
47 */
48 constructor(scope: Construct, id: string);
49 /**
50 * Overrides the auto-generated logical ID with a specific ID.
51 * @param newLogicalId The new logical ID to use for this stack element.
52 */
53 overrideLogicalId(newLogicalId: string): void;
54 /**
55 * Lock the logicalId of the element and do not allow
56 * any updates (e.g. via overrideLogicalId)
57 *
58 * This is needed in cases where you are consuming the LogicalID
59 * of an element prior to synthesis and you need to not allow future
60 * changes to the id since doing so would cause the value you just
61 * consumed to differ from the synth time value of the logicalId.
62 *
63 * For example:
64 *
65 * const bucket = new Bucket(stack, 'Bucket');
66 * stack.exportValue(bucket.bucketArn) <--- consuming the logicalId
67 * bucket.overrideLogicalId('NewLogicalId') <--- updating logicalId
68 *
69 * You should most likely never need to use this method, and if
70 * you are implementing a feature that requires this, make sure
71 * you actually require it.
72 *
73 * @internal
74 */
75 _lockLogicalId(): void;
76 /**
77 * @returns the stack trace of the point where this Resource was created from, sourced
78 * from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most
79 * node +internal+ entries filtered.
80 */
81 get creationStack(): string[];
82 /**
83 * Returns the CloudFormation 'snippet' for this entity. The snippet will only be merged
84 * at the root level to ensure there are no identity conflicts.
85 *
86 * For example, a Resource class will return something like:
87 * {
88 * Resources: {
89 * [this.logicalId]: {
90 * Type: this.resourceType,
91 * Properties: this.props,
92 * Condition: this.condition
93 * }
94 * }
95 * }
96 *
97 * @internal
98 */
99 abstract _toCloudFormation(): object;
100 /**
101 * Called during synthesize to render the logical ID of this element. If
102 * `overrideLogicalId` was it will be used, otherwise, we will allocate the
103 * logical ID through the stack.
104 */
105 private synthesizeLogicalId;
106}
107/**
108 * Base class for referenceable CloudFormation constructs which are not Resources
109 *
110 * These constructs are things like Conditions and Parameters, can be
111 * referenced by taking the `.ref` attribute.
112 *
113 * Resource constructs do not inherit from CfnRefElement because they have their
114 * own, more specific types returned from the .ref attribute. Also, some
115 * resources aren't referenceable at all (such as BucketPolicies or GatewayAttachments).
116 */
117export declare abstract class CfnRefElement extends CfnElement {
118 /**
119 * Return a string that will be resolved to a CloudFormation `{ Ref }` for this element.
120 *
121 * If, by any chance, the intrinsic reference of a resource is not a string, you could
122 * coerce it to an IResolvable through `Lazy.any({ produce: resource.ref })`.
123 */
124 get ref(): string;
125}
126import { Stack } from './stack';