UNPKG

15.3 kBTypeScriptView Raw
1import { ICfnConditionExpression, ICfnRuleConditionExpression } from './cfn-condition';
2import { IResolvable } from './resolvable';
3/**
4 * CloudFormation intrinsic functions.
5 * http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
6 */
7export declare class Fn {
8 /**
9 * The ``Ref`` intrinsic function returns the value of the specified parameter or resource.
10 * Note that it doesn't validate the logicalName, it mainly serves paremeter/resource reference defined in a ``CfnInclude`` template.
11 * @param logicalName The logical name of a parameter/resource for which you want to retrieve its value.
12 */
13 static ref(logicalName: string): string;
14 /**
15 * The ``Fn::GetAtt`` intrinsic function returns the value of an attribute
16 * from a resource in the template.
17 * @param logicalNameOfResource The logical name (also called logical ID) of
18 * the resource that contains the attribute that you want.
19 * @param attributeName The name of the resource-specific attribute whose
20 * value you want. See the resource's reference page for details about the
21 * attributes available for that resource type.
22 * @returns an IResolvable object
23 */
24 static getAtt(logicalNameOfResource: string, attributeName: string): IResolvable;
25 /**
26 * The intrinsic function ``Fn::Join`` appends a set of values into a single
27 * value, separated by the specified delimiter. If a delimiter is the empty
28 * string, the set of values are concatenated with no delimiter.
29 * @param delimiter The value you want to occur between fragments. The
30 * delimiter will occur between fragments only. It will not terminate the
31 * final value.
32 * @param listOfValues The list of values you want combined.
33 * @returns a token represented as a string
34 */
35 static join(delimiter: string, listOfValues: string[]): string;
36 /**
37 * Split a string token into a token list of string values.
38 *
39 * Specify the location of splits with a delimiter such as ',' (a comma).
40 * Renders to the `Fn::Split` intrinsic function.
41 *
42 * Lists with unknown lengths (default)
43 * -------------------------------------
44 *
45 * Since this function is used to work with deploy-time values, if `assumedLength`
46 * is not given the CDK cannot know the length of the resulting list at synthesis time.
47 * This brings the following restrictions:
48 *
49 * - You must use `Fn.select(i, list)` to pick elements out of the list (you must not use
50 * `list[i]`).
51 * - You cannot add elements to the list, remove elements from the list,
52 * combine two such lists together, or take a slice of the list.
53 * - You cannot pass the list to constructs that do any of the above.
54 *
55 * The only valid operation with such a tokenized list is to pass it unmodified to a
56 * CloudFormation Resource construct.
57 *
58 * Lists with assumed lengths
59 * --------------------------
60 *
61 * Pass `assumedLength` if you know the length of the list that will be
62 * produced by splitting. The actual list length at deploy time may be
63 * *longer* than the number you pass, but not *shorter*.
64 *
65 * The returned list will look like:
66 *
67 * ```
68 * [Fn.select(0, split), Fn.select(1, split), Fn.select(2, split), ...]
69 * ```
70 *
71 * The restrictions from the section "Lists with unknown lengths" will now be lifted,
72 * at the expense of having to know and fix the length of the list.
73 *
74 * @param delimiter A string value that determines where the source string is divided.
75 * @param source The string value that you want to split.
76 * @param assumedLength The length of the list that will be produced by splitting
77 * @returns a token represented as a string array
78 */
79 static split(delimiter: string, source: string, assumedLength?: number): string[];
80 /**
81 * The intrinsic function ``Fn::Select`` returns a single object from a list of objects by index.
82 * @param index The index of the object to retrieve. This must be a value from zero to N-1, where N represents the number of elements in the array.
83 * @param array The list of objects to select from. This list must not be null, nor can it have null entries.
84 * @returns a token represented as a string
85 */
86 static select(index: number, array: string[]): string;
87 /**
88 * The intrinsic function ``Fn::Sub`` substitutes variables in an input string
89 * with values that you specify. In your templates, you can use this function
90 * to construct commands or outputs that include values that aren't available
91 * until you create or update a stack.
92 * @param body A string with variables that AWS CloudFormation substitutes
93 * with their associated values at runtime. Write variables as ${MyVarName}.
94 * Variables can be template parameter names, resource logical IDs, resource
95 * attributes, or a variable in a key-value map. If you specify only template
96 * parameter names, resource logical IDs, and resource attributes, don't
97 * specify a key-value map.
98 * @param variables The name of a variable that you included in the String
99 * parameter. The value that AWS CloudFormation substitutes for the associated
100 * variable name at runtime.
101 * @returns a token represented as a string
102 */
103 static sub(body: string, variables?: {
104 [key: string]: string;
105 }): string;
106 /**
107 * The intrinsic function ``Fn::Base64`` returns the Base64 representation of
108 * the input string. This function is typically used to pass encoded data to
109 * Amazon EC2 instances by way of the UserData property.
110 * @param data The string value you want to convert to Base64.
111 * @returns a token represented as a string
112 */
113 static base64(data: string): string;
114 /**
115 * The intrinsic function ``Fn::Cidr`` returns the specified Cidr address block.
116 * @param ipBlock The user-specified default Cidr address block.
117 * @param count The number of subnets' Cidr block wanted. Count can be 1 to 256.
118 * @param sizeMask The digit covered in the subnet.
119 * @returns a token represented as a string
120 */
121 static cidr(ipBlock: string, count: number, sizeMask?: string): string[];
122 /**
123 * Given an url, parse the domain name
124 * @param url the url to parse
125 */
126 static parseDomainName(url: string): string;
127 /**
128 * The intrinsic function ``Fn::GetAZs`` returns an array that lists
129 * Availability Zones for a specified region. Because customers have access to
130 * different Availability Zones, the intrinsic function ``Fn::GetAZs`` enables
131 * template authors to write templates that adapt to the calling user's
132 * access. That way you don't have to hard-code a full list of Availability
133 * Zones for a specified region.
134 * @param region The name of the region for which you want to get the
135 * Availability Zones. You can use the AWS::Region pseudo parameter to specify
136 * the region in which the stack is created. Specifying an empty string is
137 * equivalent to specifying AWS::Region.
138 * @returns a token represented as a string array
139 */
140 static getAzs(region?: string): string[];
141 /**
142 * The intrinsic function ``Fn::ImportValue`` returns the value of an output
143 * exported by another stack. You typically use this function to create
144 * cross-stack references. In the following example template snippets, Stack A
145 * exports VPC security group values and Stack B imports them.
146 * @param sharedValueToImport The stack output value that you want to import.
147 * @returns a token represented as a string
148 */
149 static importValue(sharedValueToImport: string): string;
150 /**
151 * Like `Fn.importValue`, but import a list with a known length
152 *
153 * If you explicitly want a list with an unknown length, call `Fn.split(',',
154 * Fn.importValue(exportName))`. See the documentation of `Fn.split` to read
155 * more about the limitations of using lists of unknown length.
156 *
157 * `Fn.importListValue(exportName, assumedLength)` is the same as
158 * `Fn.split(',', Fn.importValue(exportName), assumedLength)`,
159 * but easier to read and impossible to forget to pass `assumedLength`.
160 */
161 static importListValue(sharedValueToImport: string, assumedLength: number, delimiter?: string): string[];
162 /**
163 * The intrinsic function ``Fn::FindInMap`` returns the value corresponding to
164 * keys in a two-level map that is declared in the Mappings section.
165 * @returns a token represented as a string
166 */
167 static findInMap(mapName: string, topLevelKey: string, secondLevelKey: string): string;
168 /**
169 * An additional function used in CfnParser,
170 * as Fn::FindInMap does not always return a string.
171 *
172 * @internal
173 */
174 static _findInMap(mapName: string, topLevelKey: string, secondLevelKey: string): IResolvable;
175 /**
176 * Creates a token representing the ``Fn::Transform`` expression
177 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-transform.html
178 * @param macroName The name of the macro to perform the processing
179 * @param parameters The parameters to be passed to the macro
180 * @returns a token representing the transform expression
181 */
182 static transform(macroName: string, parameters: {
183 [name: string]: any;
184 }): IResolvable;
185 /**
186 * Returns true if all the specified conditions evaluate to true, or returns
187 * false if any one of the conditions evaluates to false. ``Fn::And`` acts as
188 * an AND operator. The minimum number of conditions that you can include is
189 * 1.
190 * @param conditions conditions to AND
191 * @returns an FnCondition token
192 */
193 static conditionAnd(...conditions: ICfnConditionExpression[]): ICfnRuleConditionExpression;
194 /**
195 * Compares if two values are equal. Returns true if the two values are equal
196 * or false if they aren't.
197 * @param lhs A value of any type that you want to compare.
198 * @param rhs A value of any type that you want to compare.
199 * @returns an FnCondition token
200 */
201 static conditionEquals(lhs: any, rhs: any): ICfnRuleConditionExpression;
202 /**
203 * Returns one value if the specified condition evaluates to true and another
204 * value if the specified condition evaluates to false. Currently, AWS
205 * CloudFormation supports the ``Fn::If`` intrinsic function in the metadata
206 * attribute, update policy attribute, and property values in the Resources
207 * section and Outputs sections of a template. You can use the AWS::NoValue
208 * pseudo parameter as a return value to remove the corresponding property.
209 * @param conditionId A reference to a condition in the Conditions section. Use
210 * the condition's name to reference it.
211 * @param valueIfTrue A value to be returned if the specified condition
212 * evaluates to true.
213 * @param valueIfFalse A value to be returned if the specified condition
214 * evaluates to false.
215 * @returns an FnCondition token
216 */
217 static conditionIf(conditionId: string, valueIfTrue: any, valueIfFalse: any): ICfnRuleConditionExpression;
218 /**
219 * Returns true for a condition that evaluates to false or returns false for a
220 * condition that evaluates to true. ``Fn::Not`` acts as a NOT operator.
221 * @param condition A condition such as ``Fn::Equals`` that evaluates to true
222 * or false.
223 * @returns an FnCondition token
224 */
225 static conditionNot(condition: ICfnConditionExpression): ICfnRuleConditionExpression;
226 /**
227 * Returns true if any one of the specified conditions evaluate to true, or
228 * returns false if all of the conditions evaluates to false. ``Fn::Or`` acts
229 * as an OR operator. The minimum number of conditions that you can include is
230 * 1.
231 * @param conditions conditions that evaluates to true or false.
232 * @returns an FnCondition token
233 */
234 static conditionOr(...conditions: ICfnConditionExpression[]): ICfnRuleConditionExpression;
235 /**
236 * Returns true if a specified string matches at least one value in a list of
237 * strings.
238 * @param listOfStrings A list of strings, such as "A", "B", "C".
239 * @param value A string, such as "A", that you want to compare against a list of strings.
240 * @returns an FnCondition token
241 */
242 static conditionContains(listOfStrings: string[], value: string): ICfnRuleConditionExpression;
243 /**
244 * Returns true if a specified string matches all values in a list.
245 * @param listOfStrings A list of strings, such as "A", "B", "C".
246 * @param value A string, such as "A", that you want to compare against a list
247 * of strings.
248 * @returns an FnCondition token
249 */
250 static conditionEachMemberEquals(listOfStrings: string[], value: string): ICfnRuleConditionExpression;
251 /**
252 * Returns true if each member in a list of strings matches at least one value
253 * in a second list of strings.
254 * @param stringsToCheck A list of strings, such as "A", "B", "C". AWS
255 * CloudFormation checks whether each member in the strings_to_check parameter
256 * is in the strings_to_match parameter.
257 * @param stringsToMatch A list of strings, such as "A", "B", "C". Each member
258 * in the strings_to_match parameter is compared against the members of the
259 * strings_to_check parameter.
260 * @returns an FnCondition token
261 */
262 static conditionEachMemberIn(stringsToCheck: string[], stringsToMatch: string[]): ICfnRuleConditionExpression;
263 /**
264 * Returns all values for a specified parameter type.
265 * @param parameterType An AWS-specific parameter type, such as
266 * AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. For more information, see
267 * Parameters in the AWS CloudFormation User Guide.
268 * @returns a token represented as a string array
269 */
270 static refAll(parameterType: string): string[];
271 /**
272 * Returns an attribute value or list of values for a specific parameter and
273 * attribute.
274 * @param parameterOrLogicalId The name of a parameter for which you want to
275 * retrieve attribute values. The parameter must be declared in the Parameters
276 * section of the template.
277 * @param attribute The name of an attribute from which you want to retrieve a
278 * value.
279 * @returns a token represented as a string
280 */
281 static valueOf(parameterOrLogicalId: string, attribute: string): string;
282 /**
283 * Returns a list of all attribute values for a given parameter type and
284 * attribute.
285 * @param parameterType An AWS-specific parameter type, such as
286 * AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. For more information, see
287 * Parameters in the AWS CloudFormation User Guide.
288 * @param attribute The name of an attribute from which you want to retrieve a
289 * value. For more information about attributes, see Supported Attributes.
290 * @returns a token represented as a string array
291 */
292 static valueOfAll(parameterType: string, attribute: string): string[];
293 private constructor();
294}