forked from pavel-ignatiev/serverless-domain-manager
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squash all previous history. Up to this point all development done at Amplify Inc. with individual contributions from: * wongJonathan 71 commits / 2,051 ++ / 1,346 -- * jconstance-amplify 3 commits / 28 ++ / 22 --
- Loading branch information
0 parents
commit 9a1e2c1
Showing
10 changed files
with
688 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends: | ||
- airbnb | ||
rules: | ||
strict: off | ||
env: | ||
mocha: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea | ||
node_modules/ | ||
coverage | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
language: node_js | ||
node_js: | ||
- 7.7.1 | ||
install: | ||
- npm install | ||
script: | ||
- npm run lint | ||
- bash scripts/versionCheck.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST | ||
- npm test | ||
deploy: | ||
provider: npm | ||
email: $NPM_EMAIL | ||
api_key: $NPM_KEY | ||
on: | ||
branch: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright 2017 Amplify Education, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# serverless-domain-manager | ||
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: | ||
* [nodejs](https://nodejs.org/en/download/) | ||
* [npm](https://www.npmjs.com/get-npm?utm_source=house&utm_medium=homepage&utm_campaign=free%20orgs&utm_term=Install%20npm) | ||
* [serverless](https://serverless.com/framework/docs/providers/aws/guide/installation/) | ||
|
||
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: | ||
```yaml | ||
plugins: | ||
- serverless-domain-manager | ||
custom: | ||
customDomain: | ||
basePath: | ||
domainName: | ||
stage: | ||
``` | ||
|
||
## 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. |
Oops, something went wrong.