@openhi/constructs 0.0.117 → 0.0.118
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 +56 -15
- package/lib/index.d.ts +56 -15
- package/lib/index.js +77 -39
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +77 -39
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.mts
CHANGED
|
@@ -343,6 +343,15 @@ declare abstract class OpenHiService extends Stack {
|
|
|
343
343
|
* Short hash unique to the environment and branch combination.
|
|
344
344
|
*/
|
|
345
345
|
readonly branchHash: string;
|
|
346
|
+
/**
|
|
347
|
+
* Branch hash computed against {@link defaultReleaseBranch} rather than
|
|
348
|
+
* {@link branchName}. On the release branch this equals {@link branchHash};
|
|
349
|
+
* on every other branch it identifies the namespace the release-branch
|
|
350
|
+
* deploy of this service writes to. Use when looking up SSM parameters
|
|
351
|
+
* that only the release-branch stack publishes (e.g. shared static-hosting
|
|
352
|
+
* bucket ARN).
|
|
353
|
+
*/
|
|
354
|
+
readonly releaseBranchHash: string;
|
|
346
355
|
/**
|
|
347
356
|
* Short hash unique to the specific stack/service.
|
|
348
357
|
*/
|
|
@@ -1007,6 +1016,12 @@ declare class DiscoverableStringParameter extends StringParameter {
|
|
|
1007
1016
|
* Props for the StaticContent construct.
|
|
1008
1017
|
*/
|
|
1009
1018
|
interface StaticContentProps {
|
|
1019
|
+
/**
|
|
1020
|
+
* Destination bucket the content is uploaded to. Callers resolve this
|
|
1021
|
+
* reference themselves so the construct doesn't need to know whether the
|
|
1022
|
+
* bucket was created in the same stack or imported across branches.
|
|
1023
|
+
*/
|
|
1024
|
+
readonly bucket: IBucket;
|
|
1010
1025
|
/**
|
|
1011
1026
|
* Absolute path to directory containing content for the website.
|
|
1012
1027
|
*/
|
|
@@ -1031,21 +1046,14 @@ interface StaticContentProps {
|
|
|
1031
1046
|
* `<sub-domain>.<full-domain>`.
|
|
1032
1047
|
*/
|
|
1033
1048
|
readonly fullDomain: string;
|
|
1034
|
-
/**
|
|
1035
|
-
* Service type used to look up the static-hosting bucket ARN via
|
|
1036
|
-
* DiscoverableStringParameter.
|
|
1037
|
-
*
|
|
1038
|
-
* @default STATIC_HOSTING_SERVICE_TYPE ("website")
|
|
1039
|
-
*/
|
|
1040
|
-
readonly serviceType?: string;
|
|
1041
1049
|
}
|
|
1042
1050
|
/**
|
|
1043
|
-
* Static content uploader: deploys a local directory to
|
|
1051
|
+
* Static content uploader: deploys a local directory to a static-hosting
|
|
1044
1052
|
* S3 bucket under `<sub-domain>.<full-domain>/<dest>` so each branch
|
|
1045
|
-
* deploys to its own prefix without clobbering siblings. The
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1053
|
+
* deploys to its own prefix without clobbering siblings. The destination
|
|
1054
|
+
* bucket is supplied by the caller, which lets the same construct run in
|
|
1055
|
+
* both same-stack (release-branch) and cross-stack/cross-branch
|
|
1056
|
+
* (feature-branch) contexts.
|
|
1049
1057
|
*/
|
|
1050
1058
|
declare class StaticContent extends Construct {
|
|
1051
1059
|
constructor(scope: Construct, id: string, props: StaticContentProps);
|
|
@@ -1956,6 +1964,17 @@ interface OpenHiWebsiteServiceProps extends OpenHiServiceProps {
|
|
|
1956
1964
|
* @default - true on release branch, false otherwise
|
|
1957
1965
|
*/
|
|
1958
1966
|
readonly createHostingInfrastructure?: boolean;
|
|
1967
|
+
/**
|
|
1968
|
+
* Whether to create the `StaticContent` uploader. Set to `false` to skip
|
|
1969
|
+
* it entirely on every branch — used as a one-shot bootstrap toggle while
|
|
1970
|
+
* the release-branch deploy of this service first creates the static-hosting
|
|
1971
|
+
* bucket and writes `STATIC_HOSTING_BUCKET_ARN` to SSM. Once that
|
|
1972
|
+
* parameter exists, flip back to `true` so feature-branch deploys can read
|
|
1973
|
+
* it and upload content under their per-branch sub-domain folder.
|
|
1974
|
+
*
|
|
1975
|
+
* @default true
|
|
1976
|
+
*/
|
|
1977
|
+
readonly createStaticContent?: boolean;
|
|
1959
1978
|
}
|
|
1960
1979
|
/**
|
|
1961
1980
|
* SSM parameter name suffix for the website's full domain
|
|
@@ -2012,16 +2031,23 @@ declare class OpenHiWebsiteService extends OpenHiService {
|
|
|
2012
2031
|
*/
|
|
2013
2032
|
readonly staticHosting?: StaticHosting;
|
|
2014
2033
|
/**
|
|
2015
|
-
* The content uploader
|
|
2034
|
+
* The content uploader. Created on every deploy unless
|
|
2035
|
+
* {@link OpenHiWebsiteServiceProps.createStaticContent} is `false`, in
|
|
2036
|
+
* which case the property is `undefined` and the stack ships no
|
|
2037
|
+
* `BucketDeployment`. Used during release-branch bootstrap, before the
|
|
2038
|
+
* shared static-hosting bucket has been written to SSM for the first time.
|
|
2016
2039
|
*/
|
|
2017
|
-
readonly staticContent
|
|
2040
|
+
readonly staticContent?: StaticContent;
|
|
2018
2041
|
constructor(ohEnv: OpenHiEnvironment, props: OpenHiWebsiteServiceProps);
|
|
2019
2042
|
/**
|
|
2020
2043
|
* Validates that config required for the website stack is present.
|
|
2021
2044
|
*/
|
|
2022
2045
|
protected validateConfig(props: OpenHiWebsiteServiceProps): void;
|
|
2023
2046
|
/**
|
|
2024
|
-
*
|
|
2047
|
+
* Imports the website's hosted zone from config attributes (no SSM lookup).
|
|
2048
|
+
* The website attaches DNS records here on the release-branch deploy and
|
|
2049
|
+
* the same zone is imported on feature-branch deploys for any sub-domain
|
|
2050
|
+
* routing.
|
|
2025
2051
|
* Override to customize.
|
|
2026
2052
|
*/
|
|
2027
2053
|
protected createHostedZone(): IHostedZone;
|
|
@@ -2052,8 +2078,23 @@ declare class OpenHiWebsiteService extends OpenHiService {
|
|
|
2052
2078
|
* Creates the StaticContent uploader. Always created so feature-branch
|
|
2053
2079
|
* deploys can publish content to their own sub-domain folder against the
|
|
2054
2080
|
* release-branch bucket.
|
|
2081
|
+
*
|
|
2082
|
+
* The destination bucket is resolved here so the construct never has to
|
|
2083
|
+
* branch on release-vs-feature: on the release branch we pass the
|
|
2084
|
+
* just-created {@link staticHosting} bucket directly (no SSM round-trip
|
|
2085
|
+
* within a single stack); on every other branch we look up the bucket
|
|
2086
|
+
* ARN published by the release-branch deploy, addressed against
|
|
2087
|
+
* {@link OpenHiService.releaseBranchHash}.
|
|
2055
2088
|
*/
|
|
2056
2089
|
protected createStaticContent(): StaticContent;
|
|
2090
|
+
/**
|
|
2091
|
+
* Returns an {@link IBucket} pointing at the static-hosting bucket the
|
|
2092
|
+
* uploader writes to. On the release-branch deploy this is the bucket
|
|
2093
|
+
* just provisioned by {@link staticHosting}; on every other deploy it's
|
|
2094
|
+
* imported from the bucket ARN the release-branch deploy publishes to
|
|
2095
|
+
* SSM, addressed against {@link OpenHiService.releaseBranchHash}.
|
|
2096
|
+
*/
|
|
2097
|
+
protected resolveStaticHostingBucket(): IBucket;
|
|
2057
2098
|
}
|
|
2058
2099
|
|
|
2059
2100
|
interface OwningDeleteCascadeLambdasProps {
|
package/lib/index.d.ts
CHANGED
|
@@ -980,6 +980,15 @@ declare abstract class OpenHiService extends Stack {
|
|
|
980
980
|
* Short hash unique to the environment and branch combination.
|
|
981
981
|
*/
|
|
982
982
|
readonly branchHash: string;
|
|
983
|
+
/**
|
|
984
|
+
* Branch hash computed against {@link defaultReleaseBranch} rather than
|
|
985
|
+
* {@link branchName}. On the release branch this equals {@link branchHash};
|
|
986
|
+
* on every other branch it identifies the namespace the release-branch
|
|
987
|
+
* deploy of this service writes to. Use when looking up SSM parameters
|
|
988
|
+
* that only the release-branch stack publishes (e.g. shared static-hosting
|
|
989
|
+
* bucket ARN).
|
|
990
|
+
*/
|
|
991
|
+
readonly releaseBranchHash: string;
|
|
983
992
|
/**
|
|
984
993
|
* Short hash unique to the specific stack/service.
|
|
985
994
|
*/
|
|
@@ -1644,6 +1653,12 @@ declare class DiscoverableStringParameter extends StringParameter {
|
|
|
1644
1653
|
* Props for the StaticContent construct.
|
|
1645
1654
|
*/
|
|
1646
1655
|
interface StaticContentProps {
|
|
1656
|
+
/**
|
|
1657
|
+
* Destination bucket the content is uploaded to. Callers resolve this
|
|
1658
|
+
* reference themselves so the construct doesn't need to know whether the
|
|
1659
|
+
* bucket was created in the same stack or imported across branches.
|
|
1660
|
+
*/
|
|
1661
|
+
readonly bucket: IBucket;
|
|
1647
1662
|
/**
|
|
1648
1663
|
* Absolute path to directory containing content for the website.
|
|
1649
1664
|
*/
|
|
@@ -1668,21 +1683,14 @@ interface StaticContentProps {
|
|
|
1668
1683
|
* `<sub-domain>.<full-domain>`.
|
|
1669
1684
|
*/
|
|
1670
1685
|
readonly fullDomain: string;
|
|
1671
|
-
/**
|
|
1672
|
-
* Service type used to look up the static-hosting bucket ARN via
|
|
1673
|
-
* DiscoverableStringParameter.
|
|
1674
|
-
*
|
|
1675
|
-
* @default STATIC_HOSTING_SERVICE_TYPE ("website")
|
|
1676
|
-
*/
|
|
1677
|
-
readonly serviceType?: string;
|
|
1678
1686
|
}
|
|
1679
1687
|
/**
|
|
1680
|
-
* Static content uploader: deploys a local directory to
|
|
1688
|
+
* Static content uploader: deploys a local directory to a static-hosting
|
|
1681
1689
|
* S3 bucket under `<sub-domain>.<full-domain>/<dest>` so each branch
|
|
1682
|
-
* deploys to its own prefix without clobbering siblings. The
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1690
|
+
* deploys to its own prefix without clobbering siblings. The destination
|
|
1691
|
+
* bucket is supplied by the caller, which lets the same construct run in
|
|
1692
|
+
* both same-stack (release-branch) and cross-stack/cross-branch
|
|
1693
|
+
* (feature-branch) contexts.
|
|
1686
1694
|
*/
|
|
1687
1695
|
declare class StaticContent extends Construct {
|
|
1688
1696
|
constructor(scope: Construct, id: string, props: StaticContentProps);
|
|
@@ -2593,6 +2601,17 @@ interface OpenHiWebsiteServiceProps extends OpenHiServiceProps {
|
|
|
2593
2601
|
* @default - true on release branch, false otherwise
|
|
2594
2602
|
*/
|
|
2595
2603
|
readonly createHostingInfrastructure?: boolean;
|
|
2604
|
+
/**
|
|
2605
|
+
* Whether to create the `StaticContent` uploader. Set to `false` to skip
|
|
2606
|
+
* it entirely on every branch — used as a one-shot bootstrap toggle while
|
|
2607
|
+
* the release-branch deploy of this service first creates the static-hosting
|
|
2608
|
+
* bucket and writes `STATIC_HOSTING_BUCKET_ARN` to SSM. Once that
|
|
2609
|
+
* parameter exists, flip back to `true` so feature-branch deploys can read
|
|
2610
|
+
* it and upload content under their per-branch sub-domain folder.
|
|
2611
|
+
*
|
|
2612
|
+
* @default true
|
|
2613
|
+
*/
|
|
2614
|
+
readonly createStaticContent?: boolean;
|
|
2596
2615
|
}
|
|
2597
2616
|
/**
|
|
2598
2617
|
* SSM parameter name suffix for the website's full domain
|
|
@@ -2649,16 +2668,23 @@ declare class OpenHiWebsiteService extends OpenHiService {
|
|
|
2649
2668
|
*/
|
|
2650
2669
|
readonly staticHosting?: StaticHosting;
|
|
2651
2670
|
/**
|
|
2652
|
-
* The content uploader
|
|
2671
|
+
* The content uploader. Created on every deploy unless
|
|
2672
|
+
* {@link OpenHiWebsiteServiceProps.createStaticContent} is `false`, in
|
|
2673
|
+
* which case the property is `undefined` and the stack ships no
|
|
2674
|
+
* `BucketDeployment`. Used during release-branch bootstrap, before the
|
|
2675
|
+
* shared static-hosting bucket has been written to SSM for the first time.
|
|
2653
2676
|
*/
|
|
2654
|
-
readonly staticContent
|
|
2677
|
+
readonly staticContent?: StaticContent;
|
|
2655
2678
|
constructor(ohEnv: OpenHiEnvironment, props: OpenHiWebsiteServiceProps);
|
|
2656
2679
|
/**
|
|
2657
2680
|
* Validates that config required for the website stack is present.
|
|
2658
2681
|
*/
|
|
2659
2682
|
protected validateConfig(props: OpenHiWebsiteServiceProps): void;
|
|
2660
2683
|
/**
|
|
2661
|
-
*
|
|
2684
|
+
* Imports the website's hosted zone from config attributes (no SSM lookup).
|
|
2685
|
+
* The website attaches DNS records here on the release-branch deploy and
|
|
2686
|
+
* the same zone is imported on feature-branch deploys for any sub-domain
|
|
2687
|
+
* routing.
|
|
2662
2688
|
* Override to customize.
|
|
2663
2689
|
*/
|
|
2664
2690
|
protected createHostedZone(): IHostedZone;
|
|
@@ -2689,8 +2715,23 @@ declare class OpenHiWebsiteService extends OpenHiService {
|
|
|
2689
2715
|
* Creates the StaticContent uploader. Always created so feature-branch
|
|
2690
2716
|
* deploys can publish content to their own sub-domain folder against the
|
|
2691
2717
|
* release-branch bucket.
|
|
2718
|
+
*
|
|
2719
|
+
* The destination bucket is resolved here so the construct never has to
|
|
2720
|
+
* branch on release-vs-feature: on the release branch we pass the
|
|
2721
|
+
* just-created {@link staticHosting} bucket directly (no SSM round-trip
|
|
2722
|
+
* within a single stack); on every other branch we look up the bucket
|
|
2723
|
+
* ARN published by the release-branch deploy, addressed against
|
|
2724
|
+
* {@link OpenHiService.releaseBranchHash}.
|
|
2692
2725
|
*/
|
|
2693
2726
|
protected createStaticContent(): StaticContent;
|
|
2727
|
+
/**
|
|
2728
|
+
* Returns an {@link IBucket} pointing at the static-hosting bucket the
|
|
2729
|
+
* uploader writes to. On the release-branch deploy this is the bucket
|
|
2730
|
+
* just provisioned by {@link staticHosting}; on every other deploy it's
|
|
2731
|
+
* imported from the bucket ARN the release-branch deploy publishes to
|
|
2732
|
+
* SSM, addressed against {@link OpenHiService.releaseBranchHash}.
|
|
2733
|
+
*/
|
|
2734
|
+
protected resolveStaticHostingBucket(): IBucket;
|
|
2694
2735
|
}
|
|
2695
2736
|
|
|
2696
2737
|
interface OwningDeleteCascadeLambdasProps {
|
package/lib/index.js
CHANGED
|
@@ -1127,6 +1127,16 @@ var OpenHiService = class extends import_aws_cdk_lib4.Stack {
|
|
|
1127
1127
|
),
|
|
1128
1128
|
6
|
|
1129
1129
|
);
|
|
1130
|
+
const releaseBranchHash = (0, import_utils.hashString)(
|
|
1131
|
+
[
|
|
1132
|
+
appName,
|
|
1133
|
+
ohEnv.deploymentTargetRole,
|
|
1134
|
+
account,
|
|
1135
|
+
region,
|
|
1136
|
+
defaultReleaseBranch
|
|
1137
|
+
].join("-"),
|
|
1138
|
+
6
|
|
1139
|
+
);
|
|
1130
1140
|
const stackHash = (0, import_utils.hashString)(
|
|
1131
1141
|
[
|
|
1132
1142
|
appName,
|
|
@@ -1157,6 +1167,7 @@ var OpenHiService = class extends import_aws_cdk_lib4.Stack {
|
|
|
1157
1167
|
this.branchName = branchName;
|
|
1158
1168
|
this.environmentHash = environmentHash;
|
|
1159
1169
|
this.branchHash = branchHash;
|
|
1170
|
+
this.releaseBranchHash = releaseBranchHash;
|
|
1160
1171
|
this.stackHash = stackHash;
|
|
1161
1172
|
this.node.setContext(
|
|
1162
1173
|
`availability-zones:account=${account}:region=${region}`,
|
|
@@ -2286,10 +2297,31 @@ var RootHostedZone = class extends import_constructs7.Construct {
|
|
|
2286
2297
|
};
|
|
2287
2298
|
|
|
2288
2299
|
// src/components/static-hosting/static-content.ts
|
|
2289
|
-
var import_aws_s32 = require("aws-cdk-lib/aws-s3");
|
|
2290
2300
|
var import_aws_s3_deployment = require("aws-cdk-lib/aws-s3-deployment");
|
|
2291
2301
|
var import_change_case2 = require("change-case");
|
|
2292
|
-
var
|
|
2302
|
+
var import_constructs8 = require("constructs");
|
|
2303
|
+
var StaticContent = class extends import_constructs8.Construct {
|
|
2304
|
+
constructor(scope, id, props) {
|
|
2305
|
+
super(scope, id);
|
|
2306
|
+
const stack = OpenHiService.of(scope);
|
|
2307
|
+
const {
|
|
2308
|
+
bucket,
|
|
2309
|
+
contentSourceDirectory,
|
|
2310
|
+
contentDestinationDirectory = "/",
|
|
2311
|
+
subDomain = stack.branchName,
|
|
2312
|
+
fullDomain
|
|
2313
|
+
} = props;
|
|
2314
|
+
const keyPrefix = [(0, import_change_case2.paramCase)(subDomain), fullDomain].join(".");
|
|
2315
|
+
const isTestEnv = process.env.JEST_WORKER_ID !== void 0;
|
|
2316
|
+
const sources = isTestEnv ? [] : [import_aws_s3_deployment.Source.asset(contentSourceDirectory)];
|
|
2317
|
+
new import_aws_s3_deployment.BucketDeployment(this, "deploy", {
|
|
2318
|
+
sources,
|
|
2319
|
+
destinationBucket: bucket,
|
|
2320
|
+
retainOnDelete: false,
|
|
2321
|
+
destinationKeyPrefix: `${keyPrefix}${contentDestinationDirectory}`
|
|
2322
|
+
});
|
|
2323
|
+
}
|
|
2324
|
+
};
|
|
2293
2325
|
|
|
2294
2326
|
// src/components/static-hosting/static-hosting.ts
|
|
2295
2327
|
var fs6 = __toESM(require("fs"));
|
|
@@ -2303,9 +2335,9 @@ var import_aws_logs = require("aws-cdk-lib/aws-logs");
|
|
|
2303
2335
|
var import_aws_route532 = require("aws-cdk-lib/aws-route53");
|
|
2304
2336
|
var import_aws_route53_targets = require("aws-cdk-lib/aws-route53-targets");
|
|
2305
2337
|
var import_aws_s3 = require("aws-cdk-lib/aws-s3");
|
|
2306
|
-
var
|
|
2338
|
+
var import_constructs9 = require("constructs");
|
|
2307
2339
|
var STATIC_HOSTING_SERVICE_TYPE = "website";
|
|
2308
|
-
var _StaticHosting = class _StaticHosting extends
|
|
2340
|
+
var _StaticHosting = class _StaticHosting extends import_constructs9.Construct {
|
|
2309
2341
|
constructor(scope, id, props = {}) {
|
|
2310
2342
|
super(scope, id);
|
|
2311
2343
|
const stack = OpenHiService.of(scope);
|
|
@@ -2441,35 +2473,6 @@ _StaticHosting.SSM_PARAM_NAME_DISTRIBUTION_DOMAIN = "STATIC_HOSTING_DISTRIBUTION
|
|
|
2441
2473
|
_StaticHosting.SSM_PARAM_NAME_DISTRIBUTION_ID = "STATIC_HOSTING_DISTRIBUTION_ID";
|
|
2442
2474
|
var StaticHosting = _StaticHosting;
|
|
2443
2475
|
|
|
2444
|
-
// src/components/static-hosting/static-content.ts
|
|
2445
|
-
var StaticContent = class extends import_constructs9.Construct {
|
|
2446
|
-
constructor(scope, id, props) {
|
|
2447
|
-
super(scope, id);
|
|
2448
|
-
const stack = OpenHiService.of(scope);
|
|
2449
|
-
const {
|
|
2450
|
-
contentSourceDirectory,
|
|
2451
|
-
contentDestinationDirectory = "/",
|
|
2452
|
-
subDomain = stack.branchName,
|
|
2453
|
-
fullDomain,
|
|
2454
|
-
serviceType = STATIC_HOSTING_SERVICE_TYPE
|
|
2455
|
-
} = props;
|
|
2456
|
-
const keyPrefix = [(0, import_change_case2.paramCase)(subDomain), fullDomain].join(".");
|
|
2457
|
-
const bucketArn = DiscoverableStringParameter.valueForLookupName(this, {
|
|
2458
|
-
ssmParamName: StaticHosting.SSM_PARAM_NAME_BUCKET_ARN,
|
|
2459
|
-
serviceType
|
|
2460
|
-
});
|
|
2461
|
-
const bucket = import_aws_s32.Bucket.fromBucketArn(this, "bucket", bucketArn);
|
|
2462
|
-
const isTestEnv = process.env.JEST_WORKER_ID !== void 0;
|
|
2463
|
-
const sources = isTestEnv ? [] : [import_aws_s3_deployment.Source.asset(contentSourceDirectory)];
|
|
2464
|
-
new import_aws_s3_deployment.BucketDeployment(this, "deploy", {
|
|
2465
|
-
sources,
|
|
2466
|
-
destinationBucket: bucket,
|
|
2467
|
-
retainOnDelete: false,
|
|
2468
|
-
destinationKeyPrefix: `${keyPrefix}${contentDestinationDirectory}`
|
|
2469
|
-
});
|
|
2470
|
-
}
|
|
2471
|
-
};
|
|
2472
|
-
|
|
2473
2476
|
// src/services/open-hi-auth-service.ts
|
|
2474
2477
|
var import_aws_cognito4 = require("aws-cdk-lib/aws-cognito");
|
|
2475
2478
|
var import_aws_iam6 = require("aws-cdk-lib/aws-iam");
|
|
@@ -7180,6 +7183,7 @@ _OpenHiGraphqlService.SERVICE_TYPE = "graphql-api";
|
|
|
7180
7183
|
var OpenHiGraphqlService = _OpenHiGraphqlService;
|
|
7181
7184
|
|
|
7182
7185
|
// src/services/open-hi-website-service.ts
|
|
7186
|
+
var import_aws_s32 = require("aws-cdk-lib/aws-s3");
|
|
7183
7187
|
var SSM_PARAM_NAME_FULL_DOMAIN = "WEBSITE_FULL_DOMAIN";
|
|
7184
7188
|
var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
7185
7189
|
/**
|
|
@@ -7250,7 +7254,9 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7250
7254
|
});
|
|
7251
7255
|
this.createFullDomainParameter();
|
|
7252
7256
|
}
|
|
7253
|
-
|
|
7257
|
+
if (props.createStaticContent !== false) {
|
|
7258
|
+
this.staticContent = this.createStaticContent();
|
|
7259
|
+
}
|
|
7254
7260
|
}
|
|
7255
7261
|
/**
|
|
7256
7262
|
* Validates that config required for the website stack is present.
|
|
@@ -7263,14 +7269,21 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7263
7269
|
if (!config.zoneName) {
|
|
7264
7270
|
throw new Error("Zone name is required");
|
|
7265
7271
|
}
|
|
7272
|
+
if (!config.hostedZoneId) {
|
|
7273
|
+
throw new Error("Hosted zone ID is required to import the website zone");
|
|
7274
|
+
}
|
|
7266
7275
|
}
|
|
7267
7276
|
/**
|
|
7268
|
-
*
|
|
7277
|
+
* Imports the website's hosted zone from config attributes (no SSM lookup).
|
|
7278
|
+
* The website attaches DNS records here on the release-branch deploy and
|
|
7279
|
+
* the same zone is imported on feature-branch deploys for any sub-domain
|
|
7280
|
+
* routing.
|
|
7269
7281
|
* Override to customize.
|
|
7270
7282
|
*/
|
|
7271
7283
|
createHostedZone() {
|
|
7272
|
-
return OpenHiGlobalService.
|
|
7273
|
-
zoneName: this.config.zoneName
|
|
7284
|
+
return OpenHiGlobalService.rootHostedZoneFromConstruct(this, {
|
|
7285
|
+
zoneName: this.config.zoneName,
|
|
7286
|
+
hostedZoneId: this.config.hostedZoneId
|
|
7274
7287
|
});
|
|
7275
7288
|
}
|
|
7276
7289
|
/**
|
|
@@ -7317,15 +7330,40 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7317
7330
|
* Creates the StaticContent uploader. Always created so feature-branch
|
|
7318
7331
|
* deploys can publish content to their own sub-domain folder against the
|
|
7319
7332
|
* release-branch bucket.
|
|
7333
|
+
*
|
|
7334
|
+
* The destination bucket is resolved here so the construct never has to
|
|
7335
|
+
* branch on release-vs-feature: on the release branch we pass the
|
|
7336
|
+
* just-created {@link staticHosting} bucket directly (no SSM round-trip
|
|
7337
|
+
* within a single stack); on every other branch we look up the bucket
|
|
7338
|
+
* ARN published by the release-branch deploy, addressed against
|
|
7339
|
+
* {@link OpenHiService.releaseBranchHash}.
|
|
7320
7340
|
*/
|
|
7321
7341
|
createStaticContent() {
|
|
7322
7342
|
const { contentSourceDirectory, contentDestinationDirectory } = this.props;
|
|
7323
7343
|
return new StaticContent(this, "static-content", {
|
|
7344
|
+
bucket: this.resolveStaticHostingBucket(),
|
|
7324
7345
|
contentSourceDirectory,
|
|
7325
7346
|
contentDestinationDirectory,
|
|
7326
|
-
fullDomain: this.fullDomain
|
|
7327
|
-
|
|
7347
|
+
fullDomain: this.fullDomain
|
|
7348
|
+
});
|
|
7349
|
+
}
|
|
7350
|
+
/**
|
|
7351
|
+
* Returns an {@link IBucket} pointing at the static-hosting bucket the
|
|
7352
|
+
* uploader writes to. On the release-branch deploy this is the bucket
|
|
7353
|
+
* just provisioned by {@link staticHosting}; on every other deploy it's
|
|
7354
|
+
* imported from the bucket ARN the release-branch deploy publishes to
|
|
7355
|
+
* SSM, addressed against {@link OpenHiService.releaseBranchHash}.
|
|
7356
|
+
*/
|
|
7357
|
+
resolveStaticHostingBucket() {
|
|
7358
|
+
if (this.staticHosting) {
|
|
7359
|
+
return this.staticHosting.bucket;
|
|
7360
|
+
}
|
|
7361
|
+
const bucketArn = DiscoverableStringParameter.valueForLookupName(this, {
|
|
7362
|
+
ssmParamName: StaticHosting.SSM_PARAM_NAME_BUCKET_ARN,
|
|
7363
|
+
serviceType: _OpenHiWebsiteService.SERVICE_TYPE,
|
|
7364
|
+
branchHash: this.releaseBranchHash
|
|
7328
7365
|
});
|
|
7366
|
+
return import_aws_s32.Bucket.fromBucketArn(this, "shared-bucket", bucketArn);
|
|
7329
7367
|
}
|
|
7330
7368
|
};
|
|
7331
7369
|
_OpenHiWebsiteService.SERVICE_TYPE = "website";
|