serverless/serverless

`Fn::ForEach` Supported but an error is thrown on the CLI

Opened this issue · 0 comments

Issue description

When a Fn::ForEach block is included, the Serverless CLI throws an error:

Warning: Invalid configuration encountered
  at 'resources.Resources': unrecognized property 'Fn::ForEach::LoopName'

However, upon inspecting the generated CloudFormation template it seems to generates the loop resources fine.

Context

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-foreach.html

I would also suggest to add this to the documentation as it is already implicitly supported.

The correct syntax looks like:

resources:
  Transform: AWS::LanguageExtensions
  Resources:
    Fn::ForEach::LoopName:
      - VarName
      - - Foo
        - Bar
      - ${VarName}SomeResource:
          SomeProperty: !Ref VarName
          SomeNestedRef:
            Ref: !Sub ${VarName}Suffix