@ndlib/ndlib-cdk2 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,10 +20,10 @@ export interface IStaticHostProps {
20
20
  */
21
21
  readonly createDns?: boolean;
22
22
  /**
23
- * Hosted zone ids for the route53 record. Is required if createDns is true.
23
+ * Hosted zone types (used to retrieve hosted zone ids) for the route53 record(s). Is required if createDns is true.
24
24
  * This is now an array to accommodate both a public hosted zone id and a private hosted zone id
25
25
  */
26
- readonly hostedZoneIds?: string[];
26
+ readonly hostedZoneTypes?: string[];
27
27
  /**
28
28
  * Root page to be served.
29
29
  */
@@ -3,25 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StaticHost = void 0;
4
4
  const aws_cdk_lib_1 = require("aws-cdk-lib");
5
5
  const constructs_1 = require("constructs");
6
- const crypto_1 = require("crypto");
6
+ const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
7
7
  class StaticHost extends constructs_1.Construct {
8
8
  constructor(scope, id, props) {
9
9
  var _a;
10
10
  super(scope, id);
11
11
  this.inProps = props;
12
- // removed .validate() and replaced with this error to enforce hostedZondId when createDNS is true
13
- // if (this.inProps.createDns && !this.inProps.hostedZoneIds) {
14
- // Annotations.of(this).addError('hostedZoneIds is required when createDns is true')
15
- // throw new Error('hostedZoneIds is required when createDns is true')
16
- // }
17
12
  if (this.inProps.createDns) {
18
- if (!this.inProps.hostedZoneIds) {
19
- aws_cdk_lib_1.Annotations.of(this).addError('hostedZoneIds is required when createDns is true');
20
- throw new Error('hostedZoneIds is required when createDns is true');
13
+ if (!this.inProps.hostedZoneTypes) {
14
+ aws_cdk_lib_1.Annotations.of(this).addError('hostedZoneTypes is required when createDns is true');
15
+ throw new Error('hostedZoneTypes is required when createDns is true');
21
16
  }
22
- if (this.inProps.hostedZoneIds.length == 0) {
23
- aws_cdk_lib_1.Annotations.of(this).addError('hostedZoneIds is required when createDns is true, and must contain at least one hostedZoneId');
24
- throw new Error('hostedZoneIds is required when createDns is true, and must contain at least one hostedZoneId');
17
+ if (this.inProps.hostedZoneTypes.length == 0) {
18
+ aws_cdk_lib_1.Annotations.of(this).addError('hostedZoneTypes is required when createDns is true, and must contain at least one hostedZoneId');
19
+ throw new Error('hostedZoneTypes is required when createDns is true, and must contain at least one hostedZoneId');
25
20
  }
26
21
  }
27
22
  const stack = aws_cdk_lib_1.Stack.of(this);
@@ -115,19 +110,27 @@ class StaticHost extends constructs_1.Construct {
115
110
  viewerProtocolPolicy: aws_cdk_lib_1.aws_cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
116
111
  });
117
112
  // Create DNS record (conditionally)
118
- if (props.createDns && props.hostedZoneIds && props.hostedZoneIds.length > 0) {
119
- for (const hostedZoneId of props.hostedZoneIds) {
120
- const id = (0, crypto_1.randomUUID)();
121
- new aws_cdk_lib_1.aws_route53.CnameRecord(this, `ServiceCNAME${id}`, {
122
- recordName: this.hostname,
123
- comment: this.hostname,
124
- domainName: this.cloudfront.distributionDomainName,
125
- zone: aws_cdk_lib_1.aws_route53.HostedZone.fromHostedZoneAttributes(this, `ImportedHostedZone${id}`, {
126
- hostedZoneId: hostedZoneId,
127
- zoneName: props.domainName,
128
- }),
129
- ttl: aws_cdk_lib_1.Duration.minutes(15),
130
- });
113
+ if (props.createDns && props.hostedZoneTypes && props.hostedZoneTypes.length > 0) {
114
+ for (const hostedZoneType of ['public', 'private']) {
115
+ console.log('before if includes');
116
+ console.log('hostedZoneType=', hostedZoneType);
117
+ console.log('hostedZoneTypes = ', props.hostedZoneTypes);
118
+ if (props.hostedZoneTypes.includes(hostedZoneType)) {
119
+ console.log('getting hosted zone id for ', hostedZoneType);
120
+ const hostedZoneIdPath = `/all/dns/${props.domainName}/${hostedZoneType}/zoneId`;
121
+ const hostedZoneId = aws_ssm_1.StringParameter.valueForStringParameter(this, hostedZoneIdPath);
122
+ console.log('hosted zone id = ', hostedZoneId);
123
+ new aws_cdk_lib_1.aws_route53.CnameRecord(this, `ServiceCNAME${hostedZoneType}`, {
124
+ recordName: this.hostname,
125
+ comment: this.hostname,
126
+ domainName: this.cloudfront.distributionDomainName,
127
+ zone: aws_cdk_lib_1.aws_route53.HostedZone.fromHostedZoneAttributes(this, `ImportedHostedZone${hostedZoneType}`, {
128
+ hostedZoneId: hostedZoneId,
129
+ zoneName: props.domainName,
130
+ }),
131
+ ttl: aws_cdk_lib_1.Duration.minutes(15),
132
+ });
133
+ }
131
134
  }
132
135
  }
133
136
  this.bucketNameParam = new aws_cdk_lib_1.aws_ssm.StringParameter(this, 'BucketParameter', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/ndlib-cdk2",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Reusable CDK2 modules used within Hesburgh Libraries of Notre Dame",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -37,21 +37,21 @@
37
37
  },
38
38
  "homepage": "https://github.com/ndlib/ndlib-cdk2#readme",
39
39
  "peerDependencies": {
40
- "aws-cdk-lib": "^2.24.1",
41
- "constructs": "^10.1.12"
40
+ "aws-cdk-lib": "^2.26.0",
41
+ "constructs": "^10.1.25"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/jest": "^27.5.1",
45
- "@types/node": "^17.0.35",
46
- "@typescript-eslint/eslint-plugin": "^5.25.0",
47
- "@typescript-eslint/parser": "^5.25.0",
48
- "aws-sdk": "^2.1140.0",
44
+ "@types/jest": "^28.1.0",
45
+ "@types/node": "^17.0.38",
46
+ "@typescript-eslint/eslint-plugin": "^5.27.0",
47
+ "@typescript-eslint/parser": "^5.27.0",
48
+ "aws-sdk": "^2.1147.0",
49
49
  "aws-sdk-client-mock": "^0.6.2",
50
- "eslint": "^8.15.0",
50
+ "eslint": "^8.16.0",
51
51
  "eslint-config-standard": "^17.0.0",
52
52
  "eslint-plugin-import": "^2.26.0",
53
- "eslint-plugin-jest": "^26.2.2",
54
- "eslint-plugin-n": "^15.2.0",
53
+ "eslint-plugin-jest": "^26.4.6",
54
+ "eslint-plugin-n": "^15.2.1",
55
55
  "eslint-plugin-node": "^11.1.0",
56
56
  "eslint-plugin-promise": "^6.0.0",
57
57
  "eslint-plugin-standard": "^5.0.0",
@@ -59,19 +59,19 @@
59
59
  "jest": "^28.1.0",
60
60
  "prettier": "^2.6.2",
61
61
  "subpackage": "^1.1.0",
62
- "ts-jest": "^28.0.2",
62
+ "ts-jest": "^28.0.3",
63
63
  "tsc-watch": "^5.0.3",
64
- "typescript": "^4.6.4"
64
+ "typescript": "^4.7.2"
65
65
  },
66
66
  "files": [
67
67
  "lib/**/*"
68
68
  ],
69
69
  "dependencies": {
70
- "@aws-cdk/aws-appsync-alpha": "^2.24.1-alpha.0",
71
- "aws-cdk-lib": "^2.24.1",
72
- "constructs": "^10.1.12",
70
+ "@aws-cdk/aws-appsync-alpha": "^2.26.0-alpha.0",
71
+ "aws-cdk-lib": "^2.26.0",
72
+ "constructs": "^10.1.25",
73
73
  "jest-mock": "^28.1.0",
74
- "node-fetch": "^3.2.4"
74
+ "node-fetch": "^3.2.5"
75
75
  },
76
76
  "subPackages": [
77
77
  "src/internal-lambdas/sourceWatcherLambda/src"