2

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?

Seifolah
  • 341
  • 3
  • 14
  • 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 Oct 26 '21 at 19:09

2 Answers2

0

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

mcatee
  • 41
  • 4
  • Thanx mcatee but it doesn't help. – Seifolah Feb 07 '21 at 05:45
  • @Seifolah is your DNS record hosted with Route 53 or is it on a non-AWS service? – mcatee Feb 07 '21 at 09:33
  • @mactee yes, it hosted on Route53. also i created a custom domain in APi Gateway manually .I thought it may be a permission problem so granted full permission on Route53 ,Cloudfront ,... but didn't help. My Important question is what i should to de on aws side before run sls create_domain? – Seifolah Feb 07 '21 at 12:02
  • @Seifolah when you say you created a custom domain: had you created uat-api.mydomain.com or just mydomain.com? – mcatee Feb 09 '21 at 03:14
  • i have mydomain.com as a Hosted Zone and also have uat-api.mydomain.com as A Record in mydomain.com hosted zone. dns record is alias to my custom domain in api gateway[uat-api.mydomain.com ]. what thing that me be notable is that in Route53 i have nothing in Registered Domain ! – Seifolah Feb 09 '21 at 08:39
0

The AWS IAM user that using for sls deploy is not able to access the API Gateway info. You need to add that

ERROR: User is not authorized to perform apigateway::GET on resource

Rajish sani
  • 476
  • 7
  • 11