2
votes

i want to use custom domain name for my lambda api. i found plugin serverless-domain-manager. what i did is

  1. install plugin ,
  2. create custom domain name in aws/ api gateway :uat-api.mydomain.com
  3. create a dns record with point to my custom-domain name
  4. add custom confige to serverless.yml file
 custom:
        customDomain:
        domainName: uat-api.mydomain.com
        basePath: api
        certificateName: som-cert-name.com
        certificateArn: arnid
        createRoute53Record: true
        endpointType: ‘regional’
        securityPolicy: tls_1_2
        apiType: rest
        autoDomain: false
        hostedZoneId: Z1I1XQT4F25333

No when i run sls create_domain i got error:

[AWS apigatewayv2 403 3.044s 0 retries] getDomainName({ DomainName: ‘uat-api.mydomain.com’ })

  Error --------------------------------------------------
 
  Error: Unable to fetch information about uat-api.mydomain.com
      at APIGatewayWrapper.<anonymous> (/Users/../node_modules/serverless-domain-manager/dist/src/aws/api-gateway-wrapper.js:112:27)
      at Generator.throw (<anonymous>)
      at rejected (/../node_modules/serverless-domain-manager/dist/src/aws/api-gateway-wrapper.js:6:65)
      at process._tickCallback (internal/process/next_tick.js:68:7)

So , whats wrong and does i miss something?

1
I ran into this issue. Set SLS_DEBUG=* and check those logs. In my case, it was because I needed to add API Gateway access to my IAM user.Preston Hager

1 Answers

0
votes

I know that's the configuration provided on the npm/github readme, but frankly it seems like overkill.

plugins:
  - serverless-domain-manager
custom:
  customDomain:
    domainName: 'test.****.io'
    basePath: 'somePath'
    stage: ${self:provider.stage}
    createRoute53Record: true

This is the configuration I use - the domain is hosting in Route53 but otherwise I don't need to mess with the AWS console at all when I create a new subdomain (in this case create_domain did everything).