无服务器应用程序规范文档无效。发现的错误数:2。ID 为 [**] 的资源无效。 属性 'Role' 的类型无效

Invalid Serverless Application Specification document. Number of errors found: 2. Resource with id [**] is invalid. Type of property 'Role' is invalid

我在 aws cloudformation 中遇到以下错误

转换 AWS::Serverless-2016-10-31 失败:无服务器应用程序规范文档无效。发现的错误数:2。ID 为 [AbortMultipartUpload] 的资源无效。 属性 'Role' 的类型无效。 ID 为 [CompleteMultipartUpload] 的资源无效。 属性 'Role' 的类型无效。用户请求回滚。

Documents.yaml

  CompleteMultipartUpload:
    Type: AWS::Serverless::Function
    DependsOn: RolesStack
    Properties:
      FunctionName: !Sub ${Prefix}-doc-CompleteMultipartUpload-lmd
      Handler: main
      Runtime: go1.x
      CodeUri: ../../Lambdas/Go/CompleteMultipartUpload
      AutoPublishAlias: !Ref Prefix
      DeploymentPreference:
        Type: AllAtOnce
      Description: 'Function to complete the multipart upload in document bucket'
      MemorySize: 128
      Role:
        - Fn::ImportValue:
            !Sub ${Prefix}-doc-CompleteMultipartUploadRoleArn```

Role ${Prefix}-doc-CompleteMultipartUploadRoleArn i was exported from RolesStack.yaml

Role 应该只是 String,而不是 Array。所以你应该有:

      Role: 
        Fn::ImportValue:
            !Sub ${Prefix}-doc-CompleteMultipartUploadRoleArn