Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 7.2.0 #601

Merged
merged 5 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install and test
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14.x, 16.x, 18.x ]
node-version: [ 14.x, 16.x, 18.x, 20.x ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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).

## [7.2.0] - 2023-11-24

### Fixed
- Fixed support for proxy. Thank you @ertanden ([597](https://github.com/amplify-education/serverless-domain-manager/pull/597))
- Updated packages

## [7.1.2] - 2023-08-14

### Fixed
Expand Down
5,300 changes: 3,475 additions & 1,825 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-domain-manager",
"version": "7.1.2",
"version": "7.2.0",
"engines": {
"node": ">=14"
},
Expand Down Expand Up @@ -49,35 +49,36 @@
]
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.2",
"@types/shelljs": "^0.8.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.9.4",
"@types/shelljs": "^0.8.15",
"aws-sdk-client-mock": "^3.0.0",
"chai": "^4.3.7",
"chai-spies": "^1.0.0",
"chai": "^4.3.10",
"chai-spies": "^1.1.0",
"mocha": "^10.2.0",
"mocha-param": "^2.0.1",
"nyc": "^15.1.0",
"randomstring": "^1.3.0",
"serverless": "^3.33.0",
"serverless": "^3.37.0",
"serverless-plugin-split-stacks": "^1.13.0",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},
"dependencies": {
"@aws-sdk/client-acm": "^3.370.0",
"@aws-sdk/client-api-gateway": "^3.370.0",
"@aws-sdk/client-apigatewayv2": "^3.370.0",
"@aws-sdk/client-cloudformation": "^3.370.0",
"@aws-sdk/client-route-53": "^3.370.0",
"@aws-sdk/client-s3": "^3.370.0",
"@aws-sdk/config-resolver": "^3.370.0",
"@aws-sdk/credential-providers": "^3.370.0",
"@aws-sdk/node-config-provider": "^3.370.0",
"@aws-sdk/smithy-client": "^3.370.0",
"@aws-sdk/util-retry": "^3.370.0",
"@aws-sdk/client-acm": "^3.374.0",
"@aws-sdk/client-api-gateway": "^3.374.0",
"@aws-sdk/client-apigatewayv2": "^3.374.0",
"@aws-sdk/client-cloudformation": "^3.374.0",
"@aws-sdk/client-route-53": "^3.374.0",
"@aws-sdk/client-s3": "^3.374.0",
"@aws-sdk/config-resolver": "^3.374.0",
"@aws-sdk/credential-providers": "^3.374.0",
"@aws-sdk/node-config-provider": "^3.374.0",
"@aws-sdk/smithy-client": "^3.374.0",
"@aws-sdk/util-retry": "^3.374.0",
"@smithy/node-http-handler": "^2.1.10",
"proxy-agent": "^6.3.1"
},
"peerDependencies": {
Expand Down
29 changes: 17 additions & 12 deletions src/aws/acm-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {
ACMClient,
CertificateSummary,
ListCertificatesCommand,
ListCertificatesCommandInput,
ListCertificatesCommandOutput
CertificateStatus,
ACMClient,
CertificateSummary,
ListCertificatesCommand,
ListCertificatesCommandInput,
ListCertificatesCommandOutput
} from "@aws-sdk/client-acm";
import Globals from "../globals";
import DomainConfig = require("../models/domain-config");
import { getAWSPagedResults } from "../utils";
import {getAWSPagedResults} from "../utils";

const certStatuses = ["PENDING_VALIDATION", "ISSUED", "INACTIVE"];
const certStatuses = [
CertificateStatus.PENDING_VALIDATION,
CertificateStatus.ISSUED,
CertificateStatus.INACTIVE
];

class ACMWrapper {
public acm: ACMClient;
Expand All @@ -30,11 +35,11 @@ class ACMWrapper {

try {
const certificates = await getAWSPagedResults<CertificateSummary, ListCertificatesCommandInput, ListCertificatesCommandOutput>(
this.acm,
"CertificateSummaryList",
"NextToken",
"NextToken",
new ListCertificatesCommand({ CertificateStatuses: certStatuses })
this.acm,
"CertificateSummaryList",
"NextToken",
"NextToken",
new ListCertificatesCommand({CertificateStatuses: certStatuses})
);
// enhancement idea: weight the choice of cert so longer expires
// and RenewalEligibility = ELIGIBLE is more preferable
Expand Down
30 changes: 16 additions & 14 deletions src/aws/api-gateway-v1-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,28 @@ import DomainConfig = require("../models/domain-config");
import DomainInfo = require("../models/domain-info");
import Globals from "../globals";
import {
APIGatewayClient,
BasePathMapping,
CreateBasePathMappingCommand,
CreateDomainNameCommand,
CreateDomainNameCommandOutput,
DeleteBasePathMappingCommand,
DeleteDomainNameCommand,
GetBasePathMappingsCommand,
GetBasePathMappingsCommandInput,
GetBasePathMappingsCommandOutput,
GetDomainNameCommand,
GetDomainNameCommandOutput,
UpdateBasePathMappingCommand
APIGatewayClient,
BasePathMapping,
CreateBasePathMappingCommand,
CreateDomainNameCommand,
CreateDomainNameCommandOutput,
DeleteBasePathMappingCommand,
DeleteDomainNameCommand,
GetBasePathMappingsCommand,
GetBasePathMappingsCommandInput,
GetBasePathMappingsCommandOutput,
GetDomainNameCommand,
GetDomainNameCommandOutput,
UpdateBasePathMappingCommand
} from "@aws-sdk/client-api-gateway";
import ApiGatewayMap = require("../models/api-gateway-map");
import APIGatewayBase = require("../models/apigateway-base");
import Logging from "../logging";
import { getAWSPagedResults } from "../utils";
import {getAWSPagedResults} from "../utils";

class APIGatewayV1Wrapper extends APIGatewayBase {
public readonly apiGateway: APIGatewayClient;

constructor(credentials?: any) {
super();
this.apiGateway = new APIGatewayClient({
Expand Down
44 changes: 23 additions & 21 deletions src/aws/api-gateway-v2-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ import Globals from "../globals";
import ApiGatewayMap = require("../models/api-gateway-map");
import APIGatewayBase = require("../models/apigateway-base");
import {
ApiGatewayV2Client,
ApiMapping,
CreateApiMappingCommand,
CreateDomainNameCommand,
CreateDomainNameCommandOutput,
DeleteApiMappingCommand,
DeleteDomainNameCommand,
GetApiMappingsCommand,
GetApiMappingsCommandInput,
GetApiMappingsCommandOutput,
GetDomainNameCommand,
GetDomainNameCommandOutput,
UpdateApiMappingCommand
ApiGatewayV2Client,
ApiMapping,
CreateApiMappingCommand,
CreateDomainNameCommand,
CreateDomainNameCommandOutput,
DeleteApiMappingCommand,
DeleteDomainNameCommand,
GetApiMappingsCommand,
GetApiMappingsCommandInput,
GetApiMappingsCommandOutput,
GetDomainNameCommand,
GetDomainNameCommandOutput,
UpdateApiMappingCommand
} from "@aws-sdk/client-apigatewayv2";
import Logging from "../logging";
import { getAWSPagedResults } from "../utils";
import {getAWSPagedResults} from "../utils";

class APIGatewayV2Wrapper extends APIGatewayBase {
public readonly apiGateway: ApiGatewayV2Client;

constructor(credentials?: any) {
super();
this.apiGateway = new ApiGatewayV2Client({
Expand Down Expand Up @@ -157,13 +159,13 @@ class APIGatewayV2Wrapper extends APIGatewayBase {
public async getBasePathMappings(domain: DomainConfig): Promise<ApiGatewayMap[]> {
try {
const items = await getAWSPagedResults<ApiMapping, GetApiMappingsCommandInput, GetApiMappingsCommandOutput>(
this.apiGateway,
"Items",
"NextToken",
"NextToken",
new GetApiMappingsCommand({
DomainName: domain.givenDomainName
})
this.apiGateway,
"Items",
"NextToken",
"NextToken",
new GetApiMappingsCommand({
DomainName: domain.givenDomainName
})
);
return items.map(
(item) => new ApiGatewayMap(item.ApiId, item.ApiMappingKey, item.Stage, item.ApiMappingId)
Expand Down
30 changes: 15 additions & 15 deletions src/aws/route53-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import Globals from "../globals";
import DomainConfig = require("../models/domain-config");
import Logging from "../logging";
import {
ChangeResourceRecordSetsCommand,
HostedZone,
ListHostedZonesCommand,
ListHostedZonesCommandInput,
ListHostedZonesCommandOutput,
Route53Client
ChangeResourceRecordSetsCommand,
HostedZone,
ListHostedZonesCommand,
ListHostedZonesCommandInput,
ListHostedZonesCommandOutput,
Route53Client, RRType, ChangeAction
} from "@aws-sdk/client-route-53";
import { getAWSPagedResults } from "../utils";
import {getAWSPagedResults} from "../utils";

class Route53Wrapper {
public route53: Route53Client;
Expand Down Expand Up @@ -50,11 +50,11 @@ class Route53Wrapper {
let hostedZones = [];
try {
hostedZones = await getAWSPagedResults<HostedZone, ListHostedZonesCommandInput, ListHostedZonesCommandOutput>(
this.route53,
"HostedZones",
"Marker",
"NextMarker",
new ListHostedZonesCommand({})
this.route53,
"HostedZones",
"Marker",
"NextMarker",
new ListHostedZonesCommand({})
);
} catch (err) {
throw new Error(`Unable to list hosted zones in Route53.\n${err.message}`);
Expand Down Expand Up @@ -83,9 +83,9 @@ class Route53Wrapper {
* @param action: String descriptor of change to be made. Valid actions are ['UPSERT', 'DELETE']
* @param domain: DomainInfo object containing info about custom domain
*/
public async changeResourceRecordSet(action: string, domain: DomainConfig): Promise<void> {
public async changeResourceRecordSet(action: ChangeAction, domain: DomainConfig): Promise<void> {
if (domain.createRoute53Record === false) {
Logging.logInfo(`Skipping ${action === "DELETE" ? "removal" : "creation"} of Route53 record.`);
Logging.logInfo(`Skipping ${action === ChangeAction.DELETE ? "removal" : "creation"} of Route53 record.`);
return;
}
// Set up parameters
Expand Down Expand Up @@ -124,7 +124,7 @@ class Route53Wrapper {
hostedZoneIds = [route53HostedZoneId];
}

const recordsToCreate = domain.createRoute53IPv6Record ? ["A", "AAAA"] : ["A"];
const recordsToCreate = domain.createRoute53IPv6Record ? [RRType.A, RRType.AAAA] : [RRType.A];
for (const hostedZoneId of hostedZoneIds) {
const changes = recordsToCreate.map((Type) => ({
Action: action,
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import APIGatewayBase = require("./models/apigateway-base");
import Logging from "./logging";
import {loadConfig} from "@aws-sdk/node-config-provider";
import {NODE_REGION_CONFIG_FILE_OPTIONS, NODE_REGION_CONFIG_OPTIONS} from "@aws-sdk/config-resolver";
import {ChangeAction} from "@aws-sdk/client-route-53";

class ServerlessCustomDomain {

Expand Down Expand Up @@ -271,7 +272,7 @@ class ServerlessCustomDomain {
Logging.logInfo(`Custom domain '${domain.givenDomainName}' already exists.`);
}
Logging.logInfo(`Creating/updating route53 record for '${domain.givenDomainName}'.`);
await route53.changeResourceRecordSet("UPSERT", domain);
await route53.changeResourceRecordSet(ChangeAction.UPSERT, domain);
} catch (err) {
throw new Error(`Unable to create domain '${domain.givenDomainName}':\n${err.message}`);
} finally {
Expand Down Expand Up @@ -303,7 +304,7 @@ class ServerlessCustomDomain {
try {
if (domain.domainInfo) {
await apiGateway.deleteCustomDomain(domain);
await route53.changeResourceRecordSet("DELETE", domain);
await route53.changeResourceRecordSet(ChangeAction.DELETE, domain);
domain.domainInfo = null;
Logging.logInfo(`Custom domain ${domain.givenDomainName} was deleted.`);
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/models/apigateway-base.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import DomainInfo = require("./domain-info");
import ApiGatewayMap = require("./api-gateway-map");
import DomainConfig = require("./domain-config");
import {Client} from "@aws-sdk/smithy-client";

abstract class APIGatewayBase {
public apiGateway: Client<any, any, any, any>;

abstract createCustomDomain(domain: DomainConfig): Promise<DomainInfo>;

abstract getCustomDomain(domain: DomainConfig): Promise<DomainInfo>;
Expand Down
Loading