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

Unable to setup base domain mappings for <domain> #333

Closed
claudio-petrini opened this issue May 7, 2020 · 23 comments
Closed

Unable to setup base domain mappings for <domain> #333

claudio-petrini opened this issue May 7, 2020 · 23 comments
Labels

Comments

@claudio-petrini
Copy link

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.

@claudio-petrini
Copy link
Author

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 :)

@jasontll
Copy link

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 :)

I am having the problem after updated to the latest version of serverless-domain-manager.
What do you mean by having the api gateway and custom domain in the same serverless.yaml?

@claudio-petrini
Copy link
Author

Hi @jasontll,
from my understanding the serverless-domain-manager needs to find the WebsocketsApi resource inside the CloudFormation stack you're using.
So probably the serverless.yml file on which you're using the domain manager plugin doesn't define this resource.

Let me know if this helps, I'll be happy to provide support :)

@jasontll
Copy link

I wasn't using WebsocketsApi at all, just regular functions with http triggers. I have been running the system without any problem for almost a year and only yesterday when I decided to upgrade to the version 4.0.0 then I start getting the error. It has something to do with the basepath apparently. It was doing a check on the basepath value:

Serverless: [AWS apigatewayv2 200 0.263s 0 retries] getApiMappings({ DomainName: '<my-domain>' })
Serverless: [AWS apigateway undefined 0.004s 0 retries] updateBasePathMapping({
  basePath: '',
  domainName: '<my-domain>',
  patchOperations: [
    { op: 'replace', path: '/basePath', value: '(none)' },
    [length]: 1
  ]
})
Serverless Domain Manager: Error: <my-domain>:  UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.basePath
Serverless Domain Manager: Error: <my-domain>:  Error: Error: <my-domain>: Unable to update basepath mapping.

There's a solution in post #332 . I rolled back to 3.3.2 and it worked fine for me, I think the patch will come out soon.

@chearmstrong
Copy link

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?

@cbschuld
Copy link

@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
Copy link

Will give that a try. Thanks.

@Pitasi
Copy link

Pitasi commented May 15, 2020

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 :)

@joquijada
Copy link

@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=&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

@isupremedyou
Copy link

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.

@AwolDes
Copy link

AwolDes commented Nov 29, 2020

Added a comment on another similar issue here: #381 (comment)

Might help someone in the future.

@jshhrrsn
Copy link

jshhrrsn commented Jan 9, 2021

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 :)

@Pitasi - I know it's sometime later - but that is exactly what I'm attempting... Did you have any success, or was this setup not the correct approach?

@Pitasi
Copy link

Pitasi commented Jan 10, 2021

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 :)

@Pitasi - I know it's sometime later - but that is exactly what I'm attempting... Did you have any success, or was this setup not the correct approach?

The yaml was correct, I just kept using serverless-domain-manager@3 instead of upgrading to the latest version. I'm not sure if they ever fixed this problem since I'm not working on that project anymore.

@fc-udaysolanki
Copy link

fc-udaysolanki commented Mar 10, 2021

Might help someone in the future.

In our case , it was domainName, we have used caps Letter in it.
So when we create domain using sls create_domain, it will convert domainName to small-case
and when we tried to sls deploy , it was unable to map domain to api
we then change domainName to all small-case and it was working

@EbenZhang
Copy link

EbenZhang commented Apr 28, 2021

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)

@stefan-rode
Copy link

I also found out, that when there's no API endpoint defined yet in the serverless.yml under functions, serverless does not create a stage in the ApiGateway and then the base domain mapping cannot be created, because that needs to reference a stage.

@ejoncas-rivalbet
Copy link

For me the problem was I was not configuring the stage property at both provider level and customDomain.

Even though i was passing sls deploy --stage prod my config was defaulting to dev which caused a mixed on configuration that then triggered this problem.

My provider was:

provider:
  name: aws
  runtime: python3.7
  region: ap-southeast-2

My custom block was:

   customDomain:
     domainName: xxxxxx.com
     certificateName: xxxxxx.com
     stage: ${self:provider.stage}
     createRoute53Record: true

When I changed my provider to:

provider:
  name: aws
  runtime: python3.7
  region: ap-southeast-2
  stage: ${opt:stage,'dev'} (THIS LINE FIXED IT ALL!)

Hope it helps!

@deepankarm
Copy link

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

@nikoskip
Copy link

nikoskip commented Apr 19, 2022

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.

@JakeDluhy
Copy link

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).

@cabal-daniel
Copy link

I got this error because I was using an expired cert

@AhmedSaleemKhan
Copy link

what we havent craeted the custom domain name and we want to use the default domain what we will be using in the serverless file???

@YazidHamdi
Copy link

Special case: setting up a dev.subdomain.domain.com (one level down)

Still looking for an answer, I had the same issue without much of a useful message (just "Error: Unable to setup base domain mappings for ")

Then I used sls create_domain as described by users here, then I got: The certificate that is attached to your distribution doesn't cover the alternate domain name (CNAME) that you're trying to add. For more details, see: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-requirements (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidViewerCertificate;

What that meant is I needed to create a certificate for *.subdomain.domain.com in us-east-1 (oh yeah, it needs to be us-east-1). Then the deployment worked.

Then you place its ARN in your: custom.customDomain.certificateArn

While running sls create_domain does create the domain mapping in cloudformation, I still get

Error: Unable to setup base domain mappings for '<fulldomain>': Failed to find CloudFormation resources for '<fulldomain>': Failed to find a stack <stackname>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests