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

Fn:EachMemberIn should take two lists as parameters #2950

Closed
Labels
bug This issue is a bug.

Comments

@ajnarang
Copy link

ajnarang commented Jun 20, 2019

Describe the bug
https://github.com/awslabs/aws-cdk/blob/d9d3a99bea13024b1a7f19d18240a826cc23b2cf/packages/%40aws-cdk/cdk/lib/fn.ts#L258

method conditionEachMemberIn should take in two lists as parameter instead of a list and a string. (as described in the javadoc as well).

Results in
software.amazon.jsii.JsiiException: Cannot add elements to list token, got: #{Token[TOKEN.0]},#{Token[TOKEN.1]}
Error: Cannot add elements to list token, got: #{Token[TOKEN.0]},#{Token[TOKEN.1]}

To Reproduce

        Fn fn = new Fn();
        new CfnRule(
                this,
                "SubnetsInVPC",
                CfnRuleProps.builder()
                        .withAssertions(
                                Collections.singletonList(
                                        RuleAssertion.builder()
                                                .withAssert(
                                                        fn.conditionEachMemberIn(
                                                                fn.valueOfAll(
                                                                        "AWS::EC2::Subnet::Id",
                                                                        "VpcId"
                                                                ),
                                                                fn.refAll("AWS::EC2::VPC::Id").get(0) //get(0) was done to get the string but it should be list here.
                                                        )
                                                )
                                                .withAssertDescription("All subnets must in the VPC")
                                                .build()
                                )
                        )
                        .build()
        );

Expected behavior
Should add rule

"Rules": {
        "SubnetsInVPC": {
            "Assertions": [
                {
                    "Assert": {
                        "Fn::EachMemberIn": [
                            {
                                "Fn::ValueOfAll": [
                                    "AWS::EC2::Subnet::Id",
                                    "VpcId"
                                ]
                            },
                            {
                                "Fn::RefAll": "AWS::EC2::VPC::Id"
                            }
                        ]
                    },
                    "AssertDescription": "All subnets must in the VPC"
                }
            ]
        }
    }

Version:

  • MacOS
  • Java
  • 0.34.x
@ajnarang ajnarang added the bug This issue is a bug. label Jun 20, 2019
@RomainMuller
Copy link
Contributor

Thanks for having reported this bug! I'm working on a fix...

RomainMuller added a commit that referenced this issue Jun 20, 2019
Changed the type of the second argument to `Fn.eachMemberIn` to an array
of `string`s, such that it can be used at all.

BREAKING CHANGE: All instance methods of `Fn` were made `static`, and
                 the `Fn` constructor was made private.

Fixes #2950
RomainMuller added a commit that referenced this issue Jun 20, 2019
Changed the type of the second argument to `Fn.eachMemberIn` to an array
of `string`s, such that it can be used at all.

BREAKING CHANGE: All instance methods of `Fn` were made `static`, and
                 the `Fn` constructor was made private.

Fixes #2950
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment