skip to Main Content

I’ve been following the guide on https://cube.dev/docs/deployment#express-with-basic-passport-authentication to deploy Cube.js to Lambda. I got it working against an Athena db such that the /meta endpoint works successfully and returns schemas.

When trying to query Athena data in Lambda however, all requests are resulting in 504 Gateway Timeouts. Checking the CloudWatch logs I see one consistent error:

/bin/sh: hostname: command not found

Any idea what this could be?

Here’s my server.yml:

service: tw-cubejs

provider:
  name: aws
  runtime: nodejs12.x
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "sns:*"
        # Athena permissions
        - "athena:*"
        - "s3:*"
        - "glue:*"
      Resource:
        - "*"
  # When you uncomment vpc please make sure lambda has access to internet: https://medium.com/@philippholly/aws-lambda-enable-outgoing-internet-access-within-vpc-8dd250e11e12
  vpc:
    securityGroupIds:
      # Your DB and Redis security groups here
      - ########
    subnetIds:
      # Put here subnet with access to your DB, Redis and internet. For internet access 0.0.0.0/0 should be routed through NAT only for this subnet!
      - ########
      - ########
      - ########
      - ########
  environment:
    CUBEJS_AWS_KEY: ########
    CUBEJS_AWS_SECRET: ########
    CUBEJS_AWS_REGION: ########
    CUBEJS_DB_TYPE: athena
    CUBEJS_AWS_S3_OUTPUT_LOCATION: ########
    CUBEJS_JDBC_DRIVER: athena
    REDIS_URL: ########
    CUBEJS_API_SECRET: ########
    CUBEJS_APP: "${self:service.name}-${self:provider.stage}"
    NODE_ENV: production
    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

2

Answers


  1. Check the version of cube.js you are using, according to the changelog this issue should have been fixed in 0.10.59.

    It’s most likely down to a dependency of cube.js assuming that all environments where it will run will be able to run the hostname shell command (looks like it’s using node-machine-id.

    Login or Signup to reply.
  2. Even this hostname error message is in logs however it isn’t an issue cause.
    Most probably you experiencing issue described here.

    @cubejs-backend/serverless uses internet connection to access messaging API as well as Redis inside VPC for managing queue and cache.
    One of those doesn’t work in your environment.

    Such timeouts usually mean that there’s a problem with internet connection or with Redis connection. If it’s Redis you’ll usually see timeouts after 5 minutes or so in both cubejs and cubejsProcess functions. If it’s internet connection you will never see any logs of query processing in cubejsProcess function.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search