首页 > 解决方案 > 在无服务器框架中找不到导出名称 XYZ

问题描述

functions:
  wsConnect:
    handler: src/handlers/wsConnect.handler
    name: ${self:provider.stage}-wsConnect
    environment:
      WS_SERVICE: ${self:provider.stage}-wsService
    events:
      - websocket:
          route: $connect
  wsDisconnect:
    handler: src/handlers/wsDisconnect.handler
    name: ${self:provider.stage}-wsDisconnect
    environment:
      WS_SERVICE: ${self:provider.stage}-wsService
    events:
      - websocket:
          route: $disconnect
  wsDefault:
    handler: src/handlers/wsDefault.handler
    name: ${self:provider.stage}-wsDefault
    events:
      - websocket:
          route: $default
resources:
    Outputs:
        ExportedWebSocketpi:
          Value: !Ref WebsocketsApi # Logical ID
          Export:
            Name: webSocketAPI
        ExportedRestApi:
          Value: !Ref ApiGatewayRestApi # Logical ID
          Export:
            Name: rest-wsAPI
custom:
  importwebSocketAPI:
    Fn::ImportValue: webSocketAPI

我已经创建了这个 WebSocket 并第一次尝试部署它,它显示No export name webSocketAPI found, custom: tag is executed before output export the API。我如何使用 DependsOn 来做到这一点,或者有没有其他方法可以做到这一点?

标签: yamlamazon-cloudformationserverless-framework

解决方案


您缺少输出的必填字段 -

在这里,您可能会发现如何在无服务器框架中设置输出

另一个例子:

resources:
    Outputs:
        DBUserName:
            Value: ${self:custom.dbCredentials.DB_USERNAME}
        DBPassword:
            Value: ${self:custom.dbCredentials.DB_PSW}

        RDSClusterID:
            Description: "RDS Cluster"
            Value: { Ref: RDSCluster }

        CognitoUserPoolId:
            Value: ${self:custom.userPool}

推荐阅读