Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into katafalkas-support-…
Browse files Browse the repository at this point in the history
…nested-stacks

# Conflicts:
#	README.md
#	index.ts
#	package-lock.json
#	package.json
#	src/DomainInfo.ts
#	test/unit-tests/index.test.ts
  • Loading branch information
rddimon committed Sep 16, 2020
2 parents 735e57f + df84af5 commit f356f5a
Show file tree
Hide file tree
Showing 62 changed files with 9,017 additions and 2,375 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -8,3 +8,5 @@ Fixes #0000

* Change 1
* Change 2

<!--- Please remember to allow edits from maintainers: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork --->
17 changes: 11 additions & 6 deletions .travis.yml
@@ -1,20 +1,25 @@
language: node_js
node_js:
- 10.4.0
- 10.4.0
before_install:
# Only deploy if the version number has changed
- |
if git diff --unified=0 $TRAVIS_COMMIT_RANGE package.json | grep version ; then
export VERSION_CHANGED="yes"
fi
- npm i -g npm@6.4.1
install:
- npm install
- npm install
script:
- npm run lint
- bash scripts/versionCheck.sh $TRAVIS_BRANCH $TRAVIS_PULL_REQUEST
- npm test
- npm run lint
- npm test
before_deploy:
- npm run build
- npm run build
deploy:
skip_cleanup: true
provider: npm
email: $NPM_EMAIL
api_key: $NPM_KEY
on:
branch: master
condition: "$VERSION_CHANGED == 'yes'"
55 changes: 54 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,60 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [4.2.2] - 2020-09-16

