aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.4k stars 576 forks source link

v1: E3510 Exception 'not enough values to unpack (expected 2, got 1)' raised while validating 'cfnLint' when 'Ref' is resolved #3323

Closed egut closed 2 weeks ago

egut commented 2 weeks ago

CloudFormation Lint Version

v1.3.0

What operating system are you using?

Ubuntu

Describe the bug

cfn-lint get an internal error when handling serverless transformer CSV parameters this worked fin in 0.87.7. The validation works fine if we specify actions to the policy inline.

Don't work:

Parameters:
  Actions:
    Type: 'CommaDelimitedList'

Resource:
        :
            - Effect: Allow
              Action: !Ref 'Actions'
              Resource: '*'

Ex of what works:

            - Effect: Allow
              Action:
                - 'lambda:InvokeFunction'
              Resource: '*'

Expected behavior

That cfn-lint don't get an internal error while resolving CSV parameters.

Reproduction template

---
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: 'Bug E3510.'

Parameters:

  DeploymentBucket:
    Type: 'String'
    Description: 'Name of the DeploymentBucket.'

  FunctionFileName:
    Type: 'String'
    Description: 'File name of the lambda function.'

  ScheduleExpr:
    Type: 'String'
    Description: 'Schedule expression to trigger the function with.'

  Actions:
    Type: 'CommaDelimitedList'
    Description: >-
      List of the actions the lambda needs to perform
    Default: ''

Resources:
  ScheduledServerlessFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri:
        Bucket: !Ref 'DeploymentBucket'
        Key: !Sub 'lambda/scheduled_lambda/${FunctionFileName}.zip'
      Handler: !Sub '${FunctionFileName}.lambda_handler'
      Runtime: python3.9
      Architectures:
        - x86_64
      Policies:
        - Statement:
            - Effect: Allow
              # E3510 - bug in cfn-lint 1.30?
              Action: !Ref 'Actions'
              Resource: '*'
      Events:
        CloudWatchEvent:
          Type: Schedule
          Properties:
            Schedule: !Ref 'ScheduleExpr'