serverless-domain-manager
serverless-domain-manager copied to clipboard
Error: Unable to setup base domain mappings for api.test.domain.com
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 Error: Unable to setup base domain mappings for api.test.domain.com
Note I have read through the many other issues on this exact topic and am yet to find a solution. This plugin worked when I was initially using a REST API. I switched over to using the httpApi and have since been having this issue. I can manually create the domain mapping and then I can use the custom domain.
Command Run
sls deploy
Console Output
Error ---------------------------------------------------
Error: Unable to setup base domain mappings for api.test.domain.com
at ServerlessCustomDomain.<anonymous> (/Users/chris/workspace/****/phoenix-services/node_modules/serverless-domain-manager/dist/src/index.js:270:27)
at Generator.throw (<anonymous>)
at rejected (/Users/chris/workspace/****/phoenix-services/node_modules/serverless-domain-manager/dist/src/index.js:6:65)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.18.1
Framework Version: 2.66.1 (local)
Plugin Version: 5.5.1
SDK Version: 4.3.0
Components Version: 3.18.0
error Command failed with exit code 1.
Domain Manager Configuration
custom:
customDomain:
apiType: http
endpointType: regional
domainName: ${self:custom.apiDomain.${self:provider.stage}}
basePath: ""
stage: ${self:provider.stage}
createRoute53Record: true
securityPolicy: tls_1_2
autoDomain: true
Versions
- Domain Manager version(s): 5.2.0
- Node/npm version: Node 14
- Serverless Version: 2.66.1
- Lambda Code Javascript
Possible Solution
Additional context/Screenshots
When running a deploy with SLS_DEBUG=* I see the following.
Serverless Domain Manager: Error: api.test.domain.com: Error: Failed to find a stack phoenix-api-service-organisations
Serverless Domain Manager: Error: api.test.domain.com: Error: Failed to find CloudFormation resources for api.test.domain.com
Hi @chris-hinds
Have you tried to use allowPathMatching option?
Hi @chris-hinds Have you tried to use
allowPathMatchingoption?
Hi @rddimon I have tried this yes, and it doesn't seem to make any difference in my situation.
Diggin into this further and after lots of console logs, This is failing for me because of the below error
Serverless Domain Manager: Error: error getting stack info: Error: Failed to find CloudFormation resources with an error: ValidationError: Resource HttpApi does not exist for stack <stack-name>
I wonder if this is because my stacks all share a single ApiGateway, so the CF stack I am trying to deploy here doesn't have a HttpApi resource. It's just has Routes that attack to an existing API Gateway which is deployed by a separate stack.
Hi @chris-hinds Could you please provide a full sls config? With functions and custom configs
@rddimon before I do that I have just removed the Serverless domain manager config/plugin from each of my stacks, as the domain mapping has already been setup.
I am wondering if there is an issue where multiple stacks share the same domain name and there is only 1 single API mapping, i.e. no base paths are set I juts map the root domain to the api stage
For what its worth this is what a typical Serverless config file of mine looks like. My repo has about 12 of these, each with varying number of functions.
org: XXXX
app: XXXX
service: webhook-handler
variablesResolutionMode: 20210326
projectDir: ../
useDotenv: true
package:
individually: true
provider:
stackName: ${self:org}-${self:app}-${self:service}
stage: ${opt:stage}
name: ${file(../commonServerlessConfig.yml):name}
region: ${file(../commonServerlessConfig.yml):region}
runtime: ${file(../commonServerlessConfig.yml):runtime}
memorySize: ${file(../commonServerlessConfig.yml):memorySize}
timeout: ${file(../commonServerlessConfig.yml):timeout}
versionFunctions: ${file(../commonServerlessConfig.yml):versionFunctions}
httpApi: ${file(../commonServerlessConfig.yml):httpApi}
plugins:
- serverless-bundle
- serverless-offline
- serverless-domain-manager
custom:
bundle: ${file(../commonServerlessConfig.yml):bundle}
apiDomain: ${file(../commonServerlessConfig.yml):apiDomain}
customDomain: ${file(../commonServerlessConfig.yml):customDomain}
functions:
webhookHandler:
handler: src/infra/http/webhook.handler
name: api-handler-webhooks
description: handles incoming webhooks
environment:
XXXX: ${cf:XXXX.XXXX}
XXXX: ${cf:XXXX.XXXX}
XXXX: ${cf:XXXX.XXXX}
events:
- httpApi:
path: "/webhooks/XXXX"
method: post
This is what my custom domain config looks like, which is simply imported from a common file
apiDomain:
dev: XXXX.com
prod: XXXX.com
customDomain:
apiType: http
endpointType: regional
domainName: ${self:custom.apiDomain.${self:provider.stage}}
basePath: ""
# stage: ${self:provider.stage}
createRoute53Record: true
securityPolicy: tls_1_2
# API Gateway imports
httpApi:
id:
Fn::ImportValue: ApiGatewayId
In this block of code, we are trying to retrieve CF data
You can debug this code, find out what is wrong and send us a pr with the fix In another case, I need to reproduce the same situation on my end to find a problem But I don't have time for it
The config looks fine
I'm guessing there is a CF stack created by API type rest
And, when you have switched to the HTTP, the plugin can find this CF stack but it does not have LogicalResourceId=HttpApi
For the REST is should be ApiGatewayRestApi
@rddimon I am also getting the same exception. Is there any solution for this?
Hi @rddimon I am also getting this exception and we need to stay with serverless v2 for this time. Any workaround?
Found my issue: I first did create_domain without endpointType: regional which resulted in the domain created as edge in API Gateway. I just had the deleted it and redeploy.
Putting SLS_DEBUG=*did help.
Hi @chris-hinds
Hope you have solved this issue.
We are not supporting 5.x anymore please try our latest version 6.x and let us know in case of any issues