### Changed
- Fix for package build. Thank you @michaelgmcd ([#382](https://github.com/amplify-education/serverless-domain-manager/pull/382))

## [4.2.1] - 2020-09-16

### Changed
- Added support for using CloudFormation Fn::ImportValue. Thank you @sampsasaarela ([#220](https://github.com/amplify-education/serverless-domain-manager/pull/220)), @rddimon ([#380](https://github.com/amplify-education/serverless-domain-manager/pull/380))

## [4.2.0] - 2020-07-14

### Changed
- Added support for automatically creating/destroying custom domains on deploy/remove via the autoDomain option. Thank you @bryan-hunter ([#356](https://github.com/amplify-education/serverless-domain-manager/pull/356))

## [4.1.1] - 2020-05-25

### Changed
- Fix support for TLS 1.0 regional domains which were broken in the 4.0.0 release. Discovered by @jufemaiz ([#348](https://github.com/amplify-education/serverless-domain-manager/pull/348))

## [4.1.0] - 2020-05-18

### Changed
- Fixed issue when there are multiple pages of base path mappings. Also refactored how paging is handled throughout the code. Thanks @kzhou57 for discovering this ([#345](https://github.com/amplify-education/serverless-domain-manager/pull/345))

## [4.0.1] - 2020-05-12

### Changed
- Fix issue updating domains that use a blank base path. Thanks @fabiancook ([#337](https://github.com/amplify-education/serverless-domain-manager/pull/337))

## [4.0.0] - 2020-05-06

### Breaking Changes
- Regional domains with TLS 1.0 no longer work. Fixed in 4.1.1

### Added
- Add support for WebSocket and HTTP APIs. A domain name can be created for each API type (Rest, WebSocket, HTTP)
for up to 3 domain names in a single Serverless config. Thanks @TehNrd ([#319](https://github.com/amplify-education/serverless-domain-manager/pull/319))

## [3.3.2] - 2020-04-21

### Changed
- Fix CloudFormation stack's Outputs. Thanks @davidrosson ([#320](https://github.com/amplify-education/serverless-domain-manager/pull/320))
- Use pagination when there are too many certificates. Thanks @cbm-gplassard ([#315](https://github.com/amplify-education/serverless-domain-manager/pull/315))

## [3.3.1] - 2020-01-16

### Changed
- Fix AWS SDK initialization after internal change in serverless. Thanks @medikoo ([#307](https://github.com/amplify-education/serverless-domain-manager/pull/307))

## [3.3.0] - 2019-08-12

### Added
- Add ability to choose TLS version. Thanks @drexler ([#240](https://github.com/amplify-education/serverless-domain-manager/pull/240))

## [3.2.7] - 2019-08-02

Expand Down
63 changes: 58 additions & 5 deletions README.md
Expand Up @@ -58,7 +58,7 @@ plugins:
- serverless-domain-manager
```

Add the plugin configuration (example for `serverless.foo.com/api`).
Add the plugin configuration (example for `serverless.foo.com/api`). For a single domain and API type the following structure can be used.

```yaml
custom:
Expand All @@ -70,7 +70,39 @@ custom:
createRoute53Record: true
endpointType: 'regional'
securityPolicy: tls_1_2
apiType: http
apiType: rest
autoDomain: false
```

Multiple API types mapped to different domains can also be supported with the following structure. The key is the API Gateway API type.

```yaml
custom:
customDomain:
rest:
domainName: rest.serverless.foo.com
stage: ci
basePath: api
certificateName: '*.foo.com'
createRoute53Record: true
endpointType: 'regional'
securityPolicy: tls_1_2
http:
domainName: http.serverless.foo.com
stage: ci
basePath: api
certificateName: '*.foo.com'
createRoute53Record: true
endpointType: 'regional'
securityPolicy: tls_1_2
websocket:
domainName: ws.serverless.foo.com
stage: ci
basePath: api
certificateName: '*.foo.com'
createRoute53Record: true
endpointType: 'regional'
securityPolicy: tls_1_2
```

| Parameter Name | Default Value | Description |
Expand All @@ -87,6 +119,10 @@ custom:
| hostedZonePrivate | | If hostedZonePrivate is set to `true` then only private hosted zones will be used for route 53 records. If it is set to `false` then only public hosted zones will be used for route53 records. Setting this parameter is specially useful if you have multiple hosted zones with the same domain name (e.g. a public and a private one) |
| enabled | true | Sometimes there are stages for which is not desired to have custom domain names. This flag allows the developer to disable the plugin for such cases. Accepts either `boolean` or `string` values and defaults to `true` for backwards compatibility. |
securityPolicy | tls_1_2 | The security policy to apply to the custom domain name. Accepts `tls_1_0` or `tls_1_2`|
allowPathMatching | false | When updating an existing api mapping this will match on the basePath instead of the API ID to find existing mappings for an upsate. This should only be used when changing API types. For example, migrating a REST API to an HTTP API. See Changing API Types for more information. |
| autoDomain | `false` | Toggles whether or not the plugin will run `create_domain/delete_domain` as part of `sls deploy/remove` so that multiple commands are not required. |
| autoDomainWaitFor | `120` | How long to wait for create_domain to finish before starting deployment if domain does not exist immediately. |


## Running

Expand All @@ -107,8 +143,6 @@ 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 A Alias and AAAA Alias records 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. All resources are created independent of CloudFormation. However, deploying will also output the domain name and distribution domain name to the CloudFormation stack outputs under the keys `DomainName` and `DistributionDomainName`, respectively.

Note: In 1.0, we only created CNAME records. In 2.0 we deprecated CNAME creation and started creating A Alias records and migrated CNAME records to A Alias records. Now in 3.0, we only create A Alias records. Starting in version 3.2, we create AAAA Alias records as well.

### Behavior Change in Version 3

In version 3, we decided to create/update/delete all resources through the API. Previously, only the basepath mapping was managed through CloudFormation. We moved away from creating anything through the stack for two reasons.
Expand Down Expand Up @@ -139,7 +173,26 @@ npm install
```

## Writing Integration Tests
Unit tests are found in `test/unit-tests`. Integration tests are found in `test/integration-tests`. Each folder in `tests/integration-tests` contains the serverless-domain-manager configuration being tested. To create a new integration test, create a new folder for the `handler.js` and `serverless.yml` with the same naming convention and update `integration.test.js`.
Unit tests are found in `test/unit-tests`. Integration tests are found in `test/integration-tests`. Each folder in `tests/integration-tests` contains the serverless-domain-manager configuration being tested. To create a new integration test, create a new folder for the `handler.js` and `serverless.yml` with the same naming convention and update `deploy.test.ts` or create a separate one with the `test.ts` ending.

## Changing API Types
AWS API Gateway has three different API types: REST, HTTP, and WebSocket. Special steps need to be taken when migrating from one api type to another. A common migration will be from a REST API to an HTTP API given the potential cost savings. Below are the steps required to change from REST to HTTP. A similar process can be applied for other API type migrations.

**REST to HTTP**
1) Confirm the Domain name is a Regional domain name. Edge domains are not supported by AWS for HTTP APIs. See this [guide for migrating an edge-optimized custom domain name to regional](
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-migrate.html).
2) Wait for all DNS changes to take effect/propagate and ensure all traffic is being routed to the regional domain name before proceeding.
3) Make sure you have setup new or modified existing routes to use [httpApi event](https://serverless.com/framework/docs/providers/aws/events/http-api) in your serverless.yml file.
4) Make the following changes to the `customDomain` properties in the serverless.yml confg:
```yaml
endpointType: regional
apiType: http
allowPathMatching: true # Only for one deploy
```
5) Run `sls deploy`
6) Remove the `allowPathMatching` option, it should only be used once when migrating a base path from one API type to another.

NOTE: Always test this process in a lower level staging or development environment before performing it in production.


# Known Issues
Expand Down

0 comments on commit f356f5a

Please sign in to comment.