@webiny/pulumi-aws 0.0.0-ee-vpcs.549378cf03
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/LICENSE +21 -0
- package/README.md +328 -0
- package/apps/admin/createAdminPulumiApp.d.ts +24 -0
- package/apps/admin/createAdminPulumiApp.js +21 -0
- package/apps/admin/createAdminPulumiApp.js.map +1 -0
- package/apps/admin/index.d.ts +1 -0
- package/apps/admin/index.js +18 -0
- package/apps/admin/index.js.map +1 -0
- package/apps/api/ApiApwScheduler.d.ts +20 -0
- package/apps/api/ApiApwScheduler.js +246 -0
- package/apps/api/ApiApwScheduler.js.map +1 -0
- package/apps/api/ApiCloudfront.d.ts +3 -0
- package/apps/api/ApiCloudfront.js +101 -0
- package/apps/api/ApiCloudfront.js.map +1 -0
- package/apps/api/ApiFileManager.d.ts +10 -0
- package/apps/api/ApiFileManager.js +166 -0
- package/apps/api/ApiFileManager.js.map +1 -0
- package/apps/api/ApiGateway.d.ts +18 -0
- package/apps/api/ApiGateway.js +88 -0
- package/apps/api/ApiGateway.js.map +1 -0
- package/apps/api/ApiGraphql.d.ts +26 -0
- package/apps/api/ApiGraphql.js +167 -0
- package/apps/api/ApiGraphql.js.map +1 -0
- package/apps/api/ApiHeadlessCMS.d.ts +13 -0
- package/apps/api/ApiHeadlessCMS.js +94 -0
- package/apps/api/ApiHeadlessCMS.js.map +1 -0
- package/apps/api/ApiOutput.d.ts +15 -0
- package/apps/api/ApiOutput.js +43 -0
- package/apps/api/ApiOutput.js.map +1 -0
- package/apps/api/ApiPageBuilder.d.ts +24 -0
- package/apps/api/ApiPageBuilder.js +248 -0
- package/apps/api/ApiPageBuilder.js.map +1 -0
- package/apps/api/createApiPulumiApp.d.ts +71 -0
- package/apps/api/createApiPulumiApp.js +188 -0
- package/apps/api/createApiPulumiApp.js.map +1 -0
- package/apps/api/index.d.ts +9 -0
- package/apps/api/index.js +122 -0
- package/apps/api/index.js.map +1 -0
- package/apps/awsUtils.d.ts +3 -0
- package/apps/awsUtils.js +23 -0
- package/apps/awsUtils.js.map +1 -0
- package/apps/common/CoreOutput.d.ts +21 -0
- package/apps/common/CoreOutput.js +50 -0
- package/apps/common/CoreOutput.js.map +1 -0
- package/apps/common/VpcConfig.d.ts +8 -0
- package/apps/common/VpcConfig.js +37 -0
- package/apps/common/VpcConfig.js.map +1 -0
- package/apps/common/index.d.ts +2 -0
- package/apps/common/index.js +31 -0
- package/apps/common/index.js.map +1 -0
- package/apps/core/CoreCognito.d.ts +10 -0
- package/apps/core/CoreCognito.js +100 -0
- package/apps/core/CoreCognito.js.map +1 -0
- package/apps/core/CoreDynamo.d.ts +5 -0
- package/apps/core/CoreDynamo.js +51 -0
- package/apps/core/CoreDynamo.js.map +1 -0
- package/apps/core/CoreElasticSearch.d.ts +16 -0
- package/apps/core/CoreElasticSearch.js +286 -0
- package/apps/core/CoreElasticSearch.js.map +1 -0
- package/apps/core/CoreEventBus.d.ts +1 -0
- package/apps/core/CoreEventBus.js +25 -0
- package/apps/core/CoreEventBus.js.map +1 -0
- package/apps/core/CoreFileManager.d.ts +8 -0
- package/apps/core/CoreFileManager.js +55 -0
- package/apps/core/CoreFileManager.js.map +1 -0
- package/apps/core/CoreVpc.d.ts +13 -0
- package/apps/core/CoreVpc.js +148 -0
- package/apps/core/CoreVpc.js.map +1 -0
- package/apps/core/createCorePulumiApp.d.ts +64 -0
- package/apps/core/createCorePulumiApp.js +104 -0
- package/apps/core/createCorePulumiApp.js.map +1 -0
- package/apps/core/index.d.ts +6 -0
- package/apps/core/index.js +83 -0
- package/apps/core/index.js.map +1 -0
- package/apps/createAppBucket.d.ts +13 -0
- package/apps/createAppBucket.js +106 -0
- package/apps/createAppBucket.js.map +1 -0
- package/apps/customDomain.d.ts +9 -0
- package/apps/customDomain.js +14 -0
- package/apps/customDomain.js.map +1 -0
- package/apps/index.d.ts +7 -0
- package/apps/index.js +100 -0
- package/apps/index.js.map +1 -0
- package/apps/lambdaUtils.d.ts +10 -0
- package/apps/lambdaUtils.js +82 -0
- package/apps/lambdaUtils.js.map +1 -0
- package/apps/react/createReactPulumiApp.d.ts +33 -0
- package/apps/react/createReactPulumiApp.js +144 -0
- package/apps/react/createReactPulumiApp.js.map +1 -0
- package/apps/react/index.d.ts +1 -0
- package/apps/react/index.js +18 -0
- package/apps/react/index.js.map +1 -0
- package/apps/tenantRouter.d.ts +3 -0
- package/apps/tenantRouter.js +115 -0
- package/apps/tenantRouter.js.map +1 -0
- package/apps/website/WebsitePrerendering.d.ts +39 -0
- package/apps/website/WebsitePrerendering.js +300 -0
- package/apps/website/WebsitePrerendering.js.map +1 -0
- package/apps/website/createWebsitePulumiApp.d.ts +74 -0
- package/apps/website/createWebsitePulumiApp.js +246 -0
- package/apps/website/createWebsitePulumiApp.js.map +1 -0
- package/apps/website/deliveryViewerRequest.d.ts +2 -0
- package/apps/website/deliveryViewerRequest.js +32 -0
- package/apps/website/deliveryViewerRequest.js.map +1 -0
- package/apps/website/index.d.ts +1 -0
- package/apps/website/index.js +18 -0
- package/apps/website/index.js.map +1 -0
- package/components/tenantRouter/WebsiteTenantRouter.d.ts +11 -0
- package/components/tenantRouter/WebsiteTenantRouter.js +98 -0
- package/components/tenantRouter/WebsiteTenantRouter.js.map +1 -0
- package/components/tenantRouter/functions/origin/request.d.ts +1 -0
- package/components/tenantRouter/functions/origin/request.js +129 -0
- package/components/tenantRouter/functions/origin/request.js.map +1 -0
- package/enterprise/createAdminPulumiApp.d.ts +1 -0
- package/enterprise/createAdminPulumiApp.js +25 -0
- package/enterprise/createAdminPulumiApp.js.map +1 -0
- package/enterprise/createApiPulumiApp.d.ts +61 -0
- package/enterprise/createApiPulumiApp.js +68 -0
- package/enterprise/createApiPulumiApp.js.map +1 -0
- package/enterprise/createCorePulumiApp.d.ts +42 -0
- package/enterprise/createCorePulumiApp.js +137 -0
- package/enterprise/createCorePulumiApp.js.map +1 -0
- package/enterprise/createWebsitePulumiApp.d.ts +56 -0
- package/enterprise/createWebsitePulumiApp.js +68 -0
- package/enterprise/createWebsitePulumiApp.js.map +1 -0
- package/enterprise/index.d.ts +4 -0
- package/enterprise/index.js +57 -0
- package/enterprise/index.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +44 -0
- package/index.js.map +1 -0
- package/package.json +53 -0
- package/utils/crawlDirectory.d.ts +1 -0
- package/utils/crawlDirectory.js +33 -0
- package/utils/crawlDirectory.js.map +1 -0
- package/utils/getPresignedPost.d.ts +11 -0
- package/utils/getPresignedPost.js +46 -0
- package/utils/getPresignedPost.js.map +1 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +51 -0
- package/utils/index.js.map +1 -0
- package/utils/lambdaEnvVariables.d.ts +20 -0
- package/utils/lambdaEnvVariables.js +78 -0
- package/utils/lambdaEnvVariables.js.map +1 -0
- package/utils/storageMigrate.d.ts +0 -0
- package/utils/storageMigrate.js +292 -0
- package/utils/storageMigrate.js.map +1 -0
- package/utils/tagResources.d.ts +5 -0
- package/utils/tagResources.js +43 -0
- package/utils/tagResources.js.map +1 -0
- package/utils/uploadFolderToS3.d.ts +26 -0
- package/utils/uploadFolderToS3.js +188 -0
- package/utils/uploadFolderToS3.js.map +1 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.ApiPageBuilder = void 0;
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var path = _interopRequireWildcard(require("path"));
|
|
15
|
+
|
|
16
|
+
var pulumi = _interopRequireWildcard(require("@pulumi/pulumi"));
|
|
17
|
+
|
|
18
|
+
var aws = _interopRequireWildcard(require("@pulumi/aws"));
|
|
19
|
+
|
|
20
|
+
var _installation = require("@webiny/api-page-builder/installation");
|
|
21
|
+
|
|
22
|
+
var _pulumi2 = require("@webiny/pulumi");
|
|
23
|
+
|
|
24
|
+
var _common = require("../common");
|
|
25
|
+
|
|
26
|
+
var _lambdaUtils = require("../lambdaUtils");
|
|
27
|
+
|
|
28
|
+
var _awsUtils = require("../awsUtils");
|
|
29
|
+
|
|
30
|
+
//@ts-ignore
|
|
31
|
+
const ApiPageBuilder = (0, _pulumi2.createAppModule)({
|
|
32
|
+
name: "ApiPageBuilder",
|
|
33
|
+
|
|
34
|
+
config(app, params) {
|
|
35
|
+
const core = app.getModule(_common.CoreOutput);
|
|
36
|
+
app.addHandler(() => {
|
|
37
|
+
const pbInstallationZipPath = path.join(path.resolve(), ".tmp", "pbInstallation.zip"); // Will create "pbInstallation.zip" and save it in the `pbInstallationZipPath` path.
|
|
38
|
+
|
|
39
|
+
(0, _installation.createInstallationZip)(pbInstallationZipPath);
|
|
40
|
+
new aws.s3.BucketObject("./pbInstallation.zip", {
|
|
41
|
+
key: "pbInstallation.zip",
|
|
42
|
+
bucket: core.fileManagerBucketId,
|
|
43
|
+
contentType: "application/octet-stream",
|
|
44
|
+
source: new pulumi.asset.FileAsset(pbInstallationZipPath)
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
const exportResources = createExportResources(app, params);
|
|
48
|
+
const importResources = createImportResources(app, params);
|
|
49
|
+
return {
|
|
50
|
+
export: exportResources,
|
|
51
|
+
import: importResources
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
exports.ApiPageBuilder = ApiPageBuilder;
|
|
57
|
+
|
|
58
|
+
function createExportResources(app, params) {
|
|
59
|
+
const core = app.getModule(_common.CoreOutput);
|
|
60
|
+
const policy = createExportLambdaPolicy(app);
|
|
61
|
+
const role = (0, _lambdaUtils.createLambdaRole)(app, {
|
|
62
|
+
name: "pb-export-lambda-role",
|
|
63
|
+
policy: policy.output
|
|
64
|
+
});
|
|
65
|
+
const combine = app.addResource(aws.lambda.Function, {
|
|
66
|
+
name: "pb-export-combine",
|
|
67
|
+
config: {
|
|
68
|
+
role: role.output.arn,
|
|
69
|
+
runtime: "nodejs14.x",
|
|
70
|
+
handler: "handler.handler",
|
|
71
|
+
timeout: 60,
|
|
72
|
+
memorySize: 128,
|
|
73
|
+
description: "Handle export's combine workflow",
|
|
74
|
+
code: new pulumi.asset.AssetArchive({
|
|
75
|
+
".": new pulumi.asset.FileArchive(path.join(app.paths.workspace, "pageBuilder/export/combine/build"))
|
|
76
|
+
}),
|
|
77
|
+
environment: {
|
|
78
|
+
variables: (0, _lambdaUtils.getCommonLambdaEnvVariables)().apply(value => (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, value), params.env), {}, {
|
|
79
|
+
S3_BUCKET: core.fileManagerBucketId
|
|
80
|
+
}))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const process = app.addResource(aws.lambda.Function, {
|
|
85
|
+
name: "pb-export-process",
|
|
86
|
+
config: {
|
|
87
|
+
role: role.output.arn,
|
|
88
|
+
runtime: "nodejs14.x",
|
|
89
|
+
handler: "handler.handler",
|
|
90
|
+
timeout: 60,
|
|
91
|
+
memorySize: 128,
|
|
92
|
+
description: "Handle export's process workflow",
|
|
93
|
+
code: new pulumi.asset.AssetArchive({
|
|
94
|
+
".": new pulumi.asset.FileArchive(path.join(app.paths.workspace, "pageBuilder/export/process/build"))
|
|
95
|
+
}),
|
|
96
|
+
environment: {
|
|
97
|
+
variables: (0, _lambdaUtils.getCommonLambdaEnvVariables)().apply(value => (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, value), params.env), {}, {
|
|
98
|
+
S3_BUCKET: core.fileManagerBucketId,
|
|
99
|
+
EXPORT_COMBINE_HANDLER: combine.output.arn
|
|
100
|
+
}))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
role,
|
|
106
|
+
policy,
|
|
107
|
+
functions: {
|
|
108
|
+
process,
|
|
109
|
+
combine
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function createExportLambdaPolicy(app) {
|
|
115
|
+
const core = app.getModule(_common.CoreOutput);
|
|
116
|
+
const awsAccountId = (0, _awsUtils.getAwsAccountId)(app);
|
|
117
|
+
const awsRegion = (0, _awsUtils.getAwsRegion)(app);
|
|
118
|
+
return app.addResource(aws.iam.Policy, {
|
|
119
|
+
name: "PbExportTaskLambdaPolicy",
|
|
120
|
+
config: {
|
|
121
|
+
description: "This policy enables access to Dynamodb",
|
|
122
|
+
policy: {
|
|
123
|
+
Version: "2012-10-17",
|
|
124
|
+
Statement: [{
|
|
125
|
+
Sid: "AllowDynamoDBAccess",
|
|
126
|
+
Effect: "Allow",
|
|
127
|
+
Action: ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"],
|
|
128
|
+
Resource: [pulumi.interpolate`${core.primaryDynamodbTableArn}`, pulumi.interpolate`${core.primaryDynamodbTableArn}/*`]
|
|
129
|
+
}, {
|
|
130
|
+
Sid: "PermissionForS3",
|
|
131
|
+
Effect: "Allow",
|
|
132
|
+
Action: ["s3:GetObjectAcl", "s3:DeleteObject", "s3:PutObjectAcl", "s3:PutObject", "s3:GetObject", "s3:ListBucket"],
|
|
133
|
+
Resource: [pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}/*`, // We need to explicitly add bucket ARN to "Resource" list for "s3:ListBucket" action.
|
|
134
|
+
pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}`]
|
|
135
|
+
}, {
|
|
136
|
+
Sid: "PermissionForLambda",
|
|
137
|
+
Effect: "Allow",
|
|
138
|
+
Action: ["lambda:InvokeFunction"],
|
|
139
|
+
Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`
|
|
140
|
+
}]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function createImportResources(app, params) {
|
|
147
|
+
const core = app.getModule(_common.CoreOutput);
|
|
148
|
+
const policy = createImportLambdaPolicy(app);
|
|
149
|
+
const role = (0, _lambdaUtils.createLambdaRole)(app, {
|
|
150
|
+
name: "pb-import-lambda-role",
|
|
151
|
+
policy: policy.output
|
|
152
|
+
});
|
|
153
|
+
const process = app.addResource(aws.lambda.Function, {
|
|
154
|
+
name: "pb-import-queue-process",
|
|
155
|
+
config: {
|
|
156
|
+
role: role.output.arn,
|
|
157
|
+
runtime: "nodejs14.x",
|
|
158
|
+
handler: "handler.handler",
|
|
159
|
+
timeout: 60,
|
|
160
|
+
memorySize: 512,
|
|
161
|
+
description: "Handle import queue process workflow",
|
|
162
|
+
code: new pulumi.asset.AssetArchive({
|
|
163
|
+
".": new pulumi.asset.FileArchive(path.join(app.paths.workspace, "pageBuilder/import/process/build"))
|
|
164
|
+
}),
|
|
165
|
+
environment: {
|
|
166
|
+
variables: (0, _lambdaUtils.getCommonLambdaEnvVariables)().apply(value => (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, value), params.env), {}, {
|
|
167
|
+
S3_BUCKET: core.fileManagerBucketId
|
|
168
|
+
}))
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const create = app.addResource(aws.lambda.Function, {
|
|
173
|
+
name: "pb-import-queue-create",
|
|
174
|
+
config: {
|
|
175
|
+
role: role.output.arn,
|
|
176
|
+
runtime: "nodejs14.x",
|
|
177
|
+
handler: "handler.handler",
|
|
178
|
+
timeout: 60,
|
|
179
|
+
memorySize: 512,
|
|
180
|
+
description: "Handle import queue create workflow",
|
|
181
|
+
code: new pulumi.asset.AssetArchive({
|
|
182
|
+
".": new pulumi.asset.FileArchive(path.join(app.paths.workspace, "pageBuilder/import/create/build"))
|
|
183
|
+
}),
|
|
184
|
+
environment: {
|
|
185
|
+
variables: (0, _lambdaUtils.getCommonLambdaEnvVariables)().apply(value => (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, value), params.env), {}, {
|
|
186
|
+
S3_BUCKET: core.fileManagerBucketId,
|
|
187
|
+
IMPORT_QUEUE_PROCESS_HANDLER: process.output.arn
|
|
188
|
+
}))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
role,
|
|
194
|
+
policy,
|
|
195
|
+
functions: {
|
|
196
|
+
create,
|
|
197
|
+
process
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function createImportLambdaPolicy(app) {
|
|
203
|
+
const coreOutput = app.getModule(_common.CoreOutput);
|
|
204
|
+
const awsAccountId = (0, _awsUtils.getAwsAccountId)(app);
|
|
205
|
+
const awsRegion = (0, _awsUtils.getAwsRegion)(app);
|
|
206
|
+
return app.addResource(aws.iam.Policy, {
|
|
207
|
+
name: "ImportLambdaPolicy",
|
|
208
|
+
config: {
|
|
209
|
+
description: "This policy enables access Dynamodb, S3, Lambda and Cognito IDP",
|
|
210
|
+
// Core is pulumi.Output, so we need to run apply() to resolve policy based on it
|
|
211
|
+
policy: coreOutput.apply(core => {
|
|
212
|
+
const policy = {
|
|
213
|
+
Version: "2012-10-17",
|
|
214
|
+
Statement: [{
|
|
215
|
+
Sid: "PermissionForDynamodb",
|
|
216
|
+
Effect: "Allow",
|
|
217
|
+
Action: ["dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:PutItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Query", "dynamodb:UpdateItem"],
|
|
218
|
+
Resource: [`${core.primaryDynamodbTableArn}`, `${core.primaryDynamodbTableArn}/*`, // Attach permissions for elastic search dynamo as well (if ES is enabled).
|
|
219
|
+
...(core.elasticsearchDynamodbTableArn ? [`${core.elasticsearchDynamodbTableArn}`, `${core.elasticsearchDynamodbTableArn}/*`] : [])]
|
|
220
|
+
}, {
|
|
221
|
+
Sid: "PermissionForS3",
|
|
222
|
+
Effect: "Allow",
|
|
223
|
+
Action: ["s3:GetObjectAcl", "s3:DeleteObject", "s3:PutObjectAcl", "s3:PutObject", "s3:GetObject", "s3:ListBucket"],
|
|
224
|
+
Resource: [`arn:aws:s3:::${core.fileManagerBucketId}/*`, // We need to explicitly add bucket ARN to "Resource" list for "s3:ListBucket" action.
|
|
225
|
+
`arn:aws:s3:::${core.fileManagerBucketId}`]
|
|
226
|
+
}, {
|
|
227
|
+
Sid: "PermissionForLambda",
|
|
228
|
+
Effect: "Allow",
|
|
229
|
+
Action: ["lambda:InvokeFunction"],
|
|
230
|
+
Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`
|
|
231
|
+
}, {
|
|
232
|
+
Sid: "PermissionForCognitoIdp",
|
|
233
|
+
Effect: "Allow",
|
|
234
|
+
Action: "cognito-idp:*",
|
|
235
|
+
Resource: `${core.cognitoUserPoolArn}`
|
|
236
|
+
}, // Attach permissions for elastic search domain as well (if ES is enabled).
|
|
237
|
+
...(core.elasticsearchDomainArn ? [{
|
|
238
|
+
Sid: "PermissionForES",
|
|
239
|
+
Effect: "Allow",
|
|
240
|
+
Action: "es:*",
|
|
241
|
+
Resource: [`${core.elasticsearchDomainArn}`, `${core.elasticsearchDomainArn}/*`]
|
|
242
|
+
}] : [])]
|
|
243
|
+
};
|
|
244
|
+
return policy;
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ApiPageBuilder","createAppModule","name","config","app","params","core","getModule","CoreOutput","addHandler","pbInstallationZipPath","path","join","resolve","createInstallationZip","aws","s3","BucketObject","key","bucket","fileManagerBucketId","contentType","source","pulumi","asset","FileAsset","exportResources","createExportResources","importResources","createImportResources","export","import","policy","createExportLambdaPolicy","role","createLambdaRole","output","combine","addResource","lambda","Function","arn","runtime","handler","timeout","memorySize","description","code","AssetArchive","FileArchive","paths","workspace","environment","variables","getCommonLambdaEnvVariables","apply","value","env","S3_BUCKET","process","EXPORT_COMBINE_HANDLER","functions","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","iam","Policy","Version","Statement","Sid","Effect","Action","Resource","interpolate","primaryDynamodbTableArn","createImportLambdaPolicy","create","IMPORT_QUEUE_PROCESS_HANDLER","coreOutput","elasticsearchDynamodbTableArn","cognitoUserPoolArn","elasticsearchDomainArn"],"sources":["ApiPageBuilder.ts"],"sourcesContent":["import * as path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\n\n//@ts-ignore\nimport { createInstallationZip } from \"@webiny/api-page-builder/installation\";\nimport { createAppModule, PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { CoreOutput } from \"../common\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils\";\n\ninterface PageBuilderParams {\n env: Record<string, any>;\n}\n\nexport type ApiPageBuilder = PulumiAppModule<typeof ApiPageBuilder>;\n\nexport const ApiPageBuilder = createAppModule({\n name: \"ApiPageBuilder\",\n config(app: PulumiApp, params: PageBuilderParams) {\n const core = app.getModule(CoreOutput);\n\n app.addHandler(() => {\n const pbInstallationZipPath = path.join(path.resolve(), \".tmp\", \"pbInstallation.zip\");\n // Will create \"pbInstallation.zip\" and save it in the `pbInstallationZipPath` path.\n createInstallationZip(pbInstallationZipPath);\n\n new aws.s3.BucketObject(\"./pbInstallation.zip\", {\n key: \"pbInstallation.zip\",\n bucket: core.fileManagerBucketId,\n contentType: \"application/octet-stream\",\n source: new pulumi.asset.FileAsset(pbInstallationZipPath)\n });\n });\n\n const exportResources = createExportResources(app, params);\n const importResources = createImportResources(app, params);\n\n return {\n export: exportResources,\n import: importResources\n };\n }\n});\n\nfunction createExportResources(app: PulumiApp, params: PageBuilderParams) {\n const core = app.getModule(CoreOutput);\n\n const policy = createExportLambdaPolicy(app);\n const role = createLambdaRole(app, {\n name: \"pb-export-lambda-role\",\n policy: policy.output\n });\n\n const combine = app.addResource(aws.lambda.Function, {\n name: \"pb-export-combine\",\n config: {\n role: role.output.arn,\n runtime: \"nodejs14.x\",\n handler: \"handler.handler\",\n timeout: 60,\n memorySize: 128,\n description: \"Handle export's combine workflow\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"pageBuilder/export/combine/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n S3_BUCKET: core.fileManagerBucketId\n }))\n }\n }\n });\n\n const process = app.addResource(aws.lambda.Function, {\n name: \"pb-export-process\",\n config: {\n role: role.output.arn,\n runtime: \"nodejs14.x\",\n handler: \"handler.handler\",\n timeout: 60,\n memorySize: 128,\n description: \"Handle export's process workflow\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"pageBuilder/export/process/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n S3_BUCKET: core.fileManagerBucketId,\n EXPORT_COMBINE_HANDLER: combine.output.arn\n }))\n }\n }\n });\n\n return {\n role,\n policy,\n functions: {\n process,\n combine\n }\n };\n}\n\nfunction createExportLambdaPolicy(app: PulumiApp) {\n const core = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"PbExportTaskLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb\",\n policy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"AllowDynamoDBAccess\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:PutItem\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:GetItem\",\n \"dynamodb:Query\",\n \"dynamodb:UpdateItem\"\n ],\n Resource: [\n pulumi.interpolate`${core.primaryDynamodbTableArn}`,\n pulumi.interpolate`${core.primaryDynamodbTableArn}/*`\n ]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\",\n \"s3:ListBucket\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}/*`,\n // We need to explicitly add bucket ARN to \"Resource\" list for \"s3:ListBucket\" action.\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n }\n ]\n }\n }\n });\n}\n\nfunction createImportResources(app: PulumiApp, params: PageBuilderParams) {\n const core = app.getModule(CoreOutput);\n const policy = createImportLambdaPolicy(app);\n const role = createLambdaRole(app, {\n name: \"pb-import-lambda-role\",\n policy: policy.output\n });\n\n const process = app.addResource(aws.lambda.Function, {\n name: \"pb-import-queue-process\",\n config: {\n role: role.output.arn,\n runtime: \"nodejs14.x\",\n handler: \"handler.handler\",\n timeout: 60,\n memorySize: 512,\n description: \"Handle import queue process workflow\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"pageBuilder/import/process/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n S3_BUCKET: core.fileManagerBucketId\n }))\n }\n }\n });\n\n const create = app.addResource(aws.lambda.Function, {\n name: \"pb-import-queue-create\",\n config: {\n role: role.output.arn,\n runtime: \"nodejs14.x\",\n handler: \"handler.handler\",\n timeout: 60,\n memorySize: 512,\n description: \"Handle import queue create workflow\",\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"pageBuilder/import/create/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n S3_BUCKET: core.fileManagerBucketId,\n IMPORT_QUEUE_PROCESS_HANDLER: process.output.arn\n }))\n }\n }\n });\n\n return {\n role,\n policy,\n functions: {\n create,\n process\n }\n };\n}\n\nfunction createImportLambdaPolicy(app: PulumiApp) {\n const coreOutput = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ImportLambdaPolicy\",\n config: {\n description: \"This policy enables access Dynamodb, S3, Lambda and Cognito IDP\",\n // Core is pulumi.Output, so we need to run apply() to resolve policy based on it\n policy: coreOutput.apply(core => {\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:PutItem\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:GetItem\",\n \"dynamodb:Query\",\n \"dynamodb:UpdateItem\"\n ],\n Resource: [\n `${core.primaryDynamodbTableArn}`,\n `${core.primaryDynamodbTableArn}/*`,\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n ...(core.elasticsearchDynamodbTableArn\n ? [\n `${core.elasticsearchDynamodbTableArn}`,\n `${core.elasticsearchDynamodbTableArn}/*`\n ]\n : [])\n ]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\",\n \"s3:ListBucket\"\n ],\n Resource: [\n `arn:aws:s3:::${core.fileManagerBucketId}/*`,\n // We need to explicitly add bucket ARN to \"Resource\" list for \"s3:ListBucket\" action.\n `arn:aws:s3:::${core.fileManagerBucketId}`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n },\n {\n Sid: \"PermissionForCognitoIdp\",\n Effect: \"Allow\",\n Action: \"cognito-idp:*\",\n Resource: `${core.cognitoUserPoolArn}`\n },\n // Attach permissions for elastic search domain as well (if ES is enabled).\n ...(core.elasticsearchDomainArn\n ? [\n {\n Sid: \"PermissionForES\",\n Effect: \"Allow\" as const,\n Action: \"es:*\",\n Resource: [\n `${core.elasticsearchDomainArn}`,\n `${core.elasticsearchDomainArn}/*`\n ]\n }\n ]\n : [])\n ]\n };\n\n return policy;\n })\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AALA;AAaO,MAAMA,cAAc,GAAG,IAAAC,wBAAA,EAAgB;EAC1CC,IAAI,EAAE,gBADoC;;EAE1CC,MAAM,CAACC,GAAD,EAAiBC,MAAjB,EAA4C;IAC9C,MAAMC,IAAI,GAAGF,GAAG,CAACG,SAAJ,CAAcC,kBAAd,CAAb;IAEAJ,GAAG,CAACK,UAAJ,CAAe,MAAM;MACjB,MAAMC,qBAAqB,GAAGC,IAAI,CAACC,IAAL,CAAUD,IAAI,CAACE,OAAL,EAAV,EAA0B,MAA1B,EAAkC,oBAAlC,CAA9B,CADiB,CAEjB;;MACA,IAAAC,mCAAA,EAAsBJ,qBAAtB;MAEA,IAAIK,GAAG,CAACC,EAAJ,CAAOC,YAAX,CAAwB,sBAAxB,EAAgD;QAC5C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EAAG,GAAEnE,IAAI,CAAC2E,kBAAmB;UAJzC,CAhDO,EAsDP;UACA,IAAI3E,IAAI,CAAC4E,sBAAL,GACE,CACI;YACIZ,GAAG,EAAE,iBADT;YAEIC,MAAM,EAAE,OAFZ;YAGIC,MAAM,EAAE,MAHZ;YAIIC,QAAQ,EAAE,CACL,GAAEnE,IAAI,CAAC4E,sBAAuB,EADzB,EAEL,GAAE5E,IAAI,CAAC4E,sBAAuB,IAFzB;UAJd,CADJ,CADF,GAYE,EAZN,CAvDO;QAFwB,CAAvC;QAyEA,OAAOlD,MAAP;MACH,CA3EO;IAHJ;EAF2B,CAAhC,CAAP;AAmFH"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { PulumiAppParam, PulumiAppParamCallback } from "@webiny/pulumi";
|
|
2
|
+
import { CustomDomainParams } from "../customDomain";
|
|
3
|
+
export declare type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;
|
|
4
|
+
export interface CreateApiPulumiAppParams {
|
|
5
|
+
/**
|
|
6
|
+
* Enables or disables VPC for the API.
|
|
7
|
+
* For VPC to work you also have to enable it in the Core application.
|
|
8
|
+
*/
|
|
9
|
+
vpc?: PulumiAppParam<boolean>;
|
|
10
|
+
/** Custom domain configuration */
|
|
11
|
+
domains?: PulumiAppParamCallback<CustomDomainParams>;
|
|
12
|
+
/**
|
|
13
|
+
* Provides a way to adjust existing Pulumi code (cloud infrastructure resources)
|
|
14
|
+
* or add additional ones into the mix.
|
|
15
|
+
*/
|
|
16
|
+
pulumi?: (app: ApiPulumiApp) => void | Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Prefixes names of all Pulumi cloud infrastructure resource with given prefix.
|
|
19
|
+
*/
|
|
20
|
+
pulumiResourceNamePrefix?: PulumiAppParam<string>;
|
|
21
|
+
}
|
|
22
|
+
export declare const createApiPulumiApp: (projectAppParams?: CreateApiPulumiAppParams) => import("@webiny/pulumi").PulumiApp<{
|
|
23
|
+
fileManager: {
|
|
24
|
+
functions: {
|
|
25
|
+
transform: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
26
|
+
manage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
27
|
+
download: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
28
|
+
};
|
|
29
|
+
bucketNotification: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/s3/bucketNotification").BucketNotification>;
|
|
30
|
+
};
|
|
31
|
+
graphql: {
|
|
32
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
33
|
+
policy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
|
|
34
|
+
functions: {
|
|
35
|
+
graphql: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
36
|
+
};
|
|
37
|
+
addRoute: (routeParams: import("~/apps").AddRouteParams) => any;
|
|
38
|
+
};
|
|
39
|
+
headlessCms: {
|
|
40
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
41
|
+
policy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
|
|
42
|
+
functions: {
|
|
43
|
+
graphql: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
apiGateway: {
|
|
47
|
+
api: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api").Api>;
|
|
48
|
+
stage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage").Stage>;
|
|
49
|
+
routes: Record<string, {
|
|
50
|
+
integration: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/integration").Integration>;
|
|
51
|
+
route: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/route").Route>;
|
|
52
|
+
permission: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/permission").Permission>;
|
|
53
|
+
}>;
|
|
54
|
+
addRoute: (name: string, params: import("~/apps").ApiRouteParams) => void;
|
|
55
|
+
};
|
|
56
|
+
cloudfront: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudfront/distribution").Distribution>;
|
|
57
|
+
apwScheduler: {
|
|
58
|
+
executeAction: {
|
|
59
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
60
|
+
policy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
|
|
61
|
+
lambda: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
62
|
+
};
|
|
63
|
+
scheduleAction: {
|
|
64
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
65
|
+
policy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy").Policy>;
|
|
66
|
+
lambda: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
67
|
+
};
|
|
68
|
+
eventRule: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventRule").EventRule>;
|
|
69
|
+
eventTarget: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
|
|
70
|
+
};
|
|
71
|
+
}> & import("../lambdaUtils").WithCommonLambdaEnvVariables;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createApiPulumiApp = void 0;
|
|
7
|
+
|
|
8
|
+
var _pulumi = require("@webiny/pulumi");
|
|
9
|
+
|
|
10
|
+
var _ = require("./..");
|
|
11
|
+
|
|
12
|
+
var _customDomain = require("../customDomain");
|
|
13
|
+
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
|
|
16
|
+
const createApiPulumiApp = (projectAppParams = {}) => {
|
|
17
|
+
const app = (0, _pulumi.createPulumiApp)({
|
|
18
|
+
name: "api",
|
|
19
|
+
path: "apps/api",
|
|
20
|
+
config: projectAppParams,
|
|
21
|
+
program: async app => {
|
|
22
|
+
const pulumiResourceNamePrefix = app.getParam(projectAppParams.pulumiResourceNamePrefix);
|
|
23
|
+
|
|
24
|
+
if (pulumiResourceNamePrefix) {
|
|
25
|
+
app.onResource(resource => {
|
|
26
|
+
if (!resource.name.startsWith(pulumiResourceNamePrefix)) {
|
|
27
|
+
resource.name = `${pulumiResourceNamePrefix}${resource.name}`;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} // Overrides must be applied via a handler, registered at the very start of the program.
|
|
31
|
+
// By doing this, we're ensuring user's adjustments are not applied too late.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if (projectAppParams.pulumi) {
|
|
35
|
+
app.addHandler(() => {
|
|
36
|
+
return projectAppParams.pulumi(app);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const prod = app.params.run.env === "prod"; // Enables logs forwarding.
|
|
41
|
+
// https://www.webiny.com/docs/how-to-guides/use-watch-command#enabling-logs-forwarding
|
|
42
|
+
|
|
43
|
+
const WEBINY_LOGS_FORWARD_URL = String(process.env.WEBINY_LOGS_FORWARD_URL); // Register core output as a module available to all the other modules
|
|
44
|
+
|
|
45
|
+
const core = app.addModule(_.CoreOutput); // Register VPC config module to be available to other modules.
|
|
46
|
+
|
|
47
|
+
const vpcEnabled = app.getParam(projectAppParams === null || projectAppParams === void 0 ? void 0 : projectAppParams.vpc) ?? prod;
|
|
48
|
+
app.addModule(_.VpcConfig, {
|
|
49
|
+
enabled: vpcEnabled
|
|
50
|
+
});
|
|
51
|
+
const pageBuilder = app.addModule(_.ApiPageBuilder, {
|
|
52
|
+
env: {
|
|
53
|
+
COGNITO_REGION: String(process.env.AWS_REGION),
|
|
54
|
+
COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
|
|
55
|
+
DB_TABLE: core.primaryDynamodbTableName,
|
|
56
|
+
DB_TABLE_ELASTICSEARCH: core.elasticsearchDynamodbTableName,
|
|
57
|
+
ELASTIC_SEARCH_ENDPOINT: core.elasticsearchDomainEndpoint,
|
|
58
|
+
// Not required. Useful for testing purposes / ephemeral environments.
|
|
59
|
+
// https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments
|
|
60
|
+
ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,
|
|
61
|
+
S3_BUCKET: core.fileManagerBucketId,
|
|
62
|
+
WEBINY_LOGS_FORWARD_URL
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const fileManager = app.addModule(_.ApiFileManager);
|
|
66
|
+
const apwScheduler = app.addModule(_.ApiApwScheduler, {
|
|
67
|
+
primaryDynamodbTableArn: core.primaryDynamodbTableArn,
|
|
68
|
+
env: {
|
|
69
|
+
COGNITO_REGION: String(process.env.AWS_REGION),
|
|
70
|
+
COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
|
|
71
|
+
DB_TABLE: core.primaryDynamodbTableName,
|
|
72
|
+
S3_BUCKET: core.fileManagerBucketId,
|
|
73
|
+
WEBINY_LOGS_FORWARD_URL
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const headlessCms = app.addModule(_.ApiHeadlessCMS, {
|
|
77
|
+
env: {
|
|
78
|
+
COGNITO_REGION: String(process.env.AWS_REGION),
|
|
79
|
+
COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
|
|
80
|
+
DB_TABLE: core.primaryDynamodbTableName,
|
|
81
|
+
DB_TABLE_ELASTICSEARCH: core.elasticsearchDynamodbTableName,
|
|
82
|
+
ELASTIC_SEARCH_ENDPOINT: core.elasticsearchDomainEndpoint,
|
|
83
|
+
// Not required. Useful for testing purposes / ephemeral environments.
|
|
84
|
+
// https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments
|
|
85
|
+
ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,
|
|
86
|
+
S3_BUCKET: core.fileManagerBucketId,
|
|
87
|
+
// TODO: move to okta plugin
|
|
88
|
+
OKTA_ISSUER: process.env["OKTA_ISSUER"],
|
|
89
|
+
WEBINY_LOGS_FORWARD_URL,
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* APW
|
|
93
|
+
*/
|
|
94
|
+
APW_SCHEDULER_SCHEDULE_ACTION_HANDLER: apwScheduler.scheduleAction.lambda.output.arn
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const graphql = app.addModule(_.ApiGraphql, {
|
|
98
|
+
env: {
|
|
99
|
+
COGNITO_REGION: String(process.env.AWS_REGION),
|
|
100
|
+
COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
|
|
101
|
+
DB_TABLE: core.primaryDynamodbTableName,
|
|
102
|
+
DB_TABLE_ELASTICSEARCH: core.elasticsearchDynamodbTableName,
|
|
103
|
+
ELASTIC_SEARCH_ENDPOINT: core.elasticsearchDomainEndpoint,
|
|
104
|
+
// Not required. Useful for testing purposes / ephemeral environments.
|
|
105
|
+
// https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments
|
|
106
|
+
ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,
|
|
107
|
+
S3_BUCKET: core.fileManagerBucketId,
|
|
108
|
+
EVENT_BUS: core.eventBusArn,
|
|
109
|
+
IMPORT_CREATE_HANDLER: pageBuilder.import.functions.create.output.arn,
|
|
110
|
+
EXPORT_PROCESS_HANDLER: pageBuilder.export.functions.process.output.arn,
|
|
111
|
+
// TODO: move to okta plugin
|
|
112
|
+
OKTA_ISSUER: process.env["OKTA_ISSUER"],
|
|
113
|
+
WEBINY_LOGS_FORWARD_URL,
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* APW
|
|
117
|
+
*/
|
|
118
|
+
APW_SCHEDULER_SCHEDULE_ACTION_HANDLER: apwScheduler.scheduleAction.lambda.output.arn
|
|
119
|
+
},
|
|
120
|
+
apwSchedulerEventRule: apwScheduler.eventRule.output,
|
|
121
|
+
apwSchedulerEventTarget: apwScheduler.eventTarget.output
|
|
122
|
+
});
|
|
123
|
+
const apiGateway = app.addModule(_.ApiGateway, {
|
|
124
|
+
"graphql-post": {
|
|
125
|
+
path: "/graphql",
|
|
126
|
+
method: "POST",
|
|
127
|
+
function: graphql.functions.graphql.output.arn
|
|
128
|
+
},
|
|
129
|
+
"graphql-options": {
|
|
130
|
+
path: "/graphql",
|
|
131
|
+
method: "OPTIONS",
|
|
132
|
+
function: graphql.functions.graphql.output.arn
|
|
133
|
+
},
|
|
134
|
+
"files-any": {
|
|
135
|
+
path: "/files/{path}",
|
|
136
|
+
method: "ANY",
|
|
137
|
+
function: fileManager.functions.download.output.arn
|
|
138
|
+
},
|
|
139
|
+
"cms-post": {
|
|
140
|
+
path: "/cms/{key+}",
|
|
141
|
+
method: "POST",
|
|
142
|
+
function: headlessCms.functions.graphql.output.arn
|
|
143
|
+
},
|
|
144
|
+
"cms-options": {
|
|
145
|
+
path: "/cms/{key+}",
|
|
146
|
+
method: "OPTIONS",
|
|
147
|
+
function: headlessCms.functions.graphql.output.arn
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const cloudfront = app.addModule(_.ApiCloudfront);
|
|
151
|
+
const domains = app.getParam(projectAppParams.domains);
|
|
152
|
+
|
|
153
|
+
if (domains) {
|
|
154
|
+
(0, _customDomain.applyCustomDomain)(cloudfront, domains);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
app.addOutputs({
|
|
158
|
+
region: process.env.AWS_REGION,
|
|
159
|
+
apiUrl: cloudfront.output.domainName.apply(value => `https://${value}`),
|
|
160
|
+
apiDomain: cloudfront.output.domainName,
|
|
161
|
+
cognitoUserPoolId: core.cognitoUserPoolId,
|
|
162
|
+
cognitoAppClientId: core.cognitoAppClientId,
|
|
163
|
+
cognitoUserPoolPasswordPolicy: core.cognitoUserPoolPasswordPolicy,
|
|
164
|
+
apwSchedulerScheduleAction: apwScheduler.scheduleAction.lambda.output.arn,
|
|
165
|
+
apwSchedulerExecuteAction: apwScheduler.executeAction.lambda.output.arn,
|
|
166
|
+
apwSchedulerEventRule: apwScheduler.eventRule.output.name,
|
|
167
|
+
apwSchedulerEventTargetId: apwScheduler.eventTarget.output.targetId,
|
|
168
|
+
dynamoDbTable: core.primaryDynamodbTableName,
|
|
169
|
+
dynamoDbElasticsearchTable: core.elasticsearchDynamodbTableName
|
|
170
|
+
});
|
|
171
|
+
(0, _utils.tagResources)({
|
|
172
|
+
WbyProjectName: String(process.env["WEBINY_PROJECT_NAME"]),
|
|
173
|
+
WbyEnvironment: String(process.env["WEBINY_ENV"])
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
fileManager,
|
|
177
|
+
graphql,
|
|
178
|
+
headlessCms,
|
|
179
|
+
apiGateway,
|
|
180
|
+
cloudfront,
|
|
181
|
+
apwScheduler
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return (0, _utils.withCommonLambdaEnvVariables)(app);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
exports.createApiPulumiApp = createApiPulumiApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createApiPulumiApp","projectAppParams","app","createPulumiApp","name","path","config","program","pulumiResourceNamePrefix","getParam","onResource","resource","startsWith","pulumi","addHandler","prod","params","run","env","WEBINY_LOGS_FORWARD_URL","String","process","core","addModule","CoreOutput","vpcEnabled","vpc","VpcConfig","enabled","pageBuilder","ApiPageBuilder","COGNITO_REGION","AWS_REGION","COGNITO_USER_POOL_ID","cognitoUserPoolId","DB_TABLE","primaryDynamodbTableName","DB_TABLE_ELASTICSEARCH","elasticsearchDynamodbTableName","ELASTIC_SEARCH_ENDPOINT","elasticsearchDomainEndpoint","ELASTIC_SEARCH_INDEX_PREFIX","S3_BUCKET","fileManagerBucketId","fileManager","ApiFileManager","apwScheduler","ApiApwScheduler","primaryDynamodbTableArn","headlessCms","ApiHeadlessCMS","OKTA_ISSUER","APW_SCHEDULER_SCHEDULE_ACTION_HANDLER","scheduleAction","lambda","output","arn","graphql","ApiGraphql","EVENT_BUS","eventBusArn","IMPORT_CREATE_HANDLER","import","functions","create","EXPORT_PROCESS_HANDLER","export","apwSchedulerEventRule","eventRule","apwSchedulerEventTarget","eventTarget","apiGateway","ApiGateway","method","function","download","cloudfront","ApiCloudfront","domains","applyCustomDomain","addOutputs","region","apiUrl","domainName","apply","value","apiDomain","cognitoAppClientId","cognitoUserPoolPasswordPolicy","apwSchedulerScheduleAction","apwSchedulerExecuteAction","executeAction","apwSchedulerEventTargetId","targetId","dynamoDbTable","dynamoDbElasticsearchTable","tagResources","WbyProjectName","WbyEnvironment","withCommonLambdaEnvVariables"],"sources":["createApiPulumiApp.ts"],"sourcesContent":["import { createPulumiApp, PulumiAppParam, PulumiAppParamCallback } from \"@webiny/pulumi\";\nimport {\n ApiGateway,\n ApiApwScheduler,\n ApiCloudfront,\n ApiFileManager,\n ApiGraphql,\n ApiHeadlessCMS,\n ApiPageBuilder,\n CoreOutput,\n VpcConfig\n} from \"~/apps\";\nimport { applyCustomDomain, CustomDomainParams } from \"../customDomain\";\nimport { tagResources } from \"~/utils\";\nimport { withCommonLambdaEnvVariables } from \"~/utils\";\n\nexport type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;\n\nexport interface CreateApiPulumiAppParams {\n /**\n * Enables or disables VPC for the API.\n * For VPC to work you also have to enable it in the Core application.\n */\n vpc?: PulumiAppParam<boolean>;\n\n /** Custom domain configuration */\n domains?: PulumiAppParamCallback<CustomDomainParams>;\n\n /**\n * Provides a way to adjust existing Pulumi code (cloud infrastructure resources)\n * or add additional ones into the mix.\n */\n pulumi?: (app: ApiPulumiApp) => void | Promise<void>;\n\n /**\n * Prefixes names of all Pulumi cloud infrastructure resource with given prefix.\n */\n pulumiResourceNamePrefix?: PulumiAppParam<string>;\n}\n\nexport const createApiPulumiApp = (projectAppParams: CreateApiPulumiAppParams = {}) => {\n const app = createPulumiApp({\n name: \"api\",\n path: \"apps/api\",\n config: projectAppParams,\n program: async app => {\n const pulumiResourceNamePrefix = app.getParam(\n projectAppParams.pulumiResourceNamePrefix\n );\n if (pulumiResourceNamePrefix) {\n app.onResource(resource => {\n if (!resource.name.startsWith(pulumiResourceNamePrefix)) {\n resource.name = `${pulumiResourceNamePrefix}${resource.name}`;\n }\n });\n }\n\n // Overrides must be applied via a handler, registered at the very start of the program.\n // By doing this, we're ensuring user's adjustments are not applied too late.\n if (projectAppParams.pulumi) {\n app.addHandler(() => {\n return projectAppParams.pulumi!(app as ApiPulumiApp);\n });\n }\n\n const prod = app.params.run.env === \"prod\";\n\n // Enables logs forwarding.\n // https://www.webiny.com/docs/how-to-guides/use-watch-command#enabling-logs-forwarding\n const WEBINY_LOGS_FORWARD_URL = String(process.env.WEBINY_LOGS_FORWARD_URL);\n\n // Register core output as a module available to all the other modules\n const core = app.addModule(CoreOutput);\n\n // Register VPC config module to be available to other modules.\n const vpcEnabled = app.getParam(projectAppParams?.vpc) ?? prod;\n app.addModule(VpcConfig, { enabled: vpcEnabled });\n\n const pageBuilder = app.addModule(ApiPageBuilder, {\n env: {\n COGNITO_REGION: String(process.env.AWS_REGION),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_ELASTICSEARCH: core.elasticsearchDynamodbTableName,\n ELASTIC_SEARCH_ENDPOINT: core.elasticsearchDomainEndpoint,\n\n // Not required. Useful for testing purposes / ephemeral environments.\n // https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments\n ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,\n\n S3_BUCKET: core.fileManagerBucketId,\n WEBINY_LOGS_FORWARD_URL\n }\n });\n\n const fileManager = app.addModule(ApiFileManager);\n\n const apwScheduler = app.addModule(ApiApwScheduler, {\n primaryDynamodbTableArn: core.primaryDynamodbTableArn,\n\n env: {\n COGNITO_REGION: String(process.env.AWS_REGION),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n DB_TABLE: core.primaryDynamodbTableName,\n S3_BUCKET: core.fileManagerBucketId,\n WEBINY_LOGS_FORWARD_URL\n }\n });\n\n const headlessCms = app.addModule(ApiHeadlessCMS, {\n env: {\n COGNITO_REGION: String(process.env.AWS_REGION),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_ELASTICSEARCH: core.elasticsearchDynamodbTableName,\n ELASTIC_SEARCH_ENDPOINT: core.elasticsearchDomainEndpoint,\n\n // Not required. Useful for testing purposes / ephemeral environments.\n // https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments\n ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,\n\n S3_BUCKET: core.fileManagerBucketId,\n // TODO: move to okta plugin\n OKTA_ISSUER: process.env[\"OKTA_ISSUER\"],\n WEBINY_LOGS_FORWARD_URL,\n /**\n * APW\n */\n APW_SCHEDULER_SCHEDULE_ACTION_HANDLER:\n apwScheduler.scheduleAction.lambda.output.arn\n }\n });\n\n const graphql = app.addModule(ApiGraphql, {\n env: {\n COGNITO_REGION: String(process.env.AWS_REGION),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_ELASTICSEARCH: core.elasticsearchDynamodbTableName,\n ELASTIC_SEARCH_ENDPOINT: core.elasticsearchDomainEndpoint,\n\n // Not required. Useful for testing purposes / ephemeral environments.\n // https://www.webiny.com/docs/key-topics/ci-cd/testing/slow-ephemeral-environments\n ELASTIC_SEARCH_INDEX_PREFIX: process.env.ELASTIC_SEARCH_INDEX_PREFIX,\n\n S3_BUCKET: core.fileManagerBucketId,\n EVENT_BUS: core.eventBusArn,\n IMPORT_CREATE_HANDLER: pageBuilder.import.functions.create.output.arn,\n EXPORT_PROCESS_HANDLER: pageBuilder.export.functions.process.output.arn,\n // TODO: move to okta plugin\n OKTA_ISSUER: process.env[\"OKTA_ISSUER\"],\n WEBINY_LOGS_FORWARD_URL,\n /**\n * APW\n */\n APW_SCHEDULER_SCHEDULE_ACTION_HANDLER:\n apwScheduler.scheduleAction.lambda.output.arn\n },\n apwSchedulerEventRule: apwScheduler.eventRule.output,\n apwSchedulerEventTarget: apwScheduler.eventTarget.output\n });\n\n const apiGateway = app.addModule(ApiGateway, {\n \"graphql-post\": {\n path: \"/graphql\",\n method: \"POST\",\n function: graphql.functions.graphql.output.arn\n },\n \"graphql-options\": {\n path: \"/graphql\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"files-any\": {\n path: \"/files/{path}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n },\n \"cms-post\": {\n path: \"/cms/{key+}\",\n method: \"POST\",\n function: headlessCms.functions.graphql.output.arn\n },\n \"cms-options\": {\n path: \"/cms/{key+}\",\n method: \"OPTIONS\",\n function: headlessCms.functions.graphql.output.arn\n }\n });\n\n const cloudfront = app.addModule(ApiCloudfront);\n\n const domains = app.getParam(projectAppParams.domains);\n if (domains) {\n applyCustomDomain(cloudfront, domains);\n }\n\n app.addOutputs({\n region: process.env.AWS_REGION,\n apiUrl: cloudfront.output.domainName.apply(value => `https://${value}`),\n apiDomain: cloudfront.output.domainName,\n cognitoUserPoolId: core.cognitoUserPoolId,\n cognitoAppClientId: core.cognitoAppClientId,\n cognitoUserPoolPasswordPolicy: core.cognitoUserPoolPasswordPolicy,\n apwSchedulerScheduleAction: apwScheduler.scheduleAction.lambda.output.arn,\n apwSchedulerExecuteAction: apwScheduler.executeAction.lambda.output.arn,\n apwSchedulerEventRule: apwScheduler.eventRule.output.name,\n apwSchedulerEventTargetId: apwScheduler.eventTarget.output.targetId,\n dynamoDbTable: core.primaryDynamodbTableName,\n dynamoDbElasticsearchTable: core.elasticsearchDynamodbTableName\n });\n\n tagResources({\n WbyProjectName: String(process.env[\"WEBINY_PROJECT_NAME\"]),\n WbyEnvironment: String(process.env[\"WEBINY_ENV\"])\n });\n\n return {\n fileManager,\n graphql,\n headlessCms,\n apiGateway,\n cloudfront,\n apwScheduler\n };\n }\n });\n\n return withCommonLambdaEnvVariables(app);\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAWA;;AACA;;AA2BO,MAAMA,kBAAkB,GAAG,CAACC,gBAA0C,GAAG,EAA9C,KAAqD;EACnF,MAAMC,GAAG,GAAG,IAAAC,uBAAA,EAAgB;IACxBC,IAAI,EAAE,KADkB;IAExBC,IAAI,EAAE,UAFkB;IAGxBC,MAAM,EAAEL,gBAHgB;IAIxBM,OAAO,EAAE,MAAML,GAAN,IAAa;MAClB,MAAMM,wBAAwB,GAAGN,GAAG,CAACO,QAAJ,CAC7BR,gBAAgB,CAACO,wBADY,CAAjC;;MAGA,IAAIA,wBAAJ,EAA8B;QAC1BN,GAAG,CAACQ,UAAJ,CAAeC,QAAQ,IAAI;UACvB,IAAI,CAACA,QAAQ,CAACP,IAAT,CAAcQ,UAAd,CAAyBJ,wBAAzB,CAAL,EAAyD;YACrDG,QAAQ,CAACP,IAAT,GAAiB,GAAEI,wBAAyB,GAAEG,QAAQ,CAACP,IAAK,EAA5D;UACH;QACJ,CAJD;MAKH,CAViB,CAYlB;MACA;;;MACA,IAAIH,gBAAgB,CAACY,MAArB,EAA6B;QACzBX,GAAG,CAACY,UAAJ,CAAe,MAAM;UACjB,OAAOb,gBAAgB,CAACY,MAAjB,C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AAyB,EAAE9C,YAAY,CAACwB,WAAb,CAAyBf,MAAzB,CAAgCsC,QAVhD;QAWXC,aAAa,EAAExE,IAAI,CAACc,wBAXT;QAYX2D,0BAA0B,EAAEzE,IAAI,CAACgB;MAZtB,CAAf;MAeA,IAAA0D,mBAAA,EAAa;QACTC,cAAc,EAAE7E,MAAM,CAACC,OAAO,CAACH,GAAR,CAAY,qBAAZ,CAAD,CADb;QAETgF,cAAc,EAAE9E,MAAM,CAACC,OAAO,CAACH,GAAR,CAAY,YAAZ,CAAD;MAFb,CAAb;MAKA,OAAO;QACH0B,WADG;QAEHa,OAFG;QAGHR,WAHG;QAIHsB,UAJG;QAKHK,UALG;QAMH9B;MANG,CAAP;IAQH;EAxLuB,CAAhB,CAAZ;EA2LA,OAAO,IAAAqD,mCAAA,EAA6BjG,GAA7B,CAAP;AACH,CA7LM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./ApiApwScheduler";
|
|
2
|
+
export * from "./ApiCloudfront";
|
|
3
|
+
export * from "./ApiFileManager";
|
|
4
|
+
export * from "./ApiGateway";
|
|
5
|
+
export * from "./ApiGraphql";
|
|
6
|
+
export * from "./ApiHeadlessCMS";
|
|
7
|
+
export * from "./ApiPageBuilder";
|
|
8
|
+
export * from "./createApiPulumiApp";
|
|
9
|
+
export * from "./ApiOutput";
|