属性 角色的值必须是字符串列表类型 || AWS SAM

Value of property Roles must be of type List of String || AWS SAM

尝试部署 AWS SAM 时,堆栈创建失败并出现以下错误:

属性 角色的值必须是字符串列表

由于模板文件很大,我只给出策略部分的部分

  Policies:
    Type: AWS::IAM::Policy
    Properties:
      PolicyName: !Join ['',['lambdaExecutionPolicy',!FindInMap [Variables,Vid,value]]]
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Action: 'dynamodb:Query'
            Resource: '*'
          - Effect: Allow
            Action: 'logs:*'
            Resource: 'arn:aws:logs:*:*:*'
          - Effect: Allow
            Action:
              - 's3:GetObject'
              - 's3:PutObject'
            Resource: 'arn:aws:s3:::*'
          - Effect: Allow
            Action:
              - 'logs:CreateLogGroup'
              - 'logs:CreateLogStream'
              - 'logs:PutLogEvents'
            Resource: '*'
          - Effect: Allow
            Action:
              - 'logs:CreateLogGroup'
              - 'logs:CreateLogStream'
              - 'logs:PutLogEvents'
            Resource: '*'
          - Effect: Allow
            Action: 'sns:Publish'
            Resource: !Ref mysubscription
      Roles: !Ref lambdaexecutionrole'

执行 CFT 时

根据文档,Roles 的形式为:

  Roles: 
    - String

因此在您的情况下,您应该:

Roles: 
  - !Ref lambdaexecutionrole

Roles: [!Ref lambdaexecutionrole]