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): Fn.select incorrectly short-circuits complex expressions #19680

Merged
merged 2 commits into from
Apr 1, 2022

Commits on Apr 1, 2022

  1. fix(core): Fn.select incorrectly short-circuits complex expressions

    In raw CloudFormation, it is possible to do the following:
    
    ```
    'Fn::Select':
      - 0
      - - { 'Fn::If': ['Cond1', 'Value1', { Ref: 'AWS::NoValue' } }
        - { 'Fn::If': ['Cond2', 'Value2', { Ref: 'AWS::NoValue' } }
        - { 'Fn::If': ['Cond3', 'Value3', { Ref: 'AWS::NoValue' } }
    ```
    
    Because the `AWS::NoValue`s will disappear from the array, this
    will evaluate to the first condition that is true.
    
    CDK is unlikely to generate expressions like this, but people may have
    written this in CloudFormation templates. The eager short-circuiting
    behavior of `Fn.select` was breaking the roundtrippability of this
    template's condition cascade through `cloudformation-include`, by
    unconditionally picking out the first element from the array.
    
    We can't get rid of the short-circuiting completely (as bunch of
    templates and tests may already depend on it), but we can catch
    this happening and guard against it, by not short-circuiting if
    we can't look into all values.
    rix0rrr committed Apr 1, 2022
    Configuration menu
    Copy the full SHA
    931a49a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a69d5ab View commit details
    Browse the repository at this point in the history