serverless-localstack icon indicating copy to clipboard operation
serverless-localstack copied to clipboard

Failed to create custom domain using serverless-domain-manager plugin

Open indrabasak opened this issue 2 years ago • 2 comments
trafficstars

I'm using the serverless-domain-manager plugin to create a custom domain for my API Gateway. The deployment to localstack fails as serverless-domain-manager plugin uses aws-sdk-js-v3. During deployment, the plugin tries to connect to the AWS default endpoint. Is there a way of configuring the correct local stack endpoint? Here's the exception stack I encountered,

Error: V1 - Unable to fetch information about 'test-example.hello.com':
The security token included in the request is invalid.
    at APIGatewayV1Wrapper.<anonymous> (/xxxx/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v1-wrapper.js:71:27)
    at Generator.throw (<anonymous>)
    at rejected (/xxxx/node_modules/serverless-domain-manager/dist/src/aws/api-gateway-v1-wrapper.js:6:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Here's the code logic from the plugin logic,

 const gateway = new APIGatewayClient({
    endpoint: 'http://localhost:4566',
    region: 'us-west-2',
    credentials: {
      accessKeyId: 'test',
      secretAccessKey: 'test'
    }
  });
  const domainInfo = await gateway.send(
    new GetDomainNameCommand({
      domainName: 'test-example.hello.com'
    })
  );

The only thing missing is the endpoint: 'http://localhost:4566' during the instantiation of APIGatewayClient.

indrabasak avatar Jun 21 '23 00:06 indrabasak