Skip to content

taherbs/lambda-custom-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom domain name for Lambda

MIT licensed

With Serverless, it's easier than ever to deploy production-ready API endpoints. However, using AWS API Gateway results in odd hostnames for your endpoints. Further, these hostnames will change if you remove and redeploy your service, which can cause problems for existing clients.

This project will help you set-up a mapping between custom domain name to your serverless endpoint.

Prerequisites:

Quick Start

Watch the video guide here or follow the steps below to create and deploy your first serverless microservice in minutes.

  1. Install serverless and serverless-domain-manager via npm:
# Install serverless 
npm install -g serverless
# Install serverless-domain-manager
npm install serverless-domain-manager --save-dev
  1. Set-up your Provider Credentials.

Watch the video on setting up credentials

  1. Create DNS ZONE and Certificate

Update the config.yaml and domain.yaml files variables and set the project name, domain zone and cert name according to your project preferences.
Note that you'll need to keep the region to us-east-1 (N.Virginia) as this is the only region that works with API Gateway.

sceptre --dir ./aws-resources launch-env infrastructure
  1. Configure service:

Get created resources outputs

sceptre --dir ./aws-resources describe-stack-outputs infrastructure domain

Then update the env-vars.yaml properly according to the data outputted by the previous command.

  1. Create the custom domain:
serverless create_domain
  1. Deploy The Service:

Use the command below when you want to deploy your service or have made changes to your Functions, Events or Resources in serverless.yml.

serverless deploy -v

Other useful commands

  • Deploy a Function:

    Use this to quickly upload and overwrite your AWS Lambda code on AWS, allowing you to develop faster.

    serverless deploy function -f hello
  • Invoke a Function:

    Invokes an AWS Lambda Function on AWS and returns logs.

    serverless invoke -f hello -l
  • Fetch a Function Logs:

    Open up a separate tab in your console and stream all logs for a specific Function using this command.

    serverless logs -f hello -t
  • Remove the created custom domain:

    serverless delete_domain
  • Remove the Service:

    Removes all Functions, Events and Resources from your AWS account.

    serverless remove

Useful documentation and guides

About

This project will help you set-up a mapping between custom domain name to your serverless endpoint.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published