@openhi/constructs 0.0.24 → 0.0.26
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.
- package/lib/index.d.mts +47 -1
- package/lib/index.d.ts +48 -2
- package/lib/index.js +66 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +67 -4
- package/lib/index.mjs.map +1 -1
- package/package.json +6 -6
package/lib/index.mjs
CHANGED
|
@@ -802,6 +802,67 @@ import { Construct as Construct2 } from "constructs";
|
|
|
802
802
|
var RootHostedZone = class extends Construct2 {
|
|
803
803
|
};
|
|
804
804
|
|
|
805
|
+
// src/components/static-hosting/static-hosting.ts
|
|
806
|
+
import {
|
|
807
|
+
CachePolicy,
|
|
808
|
+
Distribution
|
|
809
|
+
} from "aws-cdk-lib/aws-cloudfront";
|
|
810
|
+
import { S3BucketOrigin } from "aws-cdk-lib/aws-cloudfront-origins";
|
|
811
|
+
import { Bucket } from "aws-cdk-lib/aws-s3";
|
|
812
|
+
import { Duration as Duration2 } from "aws-cdk-lib/core";
|
|
813
|
+
import { Construct as Construct3 } from "constructs";
|
|
814
|
+
var STATIC_HOSTING_SERVICE_TYPE = "website";
|
|
815
|
+
var _StaticHosting = class _StaticHosting extends Construct3 {
|
|
816
|
+
constructor(scope, id, props = {}) {
|
|
817
|
+
super(scope, id);
|
|
818
|
+
const stack = OpenHiService.of(scope);
|
|
819
|
+
const serviceType = props.serviceType ?? STATIC_HOSTING_SERVICE_TYPE;
|
|
820
|
+
this.bucket = new Bucket(this, "bucket", {
|
|
821
|
+
blockPublicAccess: {
|
|
822
|
+
blockPublicAcls: true,
|
|
823
|
+
blockPublicPolicy: true,
|
|
824
|
+
ignorePublicAcls: true,
|
|
825
|
+
restrictPublicBuckets: true
|
|
826
|
+
},
|
|
827
|
+
...props.bucketProps
|
|
828
|
+
});
|
|
829
|
+
const origin = S3BucketOrigin.withOriginAccessControl(this.bucket);
|
|
830
|
+
const cachePolicy = new CachePolicy(this, "cache-policy", {
|
|
831
|
+
cachePolicyName: `static-hosting-10s-${stack.branchHash}`,
|
|
832
|
+
comment: "Low TTL (10s) for static hosting; no invalidation",
|
|
833
|
+
defaultTtl: Duration2.seconds(10),
|
|
834
|
+
minTtl: Duration2.seconds(0),
|
|
835
|
+
maxTtl: Duration2.seconds(10)
|
|
836
|
+
});
|
|
837
|
+
this.distribution = new Distribution(this, "distribution", {
|
|
838
|
+
defaultBehavior: {
|
|
839
|
+
origin,
|
|
840
|
+
cachePolicy
|
|
841
|
+
},
|
|
842
|
+
...props.distributionProps
|
|
843
|
+
});
|
|
844
|
+
new DiscoverableStringParameter(this, "bucket-arn-param", {
|
|
845
|
+
ssmParamName: _StaticHosting.SSM_PARAM_NAME_BUCKET_ARN,
|
|
846
|
+
serviceType,
|
|
847
|
+
stringValue: this.bucket.bucketArn
|
|
848
|
+
});
|
|
849
|
+
new DiscoverableStringParameter(this, "distribution-arn-param", {
|
|
850
|
+
ssmParamName: _StaticHosting.SSM_PARAM_NAME_DISTRIBUTION_ARN,
|
|
851
|
+
serviceType,
|
|
852
|
+
stringValue: this.distribution.distributionArn
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* SSM parameter name for the S3 bucket ARN.
|
|
858
|
+
*/
|
|
859
|
+
_StaticHosting.SSM_PARAM_NAME_BUCKET_ARN = "STATIC_HOSTING_BUCKET_ARN";
|
|
860
|
+
/**
|
|
861
|
+
* SSM parameter name for the CloudFront distribution ARN.
|
|
862
|
+
*/
|
|
863
|
+
_StaticHosting.SSM_PARAM_NAME_DISTRIBUTION_ARN = "STATIC_HOSTING_DISTRIBUTION_ARN";
|
|
864
|
+
var StaticHosting = _StaticHosting;
|
|
865
|
+
|
|
805
866
|
// src/services/open-hi-auth-service.ts
|
|
806
867
|
import {
|
|
807
868
|
LambdaVersion,
|
|
@@ -1080,7 +1141,7 @@ import {
|
|
|
1080
1141
|
RecordTarget
|
|
1081
1142
|
} from "aws-cdk-lib/aws-route53";
|
|
1082
1143
|
import { ApiGatewayv2DomainProperties } from "aws-cdk-lib/aws-route53-targets";
|
|
1083
|
-
import { Duration as
|
|
1144
|
+
import { Duration as Duration3 } from "aws-cdk-lib/core";
|
|
1084
1145
|
|
|
1085
1146
|
// src/services/open-hi-data-service.ts
|
|
1086
1147
|
import { Table as Table2 } from "aws-cdk-lib/aws-dynamodb";
|
|
@@ -1152,7 +1213,7 @@ import fs2 from "fs";
|
|
|
1152
1213
|
import path2 from "path";
|
|
1153
1214
|
import { Runtime as Runtime2 } from "aws-cdk-lib/aws-lambda";
|
|
1154
1215
|
import { NodejsFunction as NodejsFunction2 } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
1155
|
-
import { Construct as
|
|
1216
|
+
import { Construct as Construct4 } from "constructs";
|
|
1156
1217
|
var HANDLER_NAME2 = "rest-api-lambda.handler.js";
|
|
1157
1218
|
function resolveHandlerEntry2(dirname) {
|
|
1158
1219
|
const sameDir = path2.join(dirname, HANDLER_NAME2);
|
|
@@ -1162,7 +1223,7 @@ function resolveHandlerEntry2(dirname) {
|
|
|
1162
1223
|
const fromLib = path2.join(dirname, "..", "..", "..", "lib", HANDLER_NAME2);
|
|
1163
1224
|
return fromLib;
|
|
1164
1225
|
}
|
|
1165
|
-
var RestApiLambda = class extends
|
|
1226
|
+
var RestApiLambda = class extends Construct4 {
|
|
1166
1227
|
constructor(scope, props) {
|
|
1167
1228
|
super(scope, "rest-api-lambda");
|
|
1168
1229
|
this.lambda = new NodejsFunction2(this, "handler", {
|
|
@@ -1388,7 +1449,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
1388
1449
|
"Authorization"
|
|
1389
1450
|
],
|
|
1390
1451
|
allowCredentials: cors.allowCredentials ?? true,
|
|
1391
|
-
maxAge: cors.maxAge ??
|
|
1452
|
+
maxAge: cors.maxAge ?? Duration3.days(1)
|
|
1392
1453
|
} : void 0;
|
|
1393
1454
|
const rootHttpApi = new RootHttpApi(this, {
|
|
1394
1455
|
defaultDomainMapping: {
|
|
@@ -1473,6 +1534,8 @@ export {
|
|
|
1473
1534
|
RootHostedZone,
|
|
1474
1535
|
RootHttpApi,
|
|
1475
1536
|
RootWildcardCertificate,
|
|
1537
|
+
STATIC_HOSTING_SERVICE_TYPE,
|
|
1538
|
+
StaticHosting,
|
|
1476
1539
|
getDynamoDbDataStoreTableName
|
|
1477
1540
|
};
|
|
1478
1541
|
//# sourceMappingURL=index.mjs.map
|