Closed promediacorp closed 5 years ago
Having the same problem! Let me know if you were able to sort it out.
Hi there! Unfortunately, I'm not able to reproduce this error. Could you give me more information about how to reproduce it?
As @jackrg94 stated, we make the call to getBasePathMappings
on the domain name in order to check if the basepath already exists. If the call to make the basepath fails (i.e. returns an error), we throw an error. Reasons why the getBasePathMappings
call would fail are usually either related to the domain name not existing or incorrect permissions. Are either of those situations applicable in your cases?
We've heard from other users about how error messages aren't as descriptive as they'd like - we'll roll out a PR in the near future logging the error messages received from making AWS calls if SLS_DEBUG
is set. We'll also be sure to update the README with the permissions required.
you can also get this error if you do not call sls create_domain
Hi everyone! We rolled out better debug messages in 3.2.1 that should help identify why you're experiencing this issue (incorrect permissions or not finding the domain as a result of not running sls create_domain
as @rgillen stated). Let us know what's going on!
@captainsidd 😕 , still end up with Error: Unable to get BasePathMappings
; simply trying to point route 53 A record alias to the cloudfront distribution.createRoute53Record: true
doesnt seem to change anything in the dns. sls create_domain
by itself yields Error: Failed to create custom domain
@promediacorp Hmmm, what happens when SLS_DEBUG is set? The debug statements we added only print if that is set. Also, would you mind listing your permissions? It would really help trying to find the root cause here, as I'm not able to reproduce the bug you've found.
It's interesting you state that sls create_domain
also fails. Was that command working with previous versions?
@captainsidd This is what I'm getting (with SLS_DEBUG=*). Note that 'api.my.domain' does not currently have a CNAME record (or any other) in Route53
Serverless: [AWS apigateway 404 0.479s 0 retries] getBasePathMappings({ domainName: 'api.my.domain' }) Serverless Domain Manager: NotFoundException: Invalid domain name identifier specified
Error --------------------------------------------------
Error: Unable to get BasePathMappings for api.my.domain.
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
Error: Error: Unable to get BasePathMappings for api.my.domain.
at ServerlessCustomDomain.
I continue to intermittently experience this issue. Logging into API gateway and deleting the base path mapping only, then retry, this seems to resolve the issue.
@FluxAugur have you run sls create_domain
? If so, I'd be very curious as to why route53 records for your domain were not created and what logs showed up in SLS_DEBUG mode for create_domain
@captainsidd I have. It fails. There are no CNAME records other than the domain validation record. Here's the debug info.
Serverless: Invoke create_domain
Serverless: [AWS apigateway 404 0.612s 0 retries] getDomainName({ domainName: 'api.my.domain' })
Serverless Domain Manager: NotFoundException: Invalid domain name identifier specified
Serverless: Selected specific certificateArn
Error --------------------------------------------------
Error: Failed to create custom domain api.my.domain
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
Error: Error: Failed to create custom domain api.my.domain
at ServerlessCustomDomain.<anonymous> (/Users/lastson/Code/Repos/sandbox/serverless-api-gateway-domain/node_modules/serverless-domain-manager/dist/index.js:335:15)
at Generator.throw (<anonymous>)
at rejected (/Users/lastson/Code/Repos/sandbox/serverless-api-gateway-domain/node_modules/serverless-domain-manager/dist/index.js:15:34)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
@captainsidd I just tried from a completely new project with the certificate still 'Issued' and not in use. No CloudFront distribution exists. Route53 hosted zone was new (with only 4 NS records and 1 SOA record. It succeeds. Here's all the relevant details.
# serverless.yml
service: products-service
provider:
name: aws
runtime: python3.6
stage: dev
region: us-east-1
environment:
SERVICE_NAME: ${self:service}
custom:
customDomain:
domainName: api.my.domain
basePath: products
stage: ${self:provider.stage}
createRoute53Record: true
functions:
hello:
handler: handler.hello
events:
- http: GET hello
plugins:
- serverless-domain-manager
Serverless: Invoke create_domain
Serverless: [AWS apigateway 404 0.168s 0 retries] getDomainName({ domainName: 'api.my.domain' })
Serverless Domain Manager: NotFoundException: Invalid domain name identifier specified
Serverless: [AWS acm 200 0.137s 0 retries] listCertificates({ CertificateStatuses: [ 'PENDING_VALIDATION', 'ISSUED', 'INACTIVE', [length]: 3 ] })
Serverless: [AWS apigateway 201 2.874s 0 retries] createDomainName({ certificateArn:
'<valid certificate ARN>',
domainName: 'api.my.domain',
endpointConfiguration: { types: [ 'EDGE', [length]: 1 ] },
regionalCertificateArn: undefined })
Serverless: [AWS route53 200 0.152s 0 retries] listHostedZones({})
Serverless: [AWS route53 200 0.139s 0 retries] changeResourceRecordSets({ ChangeBatch:
{ Changes:
[ { Action: 'UPSERT',
ResourceRecordSet:
{ AliasTarget:
{ DNSName: '<valid distribution>.cloudfront.net',
EvaluateTargetHealth: false,
HostedZoneId: 'Z2FDTNDATAQYW2' },
Name: 'api.my.domain',
Type: 'A' } },
{ Action: 'UPSERT',
ResourceRecordSet:
{ AliasTarget:
{ DNSName: '<valid distribution>.cloudfront.net',
EvaluateTargetHealth: false,
HostedZoneId: 'Z2FDTNDATAQYW2' },
Name: 'api.my.domain',
Type: 'AAAA' } },
[length]: 2 ],
Comment: 'Record created by serverless-domain-manager' },
HostedZoneId: '<valid hosted zone ID' })
Serverless: Custom domain api.my.domain was created.
New domains may take up to 40 minutes to be initialized.
After create_domain successfully completes, sls deploy
completes with no issues.
Based on the above, I'm assuming that you can't use this plugin on a hosted zone that already has apex alias records (A ALIAS/AAAA ALIAS)?
The instance where create_domain fails is where I already have an existing hosted zone with apex records (e.g. my.domain) with a certificate for my.domain and a CloudFront distribution listing my.domain as the only CNAME, and I'm trying to add api.my.domain with this plugin.
Is this not the correct usage? Why would this create A/AAAA records instead of just CNAME pointing api.my.domain to the
I hope the above makes some modicum of sense. And thanks in advance for your help.
I got it working. Apparently, there was some issue with the certificate. When I deleted it and created a new one, like magic, everything worked. I still thought you could only have one apex record per hosted zone (DNS namespace). Or doesn't this include apex alias records?
I'm still having this problem.
service: my-serverless
provider:
name: aws
runtime: nodejs8.10
stage: ${env:STAGE}
region: eu-west-1
apiGateway:
minimumCompressionSize: 1024
plugins:
- serverless-dotenv-plugin
- serverless-nextjs-plugin
- serverless-domain-manager
- serverless-offline
custom:
serverless-nextjs:
nextConfigDir: ./
customDomain:
domainName: serverless-${env:STAGE}.mywebsite.com
certificateName: 'mywebsite.com'
createRoute53Record: true
package:
# exclude everything
# page handlers are automatically included by the plugin
exclude:
- ./**
Whenever I create a new stack, I get
Error: Unable to get BasePathMappings for serverless-dev.mywebsite.com
Make sure you run sls create_domain
before running sls deploy
.
That did the trick for me.
Yeah, I just started doing that and it seems to fix the problem.
Is that how it's meant to work? I didn't see anything about that in the docs.
Edit: Just re-read the docs. It's there. 🤦♂️
This erro happens when I tried to delete all environment (i.e., I delete cf stack) and tried deploy again with sls deploy. @felimartina solutions works!
I found that I had to set endpointType
(default is 'edge', I needed 'regional') to solve this error.
It's very confusing that I had to create first the domain, and then deploy. In my opinion this should be at least logged in the output of the failing create_domain.
Me to i had the same problem. The problem was that i used another AWS account. Be sure you use your right aws account . Verify it here: C:/Users/USER1/.aws/credentials
You should add endpointType, like this:
domainName: dev.domain.com
basePath: ''
certificateName: '*.domain.com'
stage: ${self:provider.stage}
createRoute53Record: true
endpointType: regional
Then:
sls create_domain
sls deploy -v
Had a bit of a hard time with this error, I beleieve it was because I changed the region from us-east-1
to eu-west-1
. Althought I had run sls remove
on us-east-1
I think I forgot to to run sls delete_domain
as well.
This sequence worked for me:
sls delete_domain
sls create_domain
sls deploy
I am getting the same issue after change the region from us-east-1 to us-west-2. Now if I try sls create_domain --stage mysatge
I am getting Failed to create custom domain ....
. If I run sls delete_domain --stage devig
I am getting Serverless: Unable to delete custom domain ...
. If I try to deploy this is what I get Unable to get BasePathMappings for ...
and cant deploy.
We turn on autoDomain flag, so the create_domain should be executed as a part of sls deploy command per documentation. Not sure why it doesn't work as expected.
@hoang-innomizetech autoDomain
setting was just released yesterday. Do you have any more details about what is failing for you?
I am getting below error Serverless Domain Manager: NotFoundException: Invalid domain name identifier specified
Then I have to create domain before deploying sls service
Note. You need to have the domain name or its parent as a hosted zone in the same AWS account where you have your API gateway. Then use the command sls create_domain and once it is initialised (it may take up to 40 mins), then run sls deploy.
So, problem with us was , we have not used small-case for domain name. I changed it to small-case and now it is working fine
Setting the string to empty as indicated in the examples, causes the the error.
Error: Unable to get BasePathMappings for domain.com
Also, no record is created in Route53
Missing something?