Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Incorrect arg type on Fn.eachMemberIn #2958

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions packages/@aws-cdk/cdk/lib/fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class Fn {
* of strings.
* @returns an FnCondition token
*/
public conditionEachMemberEquals(listOfStrings: string[], value: string): ICfnConditionExpression {
public static conditionEachMemberEquals(listOfStrings: string[], value: string): ICfnConditionExpression {
return new FnEachMemberEquals(listOfStrings, value);
}

Expand All @@ -255,7 +255,7 @@ export class Fn {
* strings_to_check parameter.
* @returns an FnCondition token
*/
public conditionEachMemberIn(stringsToCheck: string[], stringsToMatch: string): ICfnConditionExpression {
public static conditionEachMemberIn(stringsToCheck: string[], stringsToMatch: string[]): ICfnConditionExpression {
return new FnEachMemberIn(stringsToCheck, stringsToMatch);
}

Expand All @@ -266,7 +266,7 @@ export class Fn {
* Parameters in the AWS CloudFormation User Guide.
* @returns a token represented as a string array
*/
public refAll(parameterType: string): string[] {
public static refAll(parameterType: string): string[] {
return Token.asList(new FnRefAll(parameterType));
}

Expand All @@ -280,7 +280,7 @@ export class Fn {
* value.
* @returns a token represented as a string
*/
public valueOf(parameterOrLogicalId: string, attribute: string): string {
public static valueOf(parameterOrLogicalId: string, attribute: string): string {
return new FnValueOf(parameterOrLogicalId, attribute).toString();
}

Expand All @@ -294,9 +294,11 @@ export class Fn {
* value. For more information about attributes, see Supported Attributes.
* @returns a token represented as a string array
*/
public valueOfAll(parameterType: string, attribute: string): string[] {
public static valueOfAll(parameterType: string, attribute: string): string[] {
return Token.asList(new FnValueOfAll(parameterType, attribute));
}

private constructor() { }
}

/**
Expand Down Expand Up @@ -577,8 +579,8 @@ class FnEachMemberIn extends FnConditionBase {
* @param stringsToCheck A list of strings, such as "A", "B", "C". AWS CloudFormation checks whether each member in the strings_to_check parameter is in the strings_to_match parameter.
* @param stringsToMatch A list of strings, such as "A", "B", "C". Each member in the strings_to_match parameter is compared against the members of the strings_to_check parameter.
*/
constructor(stringsToCheck: any, stringsToMatch: any) {
super('Fn::EachMemberIn', [ [stringsToCheck], stringsToMatch ]);
constructor(stringsToCheck: string[], stringsToMatch: string[]) {
super('Fn::EachMemberIn', [stringsToCheck, stringsToMatch]);
}
}

Expand Down Expand Up @@ -685,4 +687,4 @@ class FnJoin implements IResolvable {
const resolvedValues = this.listOfValues.map(context.resolve);
return this._resolvedValues = minimalCloudFormationJoin(this.delimiter, resolvedValues);
}
}
}
13 changes: 13 additions & 0 deletions packages/@aws-cdk/cdk/test/test.fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ export = nodeunit.testCase({
{ verbose: true }
);
}),
'Fn::EachMemberIn': asyncTest(async (test) => {
const stack = new Stack();
const eachMemberIn = Fn.conditionEachMemberIn(
Fn.valueOfAll('AWS::EC2::Subnet::Id', 'VpcId'),
Fn.refAll('AWS::EC2::VPC::Id')
);
test.deepEqual(stack.resolve(eachMemberIn), {
'Fn::EachMemberIn': [
{ 'Fn::ValueOfAll': ['AWS::EC2::Subnet::Id', 'VpcId'] },
{ 'Fn::RefAll': 'AWS::EC2::VPC::Id'}
]
});
}),
},
});

Expand Down