Code Monkey home page Code Monkey logo

serverless-domain-manager's Introduction

serverless-domain-manager

serverless Build Status npm version MIT licensed Codacy Badge npm downloads

Create custom domain names that your lambda can deploy to with serverless. Allows for base path mapping when deploying and deletion of domain names.

About Amplify

Amplify builds innovative and compelling digital educational products that empower teachers and students across the country. We have a long history as the leading innovator in K-12 education - and have been described as the best tech company in education and the best education company in tech. While others try to shrink the learning experience into the technology, we use technology to expand what is possible in real classrooms with real students and teachers.

Learn more at https://www.amplify.com

Getting Started

Prerequisites

Make sure you have the following installed before starting:

The IAM role that is deploying the lambda will need the following permissions:

acm: ListCertificate
apigateway: GET
apigateway: POST
route53: ListHostedZones
route53: ChangeResourceRecordSets

Installing

# From npm (recommended)
npm install serverless-domain-manager

# From github
npm install https://github.com/amplify-education/serverless-domain-manager.git

Then make the following edits to your serverless.yaml file:

plugins:
  - serverless-domain-manager

custom:
  customDomain:
    basePath:
    domainName:
    stage:
    certificateName:
    createRoute53Record: true

For example:

custom:
  customDomain:
    basePath: "dev"
    domainName: serverless.foo.com
    stage: dev

If certificateName is not provided, the certificate will be chosen using the domain name. If certificateName is blank, an error will be thrown. If createRoute53Record is blank or not provided, it defaults to true.

Running

To create the custom domain:

serverless create_domain

To deploy with the custom domain:

severless deploy

To remove the created custom domain:

serverless delete_domain

How it works

Creating the custom domain takes advantage of Amazon's Certificate Manager to assign a certificate to the given domain name. Based on already created certificate names, the plugin will search for the certificate that resembles the custom domain's name the most and assign the ARN to that domain name. The plugin then creates the proper CNAMEs for the domain through Route 53. Once the domain name is set it takes up to 40 minutes before it is initialized. After the certificate is initialized, sls deploy will create the base path mapping and assign the lambda to the custom domain name through Cloudfront.

Running Tests

To run the test:

npm test

All tests should pass.

If there is an error update the node_module inside the serverless-vpc-discovery folder:

npm install

Known Issues

  • (5/23/2017) CloudFormation does not support changing the base path from empty to something or vice a versa. You must run sls remove to remove the base path mapping.
  • (5/23/2017) Amazon Certificate Manager only allows certificates from the us-east-1 region certificates for use with CloudFront, and by extension, API Gateway Custom Domains (Results in a BadRequestException: Certificate name must be specified...).

Responsible Disclosure

If you have any security issue to report, contact project maintainers privately. You can reach us at [email protected]

Contributing

We welcome pull requests! For your pull request to be accepted smoothly, we suggest that you:

  1. For any sizable change, first open a GitHub issue to discuss your idea.
  2. Create a pull request. Explain why you want to make the change and what it’s for. We’ll try to answer any PR’s promptly.

serverless-domain-manager's People

Contributors

wongjonathan avatar jconstance-amplify avatar mscifo avatar aoskotsky-amplify avatar jerep6 avatar sidgonuts avatar alnutile avatar wrobel avatar codacy-badger avatar unlockdsre avatar

Watchers

James Cloos avatar György Balássy avatar  avatar

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.