@webiny/pulumi-aws 5.42.4-beta.0 → 5.43.0-beta.1
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/apps/api/ApiGraphql.js +2 -2
- package/apps/api/ApiGraphql.js.map +1 -1
- package/apps/api/ApiMigration.js +2 -1
- package/apps/api/ApiMigration.js.map +1 -1
- package/apps/api/ApiOutput.js +2 -1
- package/apps/api/ApiOutput.js.map +1 -1
- package/apps/api/createApiPulumiApp.d.ts +9 -2
- package/apps/api/createApiPulumiApp.js +12 -14
- package/apps/api/createApiPulumiApp.js.map +1 -1
- package/apps/awsUtils.d.ts +1 -1
- package/apps/blueGreen/BlueGreenRouterApiGateway.d.ts +11 -0
- package/apps/blueGreen/BlueGreenRouterApiGateway.js +51 -0
- package/apps/blueGreen/BlueGreenRouterApiGateway.js.map +1 -0
- package/apps/blueGreen/BlueGreenRouterCloudFront.d.ts +17 -0
- package/apps/blueGreen/BlueGreenRouterCloudFront.js +106 -0
- package/apps/blueGreen/BlueGreenRouterCloudFront.js.map +1 -0
- package/apps/blueGreen/BlueGreenRouterCloudFrontStore.d.ts +10 -0
- package/apps/blueGreen/BlueGreenRouterCloudFrontStore.js +27 -0
- package/apps/blueGreen/BlueGreenRouterCloudFrontStore.js.map +1 -0
- package/apps/blueGreen/cloudfront/createCloudFrontDefaultCacheBehaviorPolicies.d.ts +7 -0
- package/apps/blueGreen/cloudfront/createCloudFrontDefaultCacheBehaviorPolicies.js +23 -0
- package/apps/blueGreen/cloudfront/createCloudFrontDefaultCacheBehaviorPolicies.js.map +1 -0
- package/apps/blueGreen/cloudfront/createCloudFrontFunctionDomainMap.d.ts +14 -0
- package/apps/blueGreen/cloudfront/createCloudFrontFunctionDomainMap.js +30 -0
- package/apps/blueGreen/cloudfront/createCloudFrontFunctionDomainMap.js.map +1 -0
- package/apps/blueGreen/cloudfront/createOriginId.d.ts +11 -0
- package/apps/blueGreen/cloudfront/createOriginId.js +18 -0
- package/apps/blueGreen/cloudfront/createOriginId.js.map +1 -0
- package/apps/blueGreen/constants.d.ts +3 -0
- package/apps/blueGreen/constants.js +11 -0
- package/apps/blueGreen/constants.js.map +1 -0
- package/apps/blueGreen/createBlueGreenPulumiApp.d.ts +73 -0
- package/apps/blueGreen/createBlueGreenPulumiApp.js +121 -0
- package/apps/blueGreen/createBlueGreenPulumiApp.js.map +1 -0
- package/apps/blueGreen/domains/attachDomainsToOutput.d.ts +9 -0
- package/apps/blueGreen/domains/attachDomainsToOutput.js +37 -0
- package/apps/blueGreen/domains/attachDomainsToOutput.js.map +1 -0
- package/apps/blueGreen/domains/convertApplicationDomains.d.ts +6 -0
- package/apps/blueGreen/domains/convertApplicationDomains.js +32 -0
- package/apps/blueGreen/domains/convertApplicationDomains.js.map +1 -0
- package/apps/blueGreen/domains/getApplicationDomains.d.ts +20 -0
- package/apps/blueGreen/domains/getApplicationDomains.js +107 -0
- package/apps/blueGreen/domains/getApplicationDomains.js.map +1 -0
- package/apps/blueGreen/domains/resolveDomains.d.ts +6 -0
- package/apps/blueGreen/domains/resolveDomains.js +48 -0
- package/apps/blueGreen/domains/resolveDomains.js.map +1 -0
- package/apps/blueGreen/functions/buildHandlerFunction.d.ts +15 -0
- package/apps/blueGreen/functions/buildHandlerFunction.js +25 -0
- package/apps/blueGreen/functions/buildHandlerFunction.js.map +1 -0
- package/apps/blueGreen/functions/handler.d.ts +1 -0
- package/apps/blueGreen/functions/handler.js +63 -0
- package/apps/blueGreen/functions/handler.js.map +1 -0
- package/apps/blueGreen/types.d.ts +78 -0
- package/apps/blueGreen/types.js +7 -0
- package/apps/blueGreen/types.js.map +1 -0
- package/apps/blueGreen/validation/validateDeployments.d.ts +2 -0
- package/apps/blueGreen/validation/validateDeployments.js +41 -0
- package/apps/blueGreen/validation/validateDeployments.js.map +1 -0
- package/apps/common/CoreOutput.js +3 -1
- package/apps/common/CoreOutput.js.map +1 -1
- package/apps/core/cognitoIdentityProviders/configure.js +2 -1
- package/apps/core/cognitoIdentityProviders/configure.js.map +1 -1
- package/apps/core/createCorePulumiApp.js +28 -6
- package/apps/core/createCorePulumiApp.js.map +1 -1
- package/apps/createAppBucket.js +2 -1
- package/apps/createAppBucket.js.map +1 -1
- package/apps/react/createReactPulumiApp.js +7 -3
- package/apps/react/createReactPulumiApp.js.map +1 -1
- package/apps/syncSystem/SyncSystemDynamo.d.ts +5 -0
- package/apps/syncSystem/SyncSystemDynamo.js +59 -0
- package/apps/syncSystem/SyncSystemDynamo.js.map +1 -0
- package/apps/syncSystem/SyncSystemLambda.d.ts +13 -0
- package/apps/syncSystem/SyncSystemLambda.js +104 -0
- package/apps/syncSystem/SyncSystemLambda.js.map +1 -0
- package/apps/syncSystem/SyncSystemSQS.d.ts +4 -0
- package/apps/syncSystem/SyncSystemSQS.js +40 -0
- package/apps/syncSystem/SyncSystemSQS.js.map +1 -0
- package/apps/syncSystem/addTableItems.d.ts +8 -0
- package/apps/syncSystem/addTableItems.js +59 -0
- package/apps/syncSystem/addTableItems.js.map +1 -0
- package/apps/syncSystem/createSyncSystemPulumiApp.d.ts +66 -0
- package/apps/syncSystem/createSyncSystemPulumiApp.js +63 -0
- package/apps/syncSystem/createSyncSystemPulumiApp.js.map +1 -0
- package/apps/tenantRouter.js +2 -1
- package/apps/tenantRouter.js.map +1 -1
- package/apps/website/WebsitePrerendering.js +1 -1
- package/apps/website/WebsitePrerendering.js.map +1 -1
- package/apps/website/createWebsitePulumiApp.d.ts +1 -1
- package/apps/website/createWebsitePulumiApp.js +6 -2
- package/apps/website/createWebsitePulumiApp.js.map +1 -1
- package/components/tenantRouter/WebsiteTenantRouter.d.ts +1 -0
- package/components/tenantRouter/WebsiteTenantRouter.js +6 -3
- package/components/tenantRouter/WebsiteTenantRouter.js.map +1 -1
- package/enterprise/createCorePulumiApp.d.ts +1 -0
- package/enterprise/createCorePulumiApp.js +10 -0
- package/enterprise/createCorePulumiApp.js.map +1 -1
- package/enterprise/createSyncSystemPulumiApp.d.ts +26 -0
- package/enterprise/createSyncSystemPulumiApp.js +71 -0
- package/enterprise/createSyncSystemPulumiApp.js.map +1 -0
- package/env/awsRegion.d.ts +1 -0
- package/env/awsRegion.js +12 -0
- package/env/awsRegion.js.map +1 -0
- package/env/base.d.ts +15 -0
- package/env/base.js +37 -0
- package/env/base.js.map +1 -0
- package/env/env.d.ts +1 -0
- package/env/env.js +12 -0
- package/env/env.js.map +1 -0
- package/env/projectName.d.ts +1 -0
- package/env/projectName.js +12 -0
- package/env/projectName.js.map +1 -0
- package/env/variant.d.ts +1 -0
- package/env/variant.js +13 -0
- package/env/variant.js.map +1 -0
- package/package.json +21 -18
- package/utils/addServiceManifestTableItem.js +1 -1
- package/utils/addServiceManifestTableItem.js.map +1 -1
- package/utils/dynamodb.d.ts +14 -0
- package/utils/dynamodb.js +36 -0
- package/utils/dynamodb.js.map +1 -0
- package/utils/lambdaEnvVariables.js +1 -2
- package/utils/lambdaEnvVariables.js.map +1 -1
- package/utils/uploadFolderToS3.js +2 -1
- package/utils/uploadFolderToS3.js.map +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertApplicationDomains = void 0;
|
|
7
|
+
const convertApplicationDomains = params => {
|
|
8
|
+
const {
|
|
9
|
+
input
|
|
10
|
+
} = params;
|
|
11
|
+
const result = Object.keys(input).map(name => {
|
|
12
|
+
const value = input[name];
|
|
13
|
+
return {
|
|
14
|
+
name,
|
|
15
|
+
env: value.env,
|
|
16
|
+
variant: value.variant,
|
|
17
|
+
domains: {
|
|
18
|
+
api: value.api,
|
|
19
|
+
admin: value.admin,
|
|
20
|
+
website: value.website,
|
|
21
|
+
preview: value.preview
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
if (result.length !== 2) {
|
|
26
|
+
throw new Error("Invalid number of domains.");
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
exports.convertApplicationDomains = convertApplicationDomains;
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=convertApplicationDomains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["convertApplicationDomains","params","input","result","Object","keys","map","name","value","env","variant","domains","api","admin","website","preview","length","Error","exports"],"sources":["convertApplicationDomains.ts"],"sourcesContent":["import type { IGetApplicationStacksResult } from \"./getApplicationDomains.js\";\nimport type { IDeploymentDomain, IDeploymentsDomains } from \"../types.js\";\n\nexport interface IConvertApplicationDomainsParams {\n input: IGetApplicationStacksResult;\n}\n\nexport const convertApplicationDomains = (\n params: IConvertApplicationDomainsParams\n): IDeploymentsDomains => {\n const { input } = params;\n\n const result = Object.keys(input).map<IDeploymentDomain>(name => {\n const value = input[name];\n return {\n name,\n env: value.env,\n variant: value.variant,\n domains: {\n api: value.api,\n admin: value.admin,\n website: value.website,\n preview: value.preview\n }\n };\n });\n if (result.length !== 2) {\n throw new Error(\"Invalid number of domains.\");\n }\n return result as IDeploymentsDomains;\n};\n"],"mappings":";;;;;;AAOO,MAAMA,yBAAyB,GAClCC,MAAwC,IAClB;EACtB,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EAExB,MAAME,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAACI,GAAG,CAAoBC,IAAI,IAAI;IAC7D,MAAMC,KAAK,GAAGN,KAAK,CAACK,IAAI,CAAC;IACzB,OAAO;MACHA,IAAI;MACJE,GAAG,EAAED,KAAK,CAACC,GAAG;MACdC,OAAO,EAAEF,KAAK,CAACE,OAAO;MACtBC,OAAO,EAAE;QACLC,GAAG,EAAEJ,KAAK,CAACI,GAAG;QACdC,KAAK,EAAEL,KAAK,CAACK,KAAK;QAClBC,OAAO,EAAEN,KAAK,CAACM,OAAO;QACtBC,OAAO,EAAEP,KAAK,CAACO;MACnB;IACJ,CAAC;EACL,CAAC,CAAC;EACF,IAAIZ,MAAM,CAACa,MAAM,KAAK,CAAC,EAAE;IACrB,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC;EACjD;EACA,OAAOd,MAAM;AACjB,CAAC;AAACe,OAAA,CAAAlB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface IGetStacksStack {
|
|
2
|
+
name: string;
|
|
3
|
+
env: string;
|
|
4
|
+
variant: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface IGetApplicationStacks {
|
|
7
|
+
stacks: IGetStacksStack[];
|
|
8
|
+
}
|
|
9
|
+
export interface IGetApplicationStacksResultStack {
|
|
10
|
+
env: string;
|
|
11
|
+
variant: string | undefined;
|
|
12
|
+
api: string;
|
|
13
|
+
admin: string;
|
|
14
|
+
website: string | undefined;
|
|
15
|
+
preview: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface IGetApplicationStacksResult {
|
|
18
|
+
[name: string]: IGetApplicationStacksResultStack;
|
|
19
|
+
}
|
|
20
|
+
export declare const getApplicationDomains: (params: IGetApplicationStacks) => Promise<IGetApplicationStacksResult>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getApplicationDomains = void 0;
|
|
7
|
+
var _getStackOutput = require("@webiny/cli-plugin-deploy-pulumi/utils/getStackOutput.js");
|
|
8
|
+
const apps = ["api", "admin", "website"];
|
|
9
|
+
const removeProtocol = url => {
|
|
10
|
+
return url.replace(/^https?:\/\//, "");
|
|
11
|
+
};
|
|
12
|
+
const getApiDomainName = (results, name) => {
|
|
13
|
+
const api = results.find(r => r.name === name && r.app === "api");
|
|
14
|
+
if (!api?.stack?.apiDomain) {
|
|
15
|
+
throw new Error(`Missing API stack for "${name}" deployment.`);
|
|
16
|
+
}
|
|
17
|
+
return removeProtocol(api.stack.apiDomain);
|
|
18
|
+
};
|
|
19
|
+
const getAdminDomainName = (results, name) => {
|
|
20
|
+
const admin = results.find(r => r.name === name && r.app === "admin");
|
|
21
|
+
if (!admin?.stack?.appDomain) {
|
|
22
|
+
throw new Error(`Missing Admin stack for "${name}" deployment.`);
|
|
23
|
+
}
|
|
24
|
+
return removeProtocol(admin.stack.appDomain);
|
|
25
|
+
};
|
|
26
|
+
const getWebsiteDomainName = (results, name) => {
|
|
27
|
+
const website = results.find(r => r.name === name && r.app === "website");
|
|
28
|
+
if (!website?.stack?.deliveryDomain) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return removeProtocol(website.stack.deliveryDomain);
|
|
32
|
+
};
|
|
33
|
+
const getPreviewDomainName = (results, name) => {
|
|
34
|
+
const preview = results.find(r => r.name === name && r.app === "website");
|
|
35
|
+
if (!preview?.stack?.appDomain) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return removeProtocol(preview.stack.appDomain);
|
|
39
|
+
};
|
|
40
|
+
const getEnv = (results, name) => {
|
|
41
|
+
const env = results.find(r => r.name === name);
|
|
42
|
+
if (!env) {
|
|
43
|
+
throw new Error(`Missing environment for "${name}" deployment.`);
|
|
44
|
+
}
|
|
45
|
+
return env.env;
|
|
46
|
+
};
|
|
47
|
+
const getVariant = (results, name) => {
|
|
48
|
+
const variant = results.find(r => r.name === name);
|
|
49
|
+
if (!variant) {
|
|
50
|
+
throw new Error(`Missing variant for "${name}" deployment.`);
|
|
51
|
+
}
|
|
52
|
+
return variant.variant;
|
|
53
|
+
};
|
|
54
|
+
const getApplicationDomains = async params => {
|
|
55
|
+
const promises = [];
|
|
56
|
+
for (const stack of params.stacks) {
|
|
57
|
+
for (const app of apps) {
|
|
58
|
+
promises.push(new Promise(resolve => {
|
|
59
|
+
const result = (0, _getStackOutput.getStackOutput)({
|
|
60
|
+
folder: `apps/${app}`,
|
|
61
|
+
env: stack.env,
|
|
62
|
+
variant: stack.variant
|
|
63
|
+
});
|
|
64
|
+
resolve({
|
|
65
|
+
env: stack.env,
|
|
66
|
+
variant: stack.variant,
|
|
67
|
+
name: stack.name,
|
|
68
|
+
app,
|
|
69
|
+
stack: result
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const results = await Promise.all(promises);
|
|
75
|
+
const deployments = {};
|
|
76
|
+
const names = params.stacks.map(s => s.name);
|
|
77
|
+
try {
|
|
78
|
+
for (const name of names) {
|
|
79
|
+
const env = getEnv(results, name);
|
|
80
|
+
const variant = getVariant(results, name);
|
|
81
|
+
const api = getApiDomainName(results, name);
|
|
82
|
+
const admin = getAdminDomainName(results, name);
|
|
83
|
+
const website = getWebsiteDomainName(results, name);
|
|
84
|
+
const preview = getPreviewDomainName(results, name);
|
|
85
|
+
if (!website && preview) {
|
|
86
|
+
throw new Error(`Missing website stack for "${name}" deployment.`);
|
|
87
|
+
} else if (website && !preview) {
|
|
88
|
+
throw new Error(`Missing preview stack for "${name}" deployment.`);
|
|
89
|
+
}
|
|
90
|
+
deployments[name] = {
|
|
91
|
+
env,
|
|
92
|
+
variant,
|
|
93
|
+
api,
|
|
94
|
+
admin,
|
|
95
|
+
website,
|
|
96
|
+
preview
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return deployments;
|
|
100
|
+
} catch (ex) {
|
|
101
|
+
console.error(ex.message);
|
|
102
|
+
throw ex;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.getApplicationDomains = getApplicationDomains;
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=getApplicationDomains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_getStackOutput","require","apps","removeProtocol","url","replace","getApiDomainName","results","name","api","find","r","app","stack","apiDomain","Error","getAdminDomainName","admin","appDomain","getWebsiteDomainName","website","deliveryDomain","undefined","getPreviewDomainName","preview","getEnv","env","getVariant","variant","getApplicationDomains","params","promises","stacks","push","Promise","resolve","result","getStackOutput","folder","all","deployments","names","map","s","ex","console","error","message","exports"],"sources":["getApplicationDomains.ts"],"sourcesContent":["import {\n getStackOutput,\n type IDefaultStackOutput\n} from \"@webiny/cli-plugin-deploy-pulumi/utils/getStackOutput.js\";\n\nexport interface IGetStacksStack {\n name: string;\n env: string;\n variant: string | undefined;\n}\n\nexport interface IGetApplicationStacks {\n stacks: IGetStacksStack[];\n}\n\nconst apps = [\"api\", \"admin\", \"website\"];\n\ninterface IPromiseResult {\n app: string;\n env: string;\n variant: string | undefined;\n name: string;\n stack: IDefaultStackOutput;\n}\n\nexport interface IGetApplicationStacksResultStack {\n env: string;\n variant: string | undefined;\n api: string;\n admin: string;\n website: string | undefined;\n preview: string | undefined;\n}\n\nexport interface IGetApplicationStacksResult {\n [name: string]: IGetApplicationStacksResultStack;\n}\n\nconst removeProtocol = (url: string): string => {\n return url.replace(/^https?:\\/\\//, \"\");\n};\n\nconst getApiDomainName = (results: IPromiseResult[], name: string): string => {\n const api = results.find(r => r.name === name && r.app === \"api\");\n if (!api?.stack?.apiDomain) {\n throw new Error(`Missing API stack for \"${name}\" deployment.`);\n }\n return removeProtocol(api.stack.apiDomain);\n};\n\nconst getAdminDomainName = (results: IPromiseResult[], name: string): string => {\n const admin = results.find(r => r.name === name && r.app === \"admin\");\n if (!admin?.stack?.appDomain) {\n throw new Error(`Missing Admin stack for \"${name}\" deployment.`);\n }\n return removeProtocol(admin.stack.appDomain);\n};\n\nconst getWebsiteDomainName = (results: IPromiseResult[], name: string): string | undefined => {\n const website = results.find(r => r.name === name && r.app === \"website\");\n if (!website?.stack?.deliveryDomain) {\n return undefined;\n }\n return removeProtocol(website.stack.deliveryDomain);\n};\n\nconst getPreviewDomainName = (results: IPromiseResult[], name: string): string | undefined => {\n const preview = results.find(r => r.name === name && r.app === \"website\");\n if (!preview?.stack?.appDomain) {\n return undefined;\n }\n return removeProtocol(preview.stack.appDomain);\n};\n\nconst getEnv = (results: IPromiseResult[], name: string): string => {\n const env = results.find(r => r.name === name);\n if (!env) {\n throw new Error(`Missing environment for \"${name}\" deployment.`);\n }\n return env.env;\n};\n\nconst getVariant = (results: IPromiseResult[], name: string): string | undefined => {\n const variant = results.find(r => r.name === name);\n if (!variant) {\n throw new Error(`Missing variant for \"${name}\" deployment.`);\n }\n return variant.variant;\n};\n\nexport const getApplicationDomains = async (\n params: IGetApplicationStacks\n): Promise<IGetApplicationStacksResult> => {\n const promises: Promise<IPromiseResult>[] = [];\n\n for (const stack of params.stacks) {\n for (const app of apps) {\n promises.push(\n new Promise<IPromiseResult>(resolve => {\n const result = getStackOutput({\n folder: `apps/${app}`,\n env: stack.env,\n variant: stack.variant\n });\n resolve({\n env: stack.env,\n variant: stack.variant,\n name: stack.name,\n app,\n stack: result\n });\n })\n );\n }\n }\n const results = await Promise.all(promises);\n const deployments: IGetApplicationStacksResult = {};\n const names = params.stacks.map(s => s.name);\n try {\n for (const name of names) {\n const env = getEnv(results, name);\n const variant = getVariant(results, name);\n const api = getApiDomainName(results, name);\n const admin = getAdminDomainName(results, name);\n const website = getWebsiteDomainName(results, name);\n const preview = getPreviewDomainName(results, name);\n if (!website && preview) {\n throw new Error(`Missing website stack for \"${name}\" deployment.`);\n } else if (website && !preview) {\n throw new Error(`Missing preview stack for \"${name}\" deployment.`);\n }\n deployments[name] = {\n env,\n variant,\n api,\n admin,\n website,\n preview\n };\n }\n return deployments;\n } catch (ex) {\n console.error(ex.message);\n throw ex;\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAeA,MAAMC,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC;AAuBxC,MAAMC,cAAc,GAAIC,GAAW,IAAa;EAC5C,OAAOA,GAAG,CAACC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;AAC1C,CAAC;AAED,MAAMC,gBAAgB,GAAGA,CAACC,OAAyB,EAAEC,IAAY,KAAa;EAC1E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PI;MACJ,CAAC;IACL;IACA,OAAOgB,WAAW;EACtB,CAAC,CAAC,OAAOI,EAAE,EAAE;IACTC,OAAO,CAACC,KAAK,CAACF,EAAE,CAACG,OAAO,CAAC;IACzB,MAAMH,EAAE;EACZ;AACJ,CAAC;AAACI,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IAttachedDomains, IDeploymentsDomains, IResolvedDomains } from "../types.js";
|
|
2
|
+
export interface IResolveDomainsParams {
|
|
3
|
+
attachedDomains: IAttachedDomains;
|
|
4
|
+
deploymentsDomains: IDeploymentsDomains;
|
|
5
|
+
}
|
|
6
|
+
export declare const resolveDomains: (params: IResolveDomainsParams) => IResolvedDomains;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveDomains = void 0;
|
|
7
|
+
const resolveDomains = params => {
|
|
8
|
+
const {
|
|
9
|
+
attachedDomains,
|
|
10
|
+
deploymentsDomains
|
|
11
|
+
} = params;
|
|
12
|
+
const domains = attachedDomains.domains;
|
|
13
|
+
if (!domains) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
const types = Object.keys(domains).filter(key => {
|
|
17
|
+
return !!domains[key];
|
|
18
|
+
});
|
|
19
|
+
return types.reduce((output, type) => {
|
|
20
|
+
const value = domains[type];
|
|
21
|
+
/**
|
|
22
|
+
* Should not happen because we are filtering out undefined values when creating the `types` array.
|
|
23
|
+
*/
|
|
24
|
+
if (!value) {
|
|
25
|
+
return output;
|
|
26
|
+
} else if (value.length === 0) {
|
|
27
|
+
throw new Error(`Missing domains for "${type}" deployment.`);
|
|
28
|
+
}
|
|
29
|
+
for (const domain of deploymentsDomains) {
|
|
30
|
+
const target = domain.domains[type];
|
|
31
|
+
if (!target) {
|
|
32
|
+
throw new Error(`Missing "${type}" domain in deployment "${domain.name}".`);
|
|
33
|
+
}
|
|
34
|
+
output.push({
|
|
35
|
+
type,
|
|
36
|
+
env: domain.env,
|
|
37
|
+
variant: domain.variant,
|
|
38
|
+
name: domain.name,
|
|
39
|
+
sources: value,
|
|
40
|
+
target
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
}, []);
|
|
45
|
+
};
|
|
46
|
+
exports.resolveDomains = resolveDomains;
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=resolveDomains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["resolveDomains","params","attachedDomains","deploymentsDomains","domains","types","Object","keys","filter","key","reduce","output","type","value","length","Error","domain","target","name","push","env","variant","sources","exports"],"sources":["resolveDomains.ts"],"sourcesContent":["import type {\n IAttachedDomainKey,\n IAttachedDomains,\n IDeploymentsDomains,\n IResolvedDomains\n} from \"../types.js\";\n\nexport interface IResolveDomainsParams {\n attachedDomains: IAttachedDomains;\n deploymentsDomains: IDeploymentsDomains;\n}\n\nexport const resolveDomains = (params: IResolveDomainsParams): IResolvedDomains => {\n const { attachedDomains, deploymentsDomains } = params;\n\n const domains = attachedDomains.domains;\n\n if (!domains) {\n return [];\n }\n const types = Object.keys(domains).filter(key => {\n return !!domains[key as IAttachedDomainKey];\n }) as IAttachedDomainKey[];\n\n return types.reduce<IResolvedDomains>((output, type) => {\n const value = domains[type];\n /**\n * Should not happen because we are filtering out undefined values when creating the `types` array.\n */\n if (!value) {\n return output;\n } else if (value.length === 0) {\n throw new Error(`Missing domains for \"${type}\" deployment.`);\n }\n for (const domain of deploymentsDomains) {\n const target = domain.domains[type];\n if (!target) {\n throw new Error(`Missing \"${type}\" domain in deployment \"${domain.name}\".`);\n }\n\n output.push({\n type,\n env: domain.env,\n variant: domain.variant,\n name: domain.name,\n sources: value,\n target\n });\n }\n\n return output;\n }, []);\n};\n"],"mappings":";;;;;;AAYO,MAAMA,c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0 +1,15 @@
|
|
|
1
|
+
export interface IBuildRequestFunctionParamsDomain {
|
|
2
|
+
/**
|
|
3
|
+
* Name of the deployment (eg. green, blue, orange, etc.).
|
|
4
|
+
*/
|
|
5
|
+
name: string;
|
|
6
|
+
sourceDomain: string;
|
|
7
|
+
targetOriginId: string;
|
|
8
|
+
targetDomain: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IBuildRequestFunctionParams {
|
|
11
|
+
storeId: string;
|
|
12
|
+
storeKey: string;
|
|
13
|
+
domains: IBuildRequestFunctionParamsDomain[];
|
|
14
|
+
}
|
|
15
|
+
export declare const buildHandlerFunction: ({ storeId, storeKey, domains }: IBuildRequestFunctionParams) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildHandlerFunction = void 0;
|
|
7
|
+
var _fs = require("fs");
|
|
8
|
+
const buildHandlerFunction = ({
|
|
9
|
+
storeId,
|
|
10
|
+
storeKey,
|
|
11
|
+
domains
|
|
12
|
+
}) => {
|
|
13
|
+
const target = __dirname + `/handler.js`;
|
|
14
|
+
if (!(0, _fs.existsSync)(target)) {
|
|
15
|
+
throw new Error(`File "${target}" does not exist.`);
|
|
16
|
+
}
|
|
17
|
+
const content = (0, _fs.readFileSync)(target, "utf8");
|
|
18
|
+
if (!content) {
|
|
19
|
+
throw new Error(`File "${target}" is empty.`);
|
|
20
|
+
}
|
|
21
|
+
return content.replace("{BLUE_GREEN_ROUTER_STORE_ID}", storeId).replace("{BLUE_GREEN_ROUTER_STORE_KEY}", storeKey).replace(`"{BLUE_GREEN_ROUTER_DOMAINS}"`, JSON.stringify(domains));
|
|
22
|
+
};
|
|
23
|
+
exports.buildHandlerFunction = buildHandlerFunction;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=buildHandlerFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fs","require","buildHandlerFunction","storeId","storeKey","domains","target","__dirname","existsSync","Error","content","readFileSync","replace","JSON","stringify","exports"],"sources":["buildHandlerFunction.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface IBuildRequestFunctionParamsDomain {\n /**\n * Name of the deployment (eg. green, blue, orange, etc.).\n */\n name: string;\n sourceDomain: string;\n targetOriginId: string;\n targetDomain: string;\n}\n\nexport interface IBuildRequestFunctionParams {\n storeId: string;\n storeKey: string;\n domains: IBuildRequestFunctionParamsDomain[];\n}\n\nexport const buildHandlerFunction = ({\n storeId,\n storeKey,\n domains\n}: IBuildRequestFunctionParams): string => {\n const target = __dirname + `/handler.js`;\n if (!existsSync(target)) {\n throw new Error(`File \"${target}\" does not exist.`);\n }\n const content = readFileSync(target, \"utf8\");\n if (!content) {\n throw new Error(`File \"${target}\" is empty.`);\n }\n\n return content\n .replace(\"{BLUE_GREEN_ROUTER_STORE_ID}\", storeId)\n .replace(\"{BLUE_GREEN_ROUTER_STORE_KEY}\", storeKey)\n .replace(`\"{BLUE_GREEN_ROUTER_DOMAINS}\"`, JSON.stringify(domains));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAkBO,MAAMC,oBAAoB,GAAGA,CAAC;EACjCC,OAAO;EACPC,QAAQ;EACRC;AACyB,CAAC,KAAa;EACvC,MAAMC,MAAM,GAAGC,SAAS,GAAG,aAAa;EACxC,IAAI,CAAC,IAAAC,cAAU,EAACF,MAAM,CAAC,EAAE;IACrB,MAAM,IAAIG,KAAK,CAAC,SAASH,MAAM,mBAAmB,CAAC;EACvD;EACA,MAAMI,OAAO,GAAG,IAAAC,gBAAY,EAACL,MAAM,EAAE,MAAM,CAAC;EAC5C,IAAI,CAACI,OAAO,EAAE;IACV,MAAM,IAAID,KAAK,CAAC,SAASH,MAAM,aAAa,CAAC;EACjD;EAEA,OAAOI,OAAO,CACTE,OAAO,CAAC,8BAA8B,EAAET,OAAO,CAAC,CAChDS,OAAO,CAAC,+BAA+B,EAAER,QAAQ,CAAC,CAClDQ,OAAO,CAAC,+BAA+B,EAAEC,IAAI,CAACC,SAAS,CAACT,OAAO,CAAC,CAAC;AAC1E,CAAC;AAACU,OAAA,CAAAb,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const cf = require("cloudfront");
|
|
4
|
+
const BLUE_GREEN_ROUTER_STORE_ID = "{BLUE_GREEN_ROUTER_STORE_ID}";
|
|
5
|
+
const BLUE_GREEN_ROUTER_STORE_KEY = "{BLUE_GREEN_ROUTER_STORE_KEY}";
|
|
6
|
+
const BLUE_GREEN_ROUTER_DOMAINS = "{BLUE_GREEN_ROUTER_DOMAINS}";
|
|
7
|
+
const store = cf.kvs(BLUE_GREEN_ROUTER_STORE_ID);
|
|
8
|
+
function removeProtocol(url) {
|
|
9
|
+
return url.replace(/^https?:\/\//, "");
|
|
10
|
+
}
|
|
11
|
+
function requestWithError(request, error) {
|
|
12
|
+
console.log(`There is an error: ${error.message}`);
|
|
13
|
+
const properties = Object.getOwnPropertyNames(error);
|
|
14
|
+
for (const property in properties) {
|
|
15
|
+
console.log(`${property}: ${error[property]}`);
|
|
16
|
+
}
|
|
17
|
+
request.headers["x-webiny-debug-log"] = {
|
|
18
|
+
value: error.message
|
|
19
|
+
};
|
|
20
|
+
return request;
|
|
21
|
+
}
|
|
22
|
+
function getTargetDomain(headers, active) {
|
|
23
|
+
const values = headers.host;
|
|
24
|
+
if (!values) {
|
|
25
|
+
throw new Error("Missing the 'host' header.");
|
|
26
|
+
}
|
|
27
|
+
const initialHost = Array.isArray(values) ? values[0].value : values.value;
|
|
28
|
+
if (!initialHost) {
|
|
29
|
+
throw new Error("Missing the 'host' header value.");
|
|
30
|
+
}
|
|
31
|
+
const host = removeProtocol(initialHost);
|
|
32
|
+
const domain = BLUE_GREEN_ROUTER_DOMAINS.find(domain => domain.name === active && domain.sourceDomain === host);
|
|
33
|
+
if (domain) {
|
|
34
|
+
return domain;
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`Could not find a domain mapping for ${host}.`);
|
|
37
|
+
}
|
|
38
|
+
function handleRequest(request, active) {
|
|
39
|
+
const targetDomain = getTargetDomain(request.headers || {}, active);
|
|
40
|
+
cf.updateRequestOrigin({
|
|
41
|
+
domainName: targetDomain.targetDomain
|
|
42
|
+
});
|
|
43
|
+
return request;
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
+
async function handler(event) {
|
|
47
|
+
const context = event.context;
|
|
48
|
+
const request = event.request;
|
|
49
|
+
try {
|
|
50
|
+
if (context.eventType !== "viewer-request") {
|
|
51
|
+
new Error("This function only supports viewer-request events.");
|
|
52
|
+
}
|
|
53
|
+
const active = await store.get(BLUE_GREEN_ROUTER_STORE_KEY);
|
|
54
|
+
if (!active) {
|
|
55
|
+
throw new Error("Blue/Green system is not configured.");
|
|
56
|
+
}
|
|
57
|
+
return await handleRequest(request, active);
|
|
58
|
+
} catch (ex) {
|
|
59
|
+
return requestWithError(request, ex);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cf","require","BLUE_GREEN_ROUTER_STORE_ID","BLUE_GREEN_ROUTER_STORE_KEY","BLUE_GREEN_ROUTER_DOMAINS","store","kvs","removeProtocol","url","replace","requestWithError","request","error","console","log","message","properties","Object","getOwnPropertyNames","property","headers","value","getTargetDomain","active","values","host","Error","initialHost","Array","isArray","domain","find","name","sourceDomain","handleRequest","targetDomain","updateRequestOrigin","domainName","handler","event","context","eventType","get","ex"],"sources":["handler.js"],"sourcesContent":["const cf = require(\"cloudfront\");\n\nconst BLUE_GREEN_ROUTER_STORE_ID = \"{BLUE_GREEN_ROUTER_STORE_ID}\";\nconst BLUE_GREEN_ROUTER_STORE_KEY = \"{BLUE_GREEN_ROUTER_STORE_KEY}\";\nconst BLUE_GREEN_ROUTER_DOMAINS = \"{BLUE_GREEN_ROUTER_DOMAINS}\";\n\nconst store = cf.kvs(BLUE_GREEN_ROUTER_STORE_ID);\n\nfunction removeProtocol(url) {\n return url.replace(/^https?:\\/\\//, \"\");\n}\nfunction requestWithError(request, error) {\n console.log(`There is an error: ${error.message}`);\n const properties = Object.getOwnPropertyNames(error);\n for (const property in properties) {\n console.log(`${property}: ${error[property]}`);\n }\n request.headers[\"x-webiny-debug-log\"] = {\n value: error.message\n };\n\n return request;\n}\n\nfunction getTargetDomain(headers, active) {\n const values = headers.host;\n if (!values) {\n throw new Error(\"Missing the 'host' header.\");\n }\n const initialHost = Array.isArray(values) ? values[0].value : values.value;\n if (!initialHost) {\n throw new Error(\"Missing the 'host' header value.\");\n }\n const host = removeProtocol(initialHost);\n\n const domain = BLUE_GREEN_ROUTER_DOMAINS.find(\n domain => domain.name === active && domain.sourceDomain === host\n );\n if (domain) {\n return domain;\n }\n throw new Error(`Could not find a domain mapping for ${host}.`);\n}\n\nfunction handleRequest(request, active) {\n const targetDomain = getTargetDomain(request.headers || {}, active);\n\n cf.updateRequestOrigin({\n domainName: targetDomain.targetDomain\n });\n\n return request;\n}\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nasync function handler(event) {\n const context = event.context;\n const request = event.request;\n\n try {\n if (context.eventType !== \"viewer-request\") {\n new Error(\"This function only supports viewer-request events.\");\n }\n const active = await store.get(BLUE_GREEN_ROUTER_STORE_KEY);\n if (!active) {\n throw new Error(\"Blue/Green system is not configured.\");\n }\n\n return await handleRequest(request, active);\n } catch (ex) {\n return requestWithError(request, ex);\n }\n}\n"],"mappings":";;AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,YAAY,CAAC;AAEhC,MAAMC,0BAA0B,GAAG,8BAA8B;AACjE,MAA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AIO,MAAM,CAACG,YAAY,KAAKR,IAChE,CAAC;EACD,IAAIK,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;EACA,MAAM,IAAIJ,KAAK,CAAC,uCAAuCD,IAAI,GAAG,CAAC;AACnE;AAEA,SAASS,aAAaA,CAACvB,OAAO,EAAEY,MAAM,EAAE;EACpC,MAAMY,YAAY,GAAGb,eAAe,CAACX,OAAO,CAACS,OAAO,IAAI,CAAC,CAAC,EAAEG,MAAM,CAAC;EAEnEvB,EAAE,CAACoC,mBAAmB,CAAC;IACnBC,UAAU,EAAEF,YAAY,CAACA;EAC7B,CAAC,CAAC;EAEF,OAAOxB,OAAO;AAClB;AACA;AACA,eAAe2B,OAAOA,CAACC,KAAK,EAAE;EAC1B,MAAMC,OAAO,GAAGD,KAAK,CAACC,OAAO;EAC7B,MAAM7B,OAAO,GAAG4B,KAAK,CAAC5B,OAAO;EAE7B,IAAI;IACA,IAAI6B,OAAO,CAACC,SAAS,KAAK,gBAAgB,EAAE;MACxC,IAAIf,KAAK,CAAC,oDAAoD,CAAC;IACnE;IACA,MAAMH,MAAM,GAAG,MAAMlB,KAAK,CAACqC,GAAG,CAACvC,2BAA2B,CAAC;IAC3D,IAAI,CAACoB,MAAM,EAAE;MACT,MAAM,IAAIG,KAAK,CAAC,sCAAsC,CAAC;IAC3D;IAEA,OAAO,MAAMQ,aAAa,CAACvB,OAAO,EAAEY,MAAM,CAAC;EAC/C,CAAC,CAAC,OAAOoB,EAAE,EAAE;IACT,OAAOjC,gBAAgB,CAACC,OAAO,EAAEgC,EAAE,CAAC;EACxC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { IStackOutput } from "@webiny/cli-plugin-deploy-pulumi/utils/index.js";
|
|
2
|
+
export type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;
|
|
3
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
4
|
+
export interface IDeploymentDomain {
|
|
5
|
+
/**
|
|
6
|
+
* A name of the deployment (e.g. "green" or "blue").
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
env: string;
|
|
10
|
+
variant: string | undefined;
|
|
11
|
+
domains: {
|
|
12
|
+
api: string;
|
|
13
|
+
admin: string;
|
|
14
|
+
website: string | undefined;
|
|
15
|
+
preview: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export type IDeploymentsDomains = [IDeploymentDomain, IDeploymentDomain];
|
|
19
|
+
export interface IBlueGreenDeployment {
|
|
20
|
+
/**
|
|
21
|
+
* Name by this deployment will be accessible in the Pulumi program.
|
|
22
|
+
*/
|
|
23
|
+
name: string;
|
|
24
|
+
env: string;
|
|
25
|
+
variant: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface IAttachedDomainsTypes {
|
|
28
|
+
api: NonEmptyArray<string>;
|
|
29
|
+
admin: NonEmptyArray<string>;
|
|
30
|
+
website: NonEmptyArray<string> | undefined;
|
|
31
|
+
preview: NonEmptyArray<string> | undefined;
|
|
32
|
+
}
|
|
33
|
+
export interface IAttachedDomains {
|
|
34
|
+
acmCertificateArn: string;
|
|
35
|
+
sslSupportMethod?: string;
|
|
36
|
+
/**
|
|
37
|
+
* We need to allow system to be deployed without any domains for start.
|
|
38
|
+
* User can attach domains later.
|
|
39
|
+
*/
|
|
40
|
+
domains?: IAttachedDomainsTypes;
|
|
41
|
+
}
|
|
42
|
+
export interface IAttachDomainsCallable {
|
|
43
|
+
(): IAttachedDomains;
|
|
44
|
+
}
|
|
45
|
+
export type IAttachedDomainKey = keyof IAttachedDomainsTypes;
|
|
46
|
+
export interface IResolvedDomain {
|
|
47
|
+
/**
|
|
48
|
+
* Environment and variant of the deployment.
|
|
49
|
+
*/
|
|
50
|
+
env: string;
|
|
51
|
+
variant: string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Name of the deployment (e.g. "green" or "blue").
|
|
54
|
+
*/
|
|
55
|
+
name: string;
|
|
56
|
+
/**
|
|
57
|
+
* Type of the domain (e.g. "api", "admin", "website", "preview").
|
|
58
|
+
*/
|
|
59
|
+
type: IAttachedDomainKey;
|
|
60
|
+
/**
|
|
61
|
+
* List of domains that will be used as source and transferred to the target domain.
|
|
62
|
+
*/
|
|
63
|
+
sources: NonEmptyArray<string>;
|
|
64
|
+
/**
|
|
65
|
+
* The target CloudFront domain of the deployment.
|
|
66
|
+
*/
|
|
67
|
+
target: string;
|
|
68
|
+
}
|
|
69
|
+
export type IResolvedDomains = IResolvedDomain[];
|
|
70
|
+
export interface IBlueGreenStackOutput extends IStackOutput {
|
|
71
|
+
distributionDomain: string;
|
|
72
|
+
distributionUrl: string;
|
|
73
|
+
/**
|
|
74
|
+
* TODO fix later
|
|
75
|
+
*/
|
|
76
|
+
environments?: IResolvedDomains;
|
|
77
|
+
domains?: string[];
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IStackOutput } from \"@webiny/cli-plugin-deploy-pulumi/utils/index.js\";\n\nexport type GenericRecord<K extends PropertyKey = PropertyKey, V = any> = Record<K, V>;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport interface IDeploymentDomain {\n /**\n * A name of the deployment (e.g. \"green\" or \"blue\").\n */\n name: string;\n env: string;\n variant: string | undefined;\n domains: {\n api: string;\n admin: string;\n website: string | undefined;\n preview: string | undefined;\n };\n}\n\nexport type IDeploymentsDomains = [IDeploymentDomain, IDeploymentDomain];\n\nexport interface IBlueGreenDeployment {\n /**\n * Name by this deployment will be accessible in the Pulumi program.\n */\n name: string;\n env: string;\n variant: string | undefined;\n}\n\nexport interface IAttachedDomainsTypes {\n api: NonEmptyArray<string>;\n admin: NonEmptyArray<string>;\n website: NonEmptyArray<string> | undefined;\n preview: NonEmptyArray<string> | undefined;\n}\n\nexport interface IAttachedDomains {\n acmCertificateArn: string;\n sslSupportMethod?: string;\n /**\n * We need to allow system to be deployed without any domains for start.\n * User can attach domains later.\n */\n domains?: IAttachedDomainsTypes;\n}\n\nexport interface IAttachDomainsCallable {\n (): IAttachedDomains;\n}\n\nexport type IAttachedDomainKey = keyof IAttachedDomainsTypes;\n\nexport interface IResolvedDomain {\n /**\n * Environment and variant of the deployment.\n */\n env: string;\n variant: string | undefined;\n /**\n * Name of the deployment (e.g. \"green\" or \"blue\").\n */\n name: string;\n /**\n * Type of the domain (e.g. \"api\", \"admin\", \"website\", \"preview\").\n */\n type: IAttachedDomainKey;\n /**\n * List of domains that will be used as source and transferred to the target domain.\n */\n sources: NonEmptyArray<string>;\n /**\n * The target CloudFront domain of the deployment.\n */\n target: string;\n}\n\nexport type IResolvedDomains = IResolvedDomain[];\n\nexport interface IBlueGreenStackOutput extends IStackOutput {\n distributionDomain: string;\n distributionUrl: string;\n /**\n * TODO fix later\n */\n // @ts-expect-error\n environments?: IResolvedDomains;\n domains?: string[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.validateDeployments = void 0;
|
|
8
|
+
var _zod = _interopRequireDefault(require("zod"));
|
|
9
|
+
var _createZodError = require("@webiny/utils/createZodError.js");
|
|
10
|
+
const schema = _zod.default.array(_zod.default.object({
|
|
11
|
+
name: _zod.default.string(),
|
|
12
|
+
env: _zod.default.string(),
|
|
13
|
+
variant: _zod.default.string().optional()
|
|
14
|
+
})).min(2).max(2).refine(items => {
|
|
15
|
+
const check = new Set(items.map(i => i.name));
|
|
16
|
+
return check.size === items.length;
|
|
17
|
+
}, {
|
|
18
|
+
message: "Names must be unique."
|
|
19
|
+
}).refine(items => {
|
|
20
|
+
const checks = new Set(items.map(item => {
|
|
21
|
+
return `${item.env}#${item.variant || "not-set"}`;
|
|
22
|
+
}));
|
|
23
|
+
return checks.size === items.length;
|
|
24
|
+
}, {
|
|
25
|
+
message: "Environment / variant combinations must be unique."
|
|
26
|
+
});
|
|
27
|
+
const validateDeployments = deployments => {
|
|
28
|
+
const result = schema.safeParse(deployments);
|
|
29
|
+
if (result.error) {
|
|
30
|
+
throw (0, _createZodError.createZodError)(result.error);
|
|
31
|
+
}
|
|
32
|
+
return result.data.map(item => {
|
|
33
|
+
return {
|
|
34
|
+
...item,
|
|
35
|
+
variant: item.variant
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.validateDeployments = validateDeployments;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=validateDeployments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_zod","_interopRequireDefault","require","_createZodError","schema","zod","array","object","name","string","env","variant","optional","min","max","refine","items","check","Set","map","i","size","length","message","checks","item","validateDeployments","deployments","result","safeParse","error","createZodError","data","exports"],"sources":["validateDeployments.ts"],"sourcesContent":["import type { IBlueGreenDeployment } from \"../types.js\";\nimport zod from \"zod\";\nimport { createZodError } from \"@webiny/utils/createZodError.js\";\n\nconst schema = zod\n .array(\n zod.object({\n name: zod.string(),\n env: zod.string(),\n variant: zod.string().optional()\n })\n )\n .min(2)\n .max(2)\n .refine(\n items => {\n const check = new Set(items.map(i => i.name));\n return check.size === items.length;\n },\n {\n message: \"Names must be unique.\"\n }\n )\n .refine(\n items => {\n const checks = new Set(\n items.map(item => {\n return `${item.env}#${item.variant || \"not-set\"}`;\n })\n );\n return checks.size === items.length;\n },\n {\n message: \"Environment / variant combinations must be unique.\"\n }\n );\n\nexport const validateDeployments = (deployments: unknown): IBlueGreenDeployment[] => {\n const result = schema.safeParse(deployments);\n if (result.error) {\n throw createZodError(result.error);\n }\n return result.data.map(item => {\n return {\n ...item,\n variant: item.variant\n };\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAA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,IAAI;MACPd,OAAO,EAAEc,IAAI,CAACd;IAClB,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACsB,OAAA,CAAAP,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -12,7 +12,8 @@ const CoreOutput = exports.CoreOutput = (0, _pulumi.createAppModule)({
|
|
|
12
12
|
return app.addHandler(async () => {
|
|
13
13
|
const output = (0, _utils.getStackOutput)({
|
|
14
14
|
folder: "apps/core",
|
|
15
|
-
env: app.params.run.env
|
|
15
|
+
env: app.params.run.env,
|
|
16
|
+
variant: app.params.run.variant
|
|
16
17
|
});
|
|
17
18
|
if (!output) {
|
|
18
19
|
throw new Error("Core application is not deployed.");
|
|
@@ -37,6 +38,7 @@ const CoreOutput = exports.CoreOutput = (0, _pulumi.createAppModule)({
|
|
|
37
38
|
vpcPublicSubnetIds: output["vpcPublicSubnetIds"],
|
|
38
39
|
vpcPrivateSubnetIds: output["vpcPrivateSubnetIds"],
|
|
39
40
|
vpcSecurityGroupIds: output["vpcSecurityGroupIds"],
|
|
41
|
+
// These outputs are optional, since Elasticsearch is not always enabled.
|
|
40
42
|
elasticsearchDomainArn: output["elasticsearchDomainArn"],
|
|
41
43
|
elasticsearchDomainEndpoint: output["elasticsearchDomainEndpoint"],
|
|
42
44
|
elasticsearchDynamodbTableArn: output["elasticsearchDynamodbTableArn"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_pulumi","require","_utils","CoreOutput","exports","createAppModule","name","config","app","addHandler","output","getStackOutput","folder","env","params","run","Error","fileManagerBucketId","primaryDynamodbTableArn","primaryDynamodbTableName","primaryDynamodbTableHashKey","primaryDynamodbTableRangeKey","logDynamodbTableArn","logDynamodbTableName","logDynamodbTableHashKey","logDynamodbTableRangeKey","cognitoUserPoolId","cognitoUserPoolArn","cognitoUserPoolPasswordPolicy","cognitoAppClientId","eventBusName","eventBusArn","vpcPublicSubnetIds","vpcPrivateSubnetIds","vpcSecurityGroupIds","elasticsearchDomainArn","elasticsearchDomainEndpoint","elasticsearchDynamodbTableArn","elasticsearchDynamodbTableName"],"sources":["CoreOutput.ts"],"sourcesContent":["import { createAppModule, PulumiAppModule } from \"@webiny/pulumi\";\nimport { getStackOutput } from \"@webiny/cli-plugin-deploy-pulumi/utils\";\n\nexport type CoreOutput = PulumiAppModule<typeof CoreOutput>;\n\nexport const CoreOutput = createAppModule({\n name: \"CoreOutput\",\n config(app) {\n return app.addHandler(async () => {\n const output = getStackOutput({\n folder: \"apps/core\",\n env: app.params.run.env\n });\n\n if (!output) {\n throw new Error(\"Core application is not deployed.\");\n }\n\n return {\n fileManagerBucketId: output[\"fileManagerBucketId\"]
|
|
1
|
+
{"version":3,"names":["_pulumi","require","_utils","CoreOutput","exports","createAppModule","name","config","app","addHandler","output","getStackOutput","folder","env","params","run","variant","Error","fileManagerBucketId","primaryDynamodbTableArn","primaryDynamodbTableName","primaryDynamodbTableHashKey","primaryDynamodbTableRangeKey","logDynamodbTableArn","logDynamodbTableName","logDynamodbTableHashKey","logDynamodbTableRangeKey","cognitoUserPoolId","cognitoUserPoolArn","cognitoUserPoolPasswordPolicy","cognitoAppClientId","eventBusName","eventBusArn","vpcPublicSubnetIds","vpcPrivateSubnetIds","vpcSecurityGroupIds","elasticsearchDomainArn","elasticsearchDomainEndpoint","elasticsearchDynamodbTableArn","elasticsearchDynamodbTableName"],"sources":["CoreOutput.ts"],"sourcesContent":["import { createAppModule, PulumiAppModule } from \"@webiny/pulumi\";\nimport { getStackOutput } from \"@webiny/cli-plugin-deploy-pulumi/utils\";\n\nexport type CoreOutput = PulumiAppModule<typeof CoreOutput>;\n\nexport const CoreOutput = createAppModule({\n name: \"CoreOutput\",\n config(app) {\n return app.addHandler(async () => {\n const output = getStackOutput({\n folder: \"apps/core\",\n env: app.params.run.env,\n variant: app.params.run.variant\n });\n\n if (!output) {\n throw new Error(\"Core application is not deployed.\");\n }\n\n return {\n fileManagerBucketId: output[\"fileManagerBucketId\"],\n primaryDynamodbTableArn: output[\"primaryDynamodbTableArn\"],\n primaryDynamodbTableName: output[\"primaryDynamodbTableName\"],\n primaryDynamodbTableHashKey: output[\"primaryDynamodbTableHashKey\"],\n primaryDynamodbTableRangeKey: output[\"primaryDynamodbTableRangeKey\"],\n logDynamodbTableArn: output[\"logDynamodbTableArn\"],\n logDynamodbTableName: output[\"logDynamodbTableName\"],\n logDynamodbTableHashKey: output[\"logDynamodbTableHashKey\"],\n logDynamodbTableRangeKey: output[\"logDynamodbTableRangeKey\"],\n cognitoUserPoolId: output[\"cognitoUserPoolId\"],\n cognitoUserPoolArn: output[\"cognitoUserPoolArn\"],\n cognitoUserPoolPasswordPolicy: output[\"cognitoUserPoolPasswordPolicy\"],\n cognitoAppClientId: output[\"cognitoAppClientId\"],\n eventBusName: output[\"eventBusName\"],\n eventBusArn: output[\"eventBusArn\"],\n // These outputs are optional, since VPC is not always enabled.\n vpcPublicSubnetIds: output[\"vpcPublicSubnetIds\"],\n vpcPrivateSubnetIds: output[\"vpcPrivateSubnetIds\"],\n vpcSecurityGroupIds: output[\"vpcSecurityGroupIds\"],\n // These outputs are optional, since Elasticsearch is not always enabled.\n elasticsearchDomainArn: output[\"elasticsearchDomainArn\"],\n elasticsearchDomainEndpoint: output[\"elasticsearchDomainEndpoint\"],\n elasticsearchDynamodbTableArn: output[\"elasticsearchDynamodbTableArn\"],\n elasticsearchDynamodbTableName: output[\"elasticsearchDynamodbTableName\"]\n };\n });\n }\n});\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAIO,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAAE,uBAAe,EAAC;EACtCC,IAAI,EAAE,YAAY;EAClBC,MAAMA,CAACC,GAAG,EAAE;IACR,OAAOA,GAAG,CAACC,UAAU,CAAC,YAAY;MAC9B,MAAMC,MAAM,GAAG,IAAAC,qBAAc,EAAC;QAC1BC,MAAM,EAAE,WAAW;QACnBC,G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AAC;QAClE4B,6BAA6B,EAAE5B,MAAM,CAAC,+BAA+B,CAAC;QACtE6B,8BAA8B,EAAE7B,MAAM,CAAC,gCAAgC;MAC3E,CAAC;IACL,CAAC,CAAC;EACN;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -8,11 +8,12 @@ exports.configureAdminCognitoFederation = void 0;
|
|
|
8
8
|
var aws = _interopRequireWildcard(require("@pulumi/aws"));
|
|
9
9
|
var pulumi = _interopRequireWildcard(require("@pulumi/pulumi"));
|
|
10
10
|
var _getIdpConfig = require("./getIdpConfig");
|
|
11
|
+
var _awsRegion = require("../../../env/awsRegion");
|
|
11
12
|
const isString = value => {
|
|
12
13
|
return typeof value === "string";
|
|
13
14
|
};
|
|
14
15
|
const configureAdminCognitoFederation = (app, config) => {
|
|
15
|
-
const region =
|
|
16
|
+
const region = (0, _awsRegion.getEnvVariableAwsRegion)();
|
|
16
17
|
const userPool = app.resources.userPool;
|
|
17
18
|
const appClient = app.resources.userPoolClient;
|
|
18
19
|
|