|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const rules = module.exports = {}; |
| 4 | + |
| 5 | +/** |
| 6 | + * [The rule function |
| 7 | + * Fn::Contains](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#fn-contains) |
| 8 | + * returns true if a specified string matches at least one value in a list of |
| 9 | + * strings. |
| 10 | + * |
| 11 | + * @static |
| 12 | + * @memberof cloudfriend |
| 13 | + * @name contains |
| 14 | + * @param {array} strings |
| 15 | + * @param {string} s |
| 16 | + */ |
| 17 | +rules.contains = (strings, s) => { |
| 18 | + return { 'Fn::Contains': [strings, s] }; |
| 19 | +}; |
| 20 | + |
| 21 | +/** |
| 22 | + * [The rule function |
| 23 | + * Fn::EachMemberEquals](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#fn-eachmemberequals) |
| 24 | + * returns true if a specified string matches all values in a list. |
| 25 | + * |
| 26 | + * @static |
| 27 | + * @memberof cloudfriend |
| 28 | + * @name eachMemberEquals |
| 29 | + * @param {array} strings |
| 30 | + * @param {string} s |
| 31 | + */ |
| 32 | +rules.eachMemberEquals = (strings, s) => { |
| 33 | + return { 'Fn::EachMemberEquals': [strings, s] }; |
| 34 | +}; |
| 35 | + |
| 36 | +/** |
| 37 | + * [The rule function |
| 38 | + * Fn::EachMemberIn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#fn-eachmemberin) |
| 39 | + * returns true if each member in a list of strings matches at least one value |
| 40 | + * in a second list of strings. |
| 41 | + * |
| 42 | + * @static |
| 43 | + * @memberof cloudfriend |
| 44 | + * @name eachMemberIn |
| 45 | + * @param {array} stringsToCheck |
| 46 | + * @param {array} stringsToMatch |
| 47 | + */ |
| 48 | +rules.eachMemberIn = (stringsToCheck, stringsToMatch) => { |
| 49 | + return { 'Fn::EachMemberIn': [stringsToCheck, stringsToMatch] }; |
| 50 | +}; |
| 51 | + |
| 52 | +/** |
| 53 | + * [The rule function Fn::RefAll](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#fn-refall) returns all values for a specified parameter type. |
| 54 | + * |
| 55 | + * @static |
| 56 | + * @memberof cloudfriend |
| 57 | + * @name refAll |
| 58 | + * @param {string} parameterType An AWS-specific parameter type, such as AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. |
| 59 | + */ |
| 60 | +rules.refAll = (parameterType) => { |
| 61 | + return { 'Fn::RefAll': parameterType }; |
| 62 | +}; |
| 63 | + |
| 64 | +/** |
| 65 | + * [The rule function Fn::ValueOf](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#fn-valueof) returns an attribute value or list of values for a specific parameter and attribute. |
| 66 | + * |
| 67 | + * @static |
| 68 | + * @memberof cloudfriend |
| 69 | + * @name valueOf |
| 70 | + * @param {string} parameterLogicalId The name of a parameter for which you want to retrieve attribute values. The parameter must be declared in the Parameters section of the template. |
| 71 | + * @param {*} attribute The name of an attribute from which you want to retrieve a value. For more information about attributes, see [Supported Attributes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#rules-parameter-attributes). |
| 72 | + */ |
| 73 | +rules.valueOf = (parameterLogicalId, attribute) => { |
| 74 | + return { 'Fn::ValueOf': [parameterLogicalId, attribute] }; |
| 75 | +}; |
| 76 | + |
| 77 | +/** |
| 78 | + * [The rule function Fn::ValueOfAll](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#fn-valueofall) returns a list of all attribute values for a given parameter type and attribute. |
| 79 | + * |
| 80 | + * @static |
| 81 | + * @memberof cloudfriend |
| 82 | + * @name valueOfAll |
| 83 | + * @param {string} parameterType An AWS-specific parameter type, such as AWS::EC2::SecurityGroup::Id or AWS::EC2::VPC::Id. |
| 84 | + * @param {string} attribute The name of an attribute from which you want to retrieve a value. For more information about attributes, see [Supported Attributes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-rules.html#rules-parameter-attributes). |
| 85 | + */ |
| 86 | +rules.valueOfAll = (parameterType, attribute) => { |
| 87 | + return { 'Fn::ValueOfAll': [parameterType, attribute] }; |
| 88 | +}; |
0 commit comments