Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
indrabasak opened this issue Jun 21, 2023 · 2 comments
Open
Labels
status: response required Waiting for Response of the reporter

Comments

@indrabasak
Copy link

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.

@steffyP
Copy link
Member

steffyP commented Oct 13, 2023

Hi @indrabasak,

currently we do not have a patch for the serverless-domain-manager plugin. There is also an open request for localstack support for their project.

As a workaround, you could try using the endpoint_url configuration in the .aws/config file, you can find details in the official AWS docs.

You could use it e.g. by changing the default profile to be the LocalStack endpoint. Depending on your use case this might be a suitable workaround:

[default]
region = us-east-1
endpoint_url=http://127.0.0.1:4566

Note that we experienced issues with resolving the hostname localhost with newer nodeJS versions, as it would resolve to an IPv6 address by default, but the Localstack container may not be listening on IPv6 (that's why in the sample snippet you see 127.0.0.1).

Please let us know if this configuration works for you.

@steffyP steffyP added the status: response required Waiting for Response of the reporter label Oct 13, 2023
@steffyP
Copy link
Member

steffyP commented Dec 15, 2023

Hi @indrabasak,

could you please provide an update on this issue, e.g. does the proposed solution work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: response required Waiting for Response of the reporter
Projects
None yet
Development

No branches or pull requests

2 participants