# Connect serverless to mongo VPC

**URL:** <https://forum.serverless.com/t/connect-serverless-to-mongo-vpc/1383>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [February 24, 2017, 10:52am UTC](https://forum.serverless.com/t/connect-serverless-to-mongo-vpc/1383 "2017-02-24T10:52:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![khinester](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/khinester/32/315_2.png) [@khinester](https://forum.serverless.com/u/khinester)\
**Post date:** [February 24, 2017, 10:52am UTC](https://forum.serverless.com/t/connect-serverless-to-mongo-vpc/1383/1 "2017-02-24T10:52:47Z")

</div>

Hello, I have the following serveless.yaml file:

```
service: mongo-serverless

provider:
  name: aws
  runtime: nodejs4.3
  stage: ${opt:stage}
  profile: ${self:custom.profiles.self:provider.stage}
 
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:*
      Resource: "*"
    - Effect: Allow
      Action:
        - ec2:CreateNetworkInterface
        - ec2:DescribeNetworkInterfaces
        - ec2:DetachNetworkInterface
        - ec2:DeleteNetworkInterface
      Resource: "*"
    - Effect: Allow
      Action:
        - s3:*
      Resource: "*"
  vpc:
    securityGroupIds:
      - sg-xxxx
    subnetIds:
      - subnet-xxxx

functions:
  graphql:
    handler: build/main.graphql
    timeout: 12
    events:
      - http:
          path: graphql
          method: post
          cors: true

```

both security group and subnets exists on my VPC but i am not able to make the serverless connect to mongo and get this error in the logs

`module initialization error: Error`

graphql function - is there a way to further test what is going on?
