title: How to deploy NestJS services with graphql, serverless lambda in the Localstack?
body: <h1>Solution</h1>
  <p><em>I found the solution, thanks for your time. StackOverflow doesn't let me answer me.    &gt;:(</em></p>
  <h1>Description</h1>
  <blockquote>
  <p>I would like to know what kind of configuration I need to perform to deploy a lambda Localstack of an application in NesJS that has Graphql, not RestApi. This is my configuration.</p>
  </blockquote>
  <ol>
  <li>Is correct this configuration?</li>
  <li>How can I get the fake link to access the playground across lambda Localstack?</li>
  </ol>
  <h1>Implementation</h1>
  <h2>Configuration the nestJS lambda function project</h2>
  <pre><code>import { ValidationPipe } from '@nestjs/common';
  import { NestFactory } from '@nestjs/core';
  import { ExpressAdapter } from '@nestjs/platform-express';
  import serverlessExpress from '@vendia/serverless-express';
  import { APIGatewayProxyHandler, Handler } from 'aws-lambda';
  import express from 'express';
  import { AppModule } from './app.module';
  
  let cachedServer: Handler;
  
  const bootstrapServer = async (): Promise&lt;Handler&gt; =&gt; {
    const expressApp = express();
    const app = await NestFactory.create(
      AppModule,
      new ExpressAdapter(expressApp),
    );
    app.useGlobalPipes(new ValidationPipe());
    app.enableCors();
    await app.init();
    return serverlessExpress({
      app: expressApp,
    });
  };
  
  export const handler: APIGatewayProxyHandler = async (
    event,
    context,
    callback,
  ) =&gt; {
    if (!cachedServer) {
      cachedServer = await bootstrapServer();
    }
    return cachedServer(event, context, callback);
  };
  
  </code></pre>
  <h2>Serverless.yml Configuration</h2>
  <pre class="lang-yaml prettyprint-override"><code>service: test
  
  provider:
    name: aws
    runtime: nodejs14.x
    stage: ''
    # profile: local # Config your AWS Profile
    environment: # Service wide environment variables
      NODE_ENV: local
      GLOBAL_PREFIX: graphql
      PORT: 4000
  
  plugins:
  #  - serverless-plugin-typescript
  #  - serverless-plugin-optimize
  #  - serverless-offline
   - serverless-localstack
  
  custom:
    localstack:
      debug: true
      stages:
       - local
       - dev
      endpointFile: localstack_endpoints.json
      individually: true
    # serverless-offline:
    #   httpPort: 3000
      
  functions:
   main:
     handler: dis/index.handler
  
  #  local:
  #    handler: dist/main.handler
  #    events:
  #      - http:
  #           path: /
  #           method: any
  #           cors: true
  
  
  
  </code></pre>
  <h2>Docker Compose Localstack</h2>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.8'
  
  services: 
    localstack:
      image: localstack/localstack:latest
      environment: 
        - AWS_DEFAULT_REGION=us-east-1
        - EDGE_PORT=4566
        - SERVICES=lambda,s3,cloudformation,sts
      ports: 
        - '4566-4597:4566-4597'
      volumes: 
        - &quot;${TMPDIR:-/tmp}/localstack:/tmp/localstack&quot;
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
  </code></pre>
  <h2>Services</h2>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;CloudFormation&quot; : &quot;http://localhost:4566&quot;,
      &quot;CloudWatch&quot; : &quot;http://localhost:4566&quot;,
      &quot;Lambda&quot; : &quot;http://localhost:4566&quot;,
      &quot;S3&quot; : &quot;http://localhost:4566&quot;
  }
  </code></pre>
  <h2>Commands</h2>
  <blockquote>
  <p>serverless deploy --stage local
  <a href="https://i.stack.imgur.com/P6OXK.png" rel="nofollow noreferrer">When executing this command I get this error</a></p>
  </blockquote>
  <blockquote>
  <p>serverless info --stage local
  <a href="https://i.stack.imgur.com/loOvH.png" rel="nofollow noreferrer">When executing this command I get this information</a></p>
  </blockquote>
  <blockquote>
  <p>serverless invoke local -f main -l
  <a href="https://i.stack.imgur.com/Ufnm0.png" rel="nofollow noreferrer">When executing this command</a></p>
  </blockquote>