npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-custom-domain

v4.0.0

Published

Set up and cut over custom domains for API Gateway

Downloads

1,761

Readme

serverless-plugin-custom-domain

This is a plugin for Serverless that injects a CloudFormation Custom Resource in your deployed stack that sets up a base path mapping between the ApiGateway::Deployment that Serverless creates, and an API Gateway Custom Domain.

4.0.0

This version uses a newer version of add-custom-resource which requires a newer Node.js runtime.

3.0.0

This release brings in a new version of add-custom-resource that updates the runtime version of Lambda. This means your custom resources may re-execute, and should be idempotent. No actual changes in this library have been made, but this is just to be cautious.

Upgrading from 1.x

A bug in 1.x caused an extra, unused LogGroup to be created, called /aws/lambdaservice-stage-CustomBasePathMa-- instead of /aws/lambda/service-stage-CustomBasePathMa--. However, AWS automatically creates a LogGroup for your functions with the correct name. This means that any deployments using 1.x have two LogGroups. After upgrading to 2.x+, deployments may fail due to a CloudFormation error that "the log group already exists". Sorry about this! It doesn't always happen, but thankfully, the fix is pretty straightforward if it does and it should only happen the one time.

  • delete the log group (it's the 'correctly' named one, e.g. /aws/lambda/service-stage-CustomBasePathMa--)
  • redeploy!
  • feel free to delete the other, incorrectly named log group, it was never used too

Usage


service: my-service

plugins:
  - serverless-plugin-custom-domain

custom:
  domain: "${opt:region}.myservice.foo.com"

Advanced Usage

custom.domain can also be an object, with the following propeties:

  • name: the domain name, same as the above string e.g. ${opt:region}.myservice.foo.com
  • basePath: a custom base path, instead of the default (none) - a base path is a prefix e.g. /v1

Notes

Why a Custom Resource?

CloudFormation supports ApiGateway::BasePathMapping resources but I found they frequently fail to update correctly. Implementing the (relatively simple) logic to get-and-update-or-create combined with a remove hook for cleanup has proven to be more reliable.

Setting up the Custom Domain

These take a long time to provision and are long-lived persistent resources that have Route53 entires pointing at them as well as ACM certificates that have to be requested and approved. You should manage these outside of Serverless, either via CloudFormation or something like Terraform.