UNPKG

11.2 kBTypeScriptView Raw
1import { CfnCondition } from './cfn-condition';
2import { CfnRefElement } from './cfn-element';
3import { CfnCreationPolicy, CfnDeletionPolicy, CfnUpdatePolicy } from './cfn-resource-policy';
4import { Construct, IConstruct } from 'constructs';
5import { Reference } from './reference';
6import { RemovalPolicy, RemovalPolicyOptions } from './removal-policy';
7export interface CfnResourceProps {
8 /**
9 * CloudFormation resource type (e.g. `AWS::S3::Bucket`).
10 */
11 readonly type: string;
12 /**
13 * Resource properties.
14 *
15 * @default - No resource properties.
16 */
17 readonly properties?: {
18 [name: string]: any;
19 };
20}
21/**
22 * Represents a CloudFormation resource.
23 */
24export declare class CfnResource extends CfnRefElement {
25 /**
26 * Check whether the given construct is a CfnResource
27 */
28 static isCfnResource(construct: IConstruct): construct is CfnResource;
29 /**
30 * Options for this resource, such as condition, update policy etc.
31 */
32 readonly cfnOptions: ICfnResourceOptions;
33 /**
34 * AWS resource type.
35 */
36 readonly cfnResourceType: string;
37 /**
38 * AWS CloudFormation resource properties.
39 *
40 * This object is returned via cfnProperties
41 * @internal
42 */
43 protected readonly _cfnProperties: any;
44 /**
45 * An object to be merged on top of the entire resource definition.
46 */
47 private readonly rawOverrides;
48 /**
49 * Logical IDs of dependencies.
50 *
51 * Is filled during prepare().
52 */
53 private readonly dependsOn;
54 /**
55 * Creates a resource construct.
56 * @param cfnResourceType The CloudFormation type of this resource (e.g. AWS::DynamoDB::Table)
57 */
58 constructor(scope: Construct, id: string, props: CfnResourceProps);
59 /**
60 * Sets the deletion policy of the resource based on the removal policy specified.
61 *
62 * The Removal Policy controls what happens to this resource when it stops
63 * being managed by CloudFormation, either because you've removed it from the
64 * CDK application or because you've made a change that requires the resource
65 * to be replaced.
66 *
67 * The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
68 * account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
69 */
70 applyRemovalPolicy(policy: RemovalPolicy | undefined, options?: RemovalPolicyOptions): void;
71 /**
72 * Returns a token for an runtime attribute of this resource.
73 * Ideally, use generated attribute accessors (e.g. `resource.arn`), but this can be used for future compatibility
74 * in case there is no generated attribute.
75 * @param attributeName The name of the attribute.
76 */
77 getAtt(attributeName: string): Reference;
78 /**
79 * Adds an override to the synthesized CloudFormation resource. To add a
80 * property override, either use `addPropertyOverride` or prefix `path` with
81 * "Properties." (i.e. `Properties.TopicName`).
82 *
83 * If the override is nested, separate each nested level using a dot (.) in the path parameter.
84 * If there is an array as part of the nesting, specify the index in the path.
85 *
86 * To include a literal `.` in the property name, prefix with a `\`. In most
87 * programming languages you will need to write this as `"\\."` because the
88 * `\` itself will need to be escaped.
89 *
90 * For example,
91 * ```typescript
92 * cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
93 * cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
94 * ```
95 * would add the overrides
96 * ```json
97 * "Properties": {
98 * "GlobalSecondaryIndexes": [
99 * {
100 * "Projection": {
101 * "NonKeyAttributes": [ "myattribute" ]
102 * ...
103 * }
104 * ...
105 * },
106 * {
107 * "ProjectionType": "INCLUDE"
108 * ...
109 * },
110 * ]
111 * ...
112 * }
113 * ```
114 *
115 * The `value` argument to `addOverride` will not be processed or translated
116 * in any way. Pass raw JSON values in here with the correct capitalization
117 * for CloudFormation. If you pass CDK classes or structs, they will be
118 * rendered with lowercased key names, and CloudFormation will reject the
119 * template.
120 *
121 * @param path - The path of the property, you can use dot notation to
122 * override values in complex types. Any intermdediate keys
123 * will be created as needed.
124 * @param value - The value. Could be primitive or complex.
125 */
126 addOverride(path: string, value: any): void;
127 /**
128 * Syntactic sugar for `addOverride(path, undefined)`.
129 * @param path The path of the value to delete
130 */
131 addDeletionOverride(path: string): void;
132 /**
133 * Adds an override to a resource property.
134 *
135 * Syntactic sugar for `addOverride("Properties.<...>", value)`.
136 *
137 * @param propertyPath The path of the property
138 * @param value The value
139 */
140 addPropertyOverride(propertyPath: string, value: any): void;
141 /**
142 * Adds an override that deletes the value of a property from the resource definition.
143 * @param propertyPath The path to the property.
144 */
145 addPropertyDeletionOverride(propertyPath: string): void;
146 /**
147 * Indicates that this resource depends on another resource and cannot be
148 * provisioned unless the other resource has been successfully provisioned.
149 *
150 * This can be used for resources across stacks (or nested stack) boundaries
151 * and the dependency will automatically be transferred to the relevant scope.
152 */
153 addDependsOn(target: CfnResource): void;
154 /**
155 * Add a value to the CloudFormation Resource Metadata
156 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
157 *
158 * Note that this is a different set of metadata from CDK node metadata; this
159 * metadata ends up in the stack template under the resource, whereas CDK
160 * node metadata ends up in the Cloud Assembly.
161 */
162 addMetadata(key: string, value: any): void;
163 /**
164 * Retrieve a value value from the CloudFormation Resource Metadata
165 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
166 *
167 * Note that this is a different set of metadata from CDK node metadata; this
168 * metadata ends up in the stack template under the resource, whereas CDK
169 * node metadata ends up in the Cloud Assembly.
170 */
171 getMetadata(key: string): any;
172 /**
173 * @returns a string representation of this resource
174 */
175 toString(): string;
176 /**
177 * Called by the `addDependency` helper function in order to realize a direct
178 * dependency between two resources that are directly defined in the same
179 * stacks.
180 *
181 * Use `resource.addDependsOn` to define the dependency between two resources,
182 * which also takes stack boundaries into account.
183 *
184 * @internal
185 */
186 _addResourceDependency(target: CfnResource): void;
187 /**
188 * Emits CloudFormation for this resource.
189 * @internal
190 */
191 _toCloudFormation(): object;
192 protected get cfnProperties(): {
193 [key: string]: any;
194 };
195 protected renderProperties(props: {
196 [key: string]: any;
197 }): {
198 [key: string]: any;
199 };
200 /**
201 * Return properties modified after initiation
202 *
203 * Resources that expose mutable properties should override this function to
204 * collect and return the properties object for this resource.
205 */
206 protected get updatedProperites(): {
207 [key: string]: any;
208 };
209 protected validateProperties(_properties: any): void;
210 /**
211 * Can be overridden by subclasses to determine if this resource will be rendered
212 * into the cloudformation template.
213 *
214 * @returns `true` if the resource should be included or `false` is the resource
215 * should be omitted.
216 */
217 protected shouldSynthesize(): boolean;
218}
219export declare enum TagType {
220 STANDARD = "StandardTag",
221 AUTOSCALING_GROUP = "AutoScalingGroupTag",
222 MAP = "StringToStringMap",
223 KEY_VALUE = "KeyValue",
224 NOT_TAGGABLE = "NotTaggable"
225}
226export interface ICfnResourceOptions {
227 /**
228 * A condition to associate with this resource. This means that only if the condition evaluates to 'true' when the stack
229 * is deployed, the resource will be included. This is provided to allow CDK projects to produce legacy templates, but noramlly
230 * there is no need to use it in CDK projects.
231 */
232 condition?: CfnCondition;
233 /**
234 * Associate the CreationPolicy attribute with a resource to prevent its status from reaching create complete until
235 * AWS CloudFormation receives a specified number of success signals or the timeout period is exceeded. To signal a
236 * resource, you can use the cfn-signal helper script or SignalResource API. AWS CloudFormation publishes valid signals
237 * to the stack events so that you track the number of signals sent.
238 */
239 creationPolicy?: CfnCreationPolicy;
240 /**
241 * With the DeletionPolicy attribute you can preserve or (in some cases) backup a resource when its stack is deleted.
242 * You specify a DeletionPolicy attribute for each resource that you want to control. If a resource has no DeletionPolicy
243 * attribute, AWS CloudFormation deletes the resource by default. Note that this capability also applies to update operations
244 * that lead to resources being removed.
245 */
246 deletionPolicy?: CfnDeletionPolicy;
247 /**
248 * Use the UpdatePolicy attribute to specify how AWS CloudFormation handles updates to the AWS::AutoScaling::AutoScalingGroup
249 * resource. AWS CloudFormation invokes one of three update policies depending on the type of change you make or whether a
250 * scheduled action is associated with the Auto Scaling group.
251 */
252 updatePolicy?: CfnUpdatePolicy;
253 /**
254 * Use the UpdateReplacePolicy attribute to retain or (in some cases) backup the existing physical instance of a resource
255 * when it is replaced during a stack update operation.
256 */
257 updateReplacePolicy?: CfnDeletionPolicy;
258 /**
259 * The version of this resource.
260 * Used only for custom CloudFormation resources.
261 *
262 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html
263 */
264 version?: string;
265 /**
266 * The description of this resource.
267 * Used for informational purposes only, is not processed in any way
268 * (and stays with the CloudFormation template, is not passed to the underlying resource,
269 * even if it does have a 'description' property).
270 */
271 description?: string;
272 /**
273 * Metadata associated with the CloudFormation resource. This is not the same as the construct metadata which can be added
274 * using construct.addMetadata(), but would not appear in the CloudFormation template automatically.
275 */
276 metadata?: {
277 [key: string]: any;
278 };
279}
280
\No newline at end of file