Code Monkey home page Code Monkey logo

lambda-custom-domain's Introduction

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

lambda-custom-domain's People

Contributors

taherbs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

medbensalem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.