简体   繁体   中英

Deploying cube.js using serverless framework results in an error

I am trying to deploy cube.js project using serverless framework on aws and when I access the endpoint produced by serverless, it results in the following error on the browser

Cannot GET /

Here is my serverless.yml file

service: cloud-analytics

provider:
  name: aws
  stage: production
  runtime: nodejs8.10
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "sns:*"    
        - "athena:*"
        - "s3:*"
        - "glue:*"
      Resource:
        - "*"
  vpc:
    securityGroupIds:
      - sg-xxxxxxxxx # Your DB and Redis security groups here
    subnetIds:
      - subnet-xxxxxxxxx
  environment:
    CUBEJS_AWS_KEY: ${opt:awsKey}
    CUBEJS_AWS_SECRET: ${opt:awsSecret}
    CUBEJS_AWS_REGION: us-east-1
    CUBEJS_AWS_S3_OUTPUT_LOCATION: ${opt:location}
    REDIS_URL: ${opt:redis_url_with_port}
    CUBEJS_DB_TYPE: athena
    CUBEJS_API_SECRET:XXXXXX
    CUBEJS_APP: "${self:service.name}-${self:provider.stage}"
    NODE_ENV: ${self:provider.stage}
    AWS_ACCOUNT_ID:
      Fn::Join:
        - ""
        - - Ref: "AWS::AccountId"

functions:
  cubejs:
    handler: cube.api
    timeout: 30
    events:
      - http:
          path: /
          method: GET
      - http:
          path: /{proxy+}
          method: ANY
  cubejsProcess:
    handler: cube.process
    timeout: 630
    events:
      - sns: "${self:service.name}-${self:provider.stage}-process"

plugins:
  - serverless-express

I have followed this steps in this blog to set up NAT https://medium.com/@philippholly/aws-lambda-enable-outgoing-internet-access-within-vpc-8dd250e11e12

Cube.js file is as follows with server core options

const AWSHandlers = require('@cubejs-backend/serverless-aws');
const AthenaDriver = require('@cubejs-backend/athena-driver');

module.exports = new AWSHandlers({
  externalDbType: 'athena',
  externalDriverFactory: () => new AthenaDriver({
      accessKeyId: process.env.CUBEJS_AWS_KEY,
      secretAccessKey: process.env.CUBEJS_AWS_SECRET,
      region: process.env.CUBEJS_AWS_REGION,
      S3OutputLocation: process.env.CUBEJS_AWS_S3_OUTPUT_LOCATION
  })
});

When I run the endpoint

https://xxxxx.execute-api.us-east-1.amazonaws.com/production/

which is produced by the serverless api gateway I get the error

Cannot GET /

On Cloudwatch I see the cubejs lambda being invoked and see logs for start and end request id. I dont see any logs on cubejsProcess lambda.

Where/How can I debug this to see where the issue is?

By default in production mode Cube.js disables dev server capability and it's why you don't see any Playground working at / path: https://cube.dev/docs/deployment#production-mode . Please use REST API to test your deployment: https://cube.dev/docs/rest-api .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM