Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless custom domain

I want to setup a custom domain with the serverless framework and AWS.

This is what I have in serverless.yml

service: chapiLabs-rest-api

plugins:
  - serverless-domain-manager
  - serverless-express

custom:
  customDomain:
    domainName: chapitime.chapilabs.com
    basePath: ''
    stage: ${self:provider.stage}
    certificateName: '*.chapilabs.com'
    createRoute53Record: true

package:
  exclude:
    - node_modules
  include:
    - dist

provider:
  name: aws
  runtime: nodejs8.10

webpackIncludeModules:
  forceInclude:
    - mysql
    - mysql2
    - sequelize

functions:
  get:
    handler: dist/get.get
    events:
      - http:
          path: v1/client/{id}
          method: get
          request:
            parameters:
              paths:
                id: true
  create:
    handler: dist/auth.auth
    events:
      - http:
          path: v1/auth
          method: post

I used this npm package as plugin: https://github.com/amplify-education/serverless-domain-manager

I added a certificate via DNS using CloudFlare

enter image description here

Then I made a deploy and got the next log.

enter image description here

In cloudflare I added a CNAME to add the ACM validation and another CNAME pointing cloudfront.

enter image description here

But the domain name is not working. Any ideas why? I didn't bought the domain in AWS.

like image 675
fcpauldiaz Avatar asked Jun 18 '18 19:06

fcpauldiaz


1 Answers

After some deployments the cloudfront url changed and I didn't noticed. I just updated the CNAME record in CloudFlare and it started working.

like image 68
fcpauldiaz Avatar answered Nov 06 '22 18:11

fcpauldiaz