monken / cfn-include

Preprocessor for CloudFormation templates with support for loops and flexible include statements
MIT License
86 stars 10 forks source link

Chokes on sequence next to map #39

Closed rirze closed 4 years ago

rirze commented 4 years ago

When I try to parse a CloudFormation file with the following structure:

            Version: 2012-10-17
            Statement:
              - Action:
                  Effect: Allow
                  Resource: '*'
                  - ec2:AttachVolume
                  - ec2:DescribeVolumes
                  - ec2:DescribeAddress
                  - ec2:AssociateAddress

The parser fails with this error:

SyntaxError: YAMLException: bad indentation of a sequence entry at line 127, column 17:
                    - ec2:AttachVolume
                    ^,SyntaxError: Unexpected token M in JSON at position 0

However, I know this is correct syntax because Cloudformation can run this section of YAML without issue. Maybe there is a test case not handled by the parser for this library?

monken commented 4 years ago

That's not a valid policy. It should read:

            Version: 2012-10-17
            Statement:
              - Effect: Allow
                Resource: '*'
                Action:
                  - ec2:AttachVolume
                  - ec2:DescribeVolumes
                  - ec2:DescribeAddress
                  - ec2:AssociateAddress

I'm not sure why CloudFormation would accept this as valid YAML. You cannot mix an object with an array.

rirze commented 4 years ago

Huh strange, I could've sworn it worked with CloudFormation. It works now with the correction you gave. Thanks for the quick response.