serverless-domain-manager: Unable to setup base domain mappings for

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Bug Report

Error Description After creating a custom domain with sls create_domain the deploy exits with error Unable to setup base domain mappings for <domain>

Command Run sls create_domain sls deploy --stage development

Console Output

Serverless Domain Manager: Error: <domain>:  ValidationError: Resource WebsocketsApi does not exist for stack <stack>
Serverless Domain Manager: Error: <domain>:  Error: Error: Failed to find CloudFormation resources for <domain>
  Error --------------------------------------------------
  Error: Error: Unable to setup base domain mappings for <domain>

Domain Manager Configuration

plugins:
  - serverless-domain-manager
custom:
  customDomain:
    websocket:
      domainName: <domain>
      createRoute53Record: true
      endpointType: 'regional'
      securityPolicy: tls_1_2
      certificateName: '<domain>'

Versions

  • Domain Manager version(s): v4.0.0
  • Node/npm version: Node 12.13.0/npm 6.12.0
  • Serverless Version: 1.69.0
  • Lambda Code Javascript

Additional context/Screenshots Already tried to delete the domain and recreated with no luck.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 37
  • Comments: 23

Most upvoted comments

Hello! I’m going to share my troubleshooting and my final solution because I wasted about 3 hours fighting with this (and I didn’t want to downgrade to v3). This was tested using version 6.0.3.

  1. If your are using a HTTP API you MUST set endpointType to regional and apiType to http
  2. If you are using a REST API you MUST set endpointType to edge and apiType to rest
  3. basePath is not mandatory, you can skip it if you just wanna go from root path (e.g. my-api.subdomain.com/my-endpoint instead of my-api.subdomain.com/api/my-endpoint)
  4. If you are still getting an error please check the error message carefully and check the “Failed to find a stack [name]” part. The [name] MUST match the name of your CloudFormation stack name (you can check here the final name). If for some reason it doesn’t:
    1. Delete your current stack sls remove
    2. Declare your stack name on the Serverless YML file in provider.stackName
    3. Deploy your stack

I hope this helps someone.

If someone (like me) didn’t read the docs & tried sls deploy directly, please don’t forget to run sls create_domain 😀

Just sharing what helped me.

If you are not using Route 53 to manage the DNS for the domain, make sure you set createRoute53Record: false in your serverless.yml file. This is what was causing the error for me.

@chearmstrong if you did the original create_domain on the previous version you may need to delete the domain and then re-create it.

@chearmstrong if you did the original create_domain on the previous version you may need to delete the domain and then re-create it.

I recently upgraded from serverless-domain-manager": "^3.3.2" to "serverless-domain-manager": "^4.1.1" in my Node.js Lambda app, and the domain had been originally created using the older version of this plugin. I just manually deleted the custom domain mapping in the AWS console at https://console.aws.amazon.com/apigateway/main/publish/domain-names?domain=<your-company-domain-here>&region=us-east-1 and then it worked.

Not sure if it matters but in my serverless.yml I was mapping the customDomain to nothing, like so, see the basePath:

customDomain:
    domainName: XYZ.${self:custom.domainName.${self:provider.stage}}
    stage: ${self:provider.stage}
    basePath:
    certificateName: "*.${self:custom.domainName.${self:provider.stage}}"
    createRoute53Record: true
    endpointType: 'regional'
    securityPolicy: tls_1_2

I wanted to add my own problem/solution set in case it helps someone. In my case I fundamentally didn’t understand the difference between rest and http for the API type. My APIs were being served over http and configured using the http keyword so I should use apiType=http right? Nope!

Turns out my functions are actually configured to use rest, and so it was failing to connect the domain that was created with http to the services that were created with rest (or something like that).

Just in case it might help someone (may not be the same issue as the OP).

In my case, I was migrating from REST API to HTTP API, the account that ran the sls deploy didn’t have APIGateway permission (the plugin didn’t say anything about permission but just the Unable to setup base domain mappings), I assigned apigateway admin policy then it worked, didn’t bother investigate what exactly permission was needed.

It will be helpful if the plugin can print out more error information (if possible)

Added a comment on another similar issue here: https://github.com/amplify-education/serverless-domain-manager/issues/381#issuecomment-735318565

Might help someone in the future.

I’m running into the same error but not sure if what I’m trying to do is legal: I have two stacks (two repo, with two serverless.yml), I wanted to use the same domain for both of them and just change the basePath.

In my two serverless.yml I have:

custom:
  customDomain:
    domainName: example.com
    basePath: myServiceA      # or myServiceB in the other file
    certificateName: 'example.com'
    createRoute53Record: false
    endpointType: 'regional'
    securityPolicy: tls_1_2
    apiType: http

For the first stack, everything went ok (create_domain followed by deploy). In the second stack, when I try to deploy I run into:

Unable to setup base domain mappings for <domain>

is this a bug? Or am I not supposed to share the same domain?

thanks

edit: yeah you can do it. Just rolled back to serverless-domain-manager@3 and everything’s working fine 😃

I’m getting this error and I’m not sure why.

  Error: Error: Unable to setup base domain mappings for <domain>
      at ServerlessCustomDomain.<anonymous> (/Users/chearmstrong/Git/voice-control-google/node_modules/serverless-domain-manager/dist/index.js:142:27)
      at Generator.throw (<anonymous>)
      at rejected (/Users/chearmstrong/Git/voice-control-google/node_modules/serverless-domain-manager/dist/index.js:5:65)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)

My config:

  customDomain:
    apiType: http
    domainName: <domain>
    stage: prod-green
    endpointType: regional
    createRoute53Record: true
    hostedZoneId: <id>
    enabled: true

The custom domain in the AWS console is showing as regional. If I try to configure the mappings manually, I get this error:

image

Any ideas?

Following up the issue, my fault. Note that the custom domain must be configured in the same serverless.yaml file that uses the API Gateway in the first place.

Thank you for the great work on supporting the websocket API Gateway 😃