@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 @@
|
|
|
1
|
+
{"version":3,"names":["createLambdaRole","app","params","role","addResource","aws","iam","Role","name","config","assumeRolePolicy","Version","Statement","Action","Principal","Service","Effect","meta","isLambdaFunctionRole","policy","RolePolicyAttachment","output","policyArn","arn","executionRole","vpc","getModule","VpcConfig","enabled","apply","ManagedPolicy","AWSLambdaVPCAccessExecutionRole","AWSLambdaBasicExecutionRole"],"sources":["lambdaUtils.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { PulumiApp } from \"@webiny/pulumi\";\n\nexport * from \"../utils/lambdaEnvVariables\";\n\nimport { VpcConfig } from \"./common\";\n\ninterface LambdaRoleParams {\n name: string;\n policy?: pulumi.Output<aws.iam.Policy>;\n executionRole?: pulumi.Input<string>;\n}\n\nexport function createLambdaRole(app: PulumiApp, params: LambdaRoleParams) {\n const role = app.addResource(aws.iam.Role, {\n name: params.name,\n config: {\n assumeRolePolicy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: \"sts:AssumeRole\",\n Principal: {\n Service: \"lambda.amazonaws.com\"\n },\n Effect: \"Allow\"\n }\n ]\n }\n },\n meta: { isLambdaFunctionRole: true }\n });\n\n if (params.policy) {\n app.addResource(aws.iam.RolePolicyAttachment, {\n name: `${params.name}-policy`,\n config: {\n role: role.output,\n policyArn: params.policy.arn\n }\n });\n }\n\n if (params.executionRole) {\n // If execution role is set, use it.\n app.addResource(aws.iam.RolePolicyAttachment, {\n name: `${params.name}-execution-role`,\n config: {\n role: role.output,\n policyArn: params.executionRole\n }\n });\n }\n\n // Add default execution role.\n const vpc = app.getModule(VpcConfig);\n\n app.addResource(aws.iam.RolePolicyAttachment, {\n name: `${params.name}-default-execution-role`,\n config: {\n role: role.output,\n policyArn: vpc.enabled.apply(enabled =>\n enabled\n ? aws.iam.ManagedPolicy.AWSLambdaVPCAccessExecutionRole\n : aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole\n )\n }\n });\n\n return role;\n}\n"],"mappings":";;;;;;;;;;;;AACA;;AAGA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAQO,SAASA,gBAAT,CAA0BC,GAA1B,EAA0CC,MAA1C,EAAoE;EACvE,MAAMC,IAAI,GAAGF,GAAG,CAACG,WAAJ,CAAgBC,GAAG,CAACC,GAAJ,CAAQC,IAAxB,EAA8B;IACvCC,IAAI,EAAEN,MAAM,CAACM,IAD0B;IAEvCC,MAAM,EAAE;MACJC,gBAAgB,EAAE;QACdC,OAAO,EAAE,YADK;QAEdC,SAAS,EAAE,CACP;UACIC,MAAM,EAAE,gBADZ;UAEIC,SAAS,EAAE;YACPC,OAAO,EAAE;UADF,CAFf;UAK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P;AACH"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as aws from "@pulumi/aws";
|
|
2
|
+
import { PulumiAppParam, PulumiAppParamCallback } from "@webiny/pulumi";
|
|
3
|
+
import { CustomDomainParams } from "../customDomain";
|
|
4
|
+
export declare type ReactPulumiApp = ReturnType<typeof createReactPulumiApp>;
|
|
5
|
+
export interface CreateReactPulumiAppParams {
|
|
6
|
+
/**
|
|
7
|
+
* A name of the app, e.g., "user-area"
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* A folder where the app is located, e.g., "apps/user-area"
|
|
12
|
+
*/
|
|
13
|
+
folder: string;
|
|
14
|
+
/** Custom domain configuration */
|
|
15
|
+
domains?: PulumiAppParamCallback<CustomDomainParams>;
|
|
16
|
+
/**
|
|
17
|
+
* Provides a way to adjust existing Pulumi code (cloud infrastructure resources)
|
|
18
|
+
* or add additional ones into the mix.
|
|
19
|
+
*/
|
|
20
|
+
pulumi?: (app: ReactPulumiApp) => void | Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Prefixes names of all Pulumi cloud infrastructure resource with given prefix.
|
|
23
|
+
*/
|
|
24
|
+
pulumiResourceNamePrefix?: PulumiAppParam<string>;
|
|
25
|
+
}
|
|
26
|
+
export declare const createReactPulumiApp: (projectAppParams: CreateReactPulumiAppParams) => import("@webiny/pulumi").PulumiApp<{
|
|
27
|
+
cloudfront: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudfront/distribution").Distribution>;
|
|
28
|
+
bucket: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/s3/bucket").Bucket>;
|
|
29
|
+
originIdentity: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudfront/originAccessIdentity").OriginAccessIdentity>;
|
|
30
|
+
origin: aws.types.input.cloudfront.DistributionOrigin;
|
|
31
|
+
bucketPublicAccessBlock: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/s3/bucketPublicAccessBlock").BucketPublicAccessBlock>;
|
|
32
|
+
bucketPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/s3/bucketPolicy").BucketPolicy>;
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,144 @@
|
|
|
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.createReactPulumiApp = void 0;
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var aws = _interopRequireWildcard(require("@pulumi/aws"));
|
|
15
|
+
|
|
16
|
+
var _pulumi = require("@webiny/pulumi");
|
|
17
|
+
|
|
18
|
+
var _utils = require("../../utils");
|
|
19
|
+
|
|
20
|
+
var _createAppBucket = require("../createAppBucket");
|
|
21
|
+
|
|
22
|
+
var _customDomain = require("../customDomain");
|
|
23
|
+
|
|
24
|
+
var pulumi = _interopRequireWildcard(require("@pulumi/pulumi"));
|
|
25
|
+
|
|
26
|
+
var _CoreOutput = require("../common/CoreOutput");
|
|
27
|
+
|
|
28
|
+
const createReactPulumiApp = projectAppParams => {
|
|
29
|
+
return (0, _pulumi.createPulumiApp)({
|
|
30
|
+
name: projectAppParams.name,
|
|
31
|
+
path: projectAppParams.folder,
|
|
32
|
+
config: projectAppParams,
|
|
33
|
+
program: async app => {
|
|
34
|
+
const pulumiResourceNamePrefix = app.getParam(projectAppParams.pulumiResourceNamePrefix);
|
|
35
|
+
|
|
36
|
+
if (pulumiResourceNamePrefix) {
|
|
37
|
+
app.onResource(resource => {
|
|
38
|
+
if (!resource.name.startsWith(pulumiResourceNamePrefix)) {
|
|
39
|
+
resource.name = `${pulumiResourceNamePrefix}${resource.name}`;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const {
|
|
45
|
+
name
|
|
46
|
+
} = projectAppParams; // Register core output as a module available for all other modules
|
|
47
|
+
|
|
48
|
+
const core = app.addModule(_CoreOutput.CoreOutput); // Overrides must be applied via a handler, registered at the very start of the program.
|
|
49
|
+
// By doing this, we're ensuring user's adjustments are not applied to late.
|
|
50
|
+
|
|
51
|
+
if (projectAppParams.pulumi) {
|
|
52
|
+
app.addHandler(() => {
|
|
53
|
+
return projectAppParams.pulumi(app);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const bucket = (0, _createAppBucket.createPrivateAppBucket)(app, `${name}-app`);
|
|
58
|
+
const cloudfront = app.addResource(aws.cloudfront.Distribution, {
|
|
59
|
+
name: `${name}-app-cdn`,
|
|
60
|
+
config: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
waitForDeployment: false,
|
|
63
|
+
origins: [bucket.origin],
|
|
64
|
+
defaultRootObject: "index.html",
|
|
65
|
+
defaultCacheBehavior: {
|
|
66
|
+
compress: true,
|
|
67
|
+
targetOriginId: bucket.origin.originId,
|
|
68
|
+
viewerProtocolPolicy: "redirect-to-https",
|
|
69
|
+
allowedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
70
|
+
cachedMethods: ["GET", "HEAD", "OPTIONS"],
|
|
71
|
+
forwardedValues: {
|
|
72
|
+
cookies: {
|
|
73
|
+
forward: "none"
|
|
74
|
+
},
|
|
75
|
+
queryString: false
|
|
76
|
+
},
|
|
77
|
+
// MinTTL <= DefaultTTL <= MaxTTL
|
|
78
|
+
minTtl: 0,
|
|
79
|
+
defaultTtl: 600,
|
|
80
|
+
maxTtl: 600
|
|
81
|
+
},
|
|
82
|
+
priceClass: "PriceClass_100",
|
|
83
|
+
customErrorResponses: [{
|
|
84
|
+
errorCode: 404,
|
|
85
|
+
responseCode: 404,
|
|
86
|
+
responsePagePath: "/index.html"
|
|
87
|
+
}],
|
|
88
|
+
restrictions: {
|
|
89
|
+
geoRestriction: {
|
|
90
|
+
restrictionType: "none"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
viewerCertificate: {
|
|
94
|
+
cloudfrontDefaultCertificate: true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const domains = app.getParam(projectAppParams.domains);
|
|
99
|
+
|
|
100
|
+
if (domains) {
|
|
101
|
+
(0, _customDomain.applyCustomDomain)(cloudfront, domains);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
app.addOutputs({
|
|
105
|
+
appStorage: bucket.bucket.output.id,
|
|
106
|
+
appDomain: cloudfront.output.domainName,
|
|
107
|
+
appUrl: cloudfront.output.domainName.apply(value => `https://${value}`)
|
|
108
|
+
});
|
|
109
|
+
(0, _utils.tagResources)({
|
|
110
|
+
WbyAppName: name,
|
|
111
|
+
WbyProjectName: String(process.env["WEBINY_PROJECT_NAME"]),
|
|
112
|
+
WbyEnvironment: String(process.env["WEBINY_ENV"])
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* We need to store the appUrl to the admin settings item in the dynamodb
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
app.addResource(aws.dynamodb.TableItem, {
|
|
119
|
+
name: "adminSettings",
|
|
120
|
+
config: {
|
|
121
|
+
tableName: core.primaryDynamodbTableName,
|
|
122
|
+
hashKey: core.primaryDynamodbTableHashKey,
|
|
123
|
+
rangeKey: pulumi.output(core.primaryDynamodbTableRangeKey).apply(key => key || "SK"),
|
|
124
|
+
item: pulumi.interpolate`{
|
|
125
|
+
"PK": {"S": "ADMIN#SETTINGS"},
|
|
126
|
+
"SK": {"S": "${app.params.run.variant || "default"}"},
|
|
127
|
+
"data": {
|
|
128
|
+
"M": {
|
|
129
|
+
"appUrl": {
|
|
130
|
+
"S": "${cloudfront.output.domainName.apply(value => `https://${value}`)}"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}`
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, bucket), {}, {
|
|
138
|
+
cloudfront
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.createReactPulumiApp = createReactPulumiApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createReactPulumiApp","projectAppParams","createPulumiApp","name","path","folder","config","program","app","pulumiResourceNamePrefix","getParam","onResource","resource","startsWith","core","addModule","CoreOutput","pulumi","addHandler","bucket","createPrivateAppBucket","cloudfront","addResource","aws","Distribution","enabled","waitForDeployment","origins","origin","defaultRootObject","defaultCacheBehavior","compress","targetOriginId","originId","viewerProtocolPolicy","allowedMethods","cachedMethods","forwardedValues","cookies","forward","queryString","minTtl","defaultTtl","maxTtl","priceClass","customErrorResponses","errorCode","responseCode","responsePagePath","restrictions","geoRestriction","restrictionType","viewerCertificate","cloudfrontDefaultCertificate","domains","applyCustomDomain","addOutputs","appStorage","output","id","appDomain","domainName","appUrl","apply","value","tagResources","WbyAppName","WbyProjectName","String","process","env","WbyEnvironment","dynamodb","TableItem","tableName","primaryDynamodbTableName","hashKey","primaryDynamodbTableHashKey","rangeKey","primaryDynamodbTableRangeKey","key","item","interpolate","params","run","variant"],"sources":["createReactPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\n\nimport { createPulumiApp, PulumiAppParam, PulumiAppParamCallback } from \"@webiny/pulumi\";\nimport { tagResources } from \"~/utils\";\nimport { createPrivateAppBucket } from \"../createAppBucket\";\nimport { applyCustomDomain, CustomDomainParams } from \"../customDomain\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { CoreOutput } from \"../common/CoreOutput\";\n\nexport type ReactPulumiApp = ReturnType<typeof createReactPulumiApp>;\n\nexport interface CreateReactPulumiAppParams {\n /**\n * A name of the app, e.g., \"user-area\"\n */\n name: string;\n\n /**\n * A folder where the app is located, e.g., \"apps/user-area\"\n */\n folder: string;\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: ReactPulumiApp) => 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 createReactPulumiApp = (projectAppParams: CreateReactPulumiAppParams) => {\n return createPulumiApp({\n name: projectAppParams.name,\n path: projectAppParams.folder,\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 const { name } = projectAppParams;\n\n // Register core output as a module available for all other modules\n const core = app.addModule(CoreOutput);\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 to late.\n if (projectAppParams.pulumi) {\n app.addHandler(() => {\n return projectAppParams.pulumi!(app as ReactPulumiApp);\n });\n }\n\n const bucket = createPrivateAppBucket(app, `${name}-app`);\n\n const cloudfront = app.addResource(aws.cloudfront.Distribution, {\n name: `${name}-app-cdn`,\n config: {\n enabled: true,\n waitForDeployment: false,\n origins: [bucket.origin],\n defaultRootObject: \"index.html\",\n defaultCacheBehavior: {\n compress: true,\n targetOriginId: bucket.origin.originId,\n viewerProtocolPolicy: \"redirect-to-https\",\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: { forward: \"none\" },\n queryString: false\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 600,\n maxTtl: 600\n },\n priceClass: \"PriceClass_100\",\n customErrorResponses: [\n { errorCode: 404, responseCode: 404, responsePagePath: \"/index.html\" }\n ],\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n }\n });\n\n const domains = app.getParam(projectAppParams.domains);\n if (domains) {\n applyCustomDomain(cloudfront, domains);\n }\n\n app.addOutputs({\n appStorage: bucket.bucket.output.id,\n appDomain: cloudfront.output.domainName,\n appUrl: cloudfront.output.domainName.apply(value => `https://${value}`)\n });\n\n tagResources({\n WbyAppName: name,\n WbyProjectName: String(process.env[\"WEBINY_PROJECT_NAME\"]),\n WbyEnvironment: String(process.env[\"WEBINY_ENV\"])\n });\n\n /**\n * We need to store the appUrl to the admin settings item in the dynamodb\n */\n app.addResource(aws.dynamodb.TableItem, {\n name: \"adminSettings\",\n config: {\n tableName: core.primaryDynamodbTableName,\n hashKey: core.primaryDynamodbTableHashKey,\n rangeKey: pulumi\n .output(core.primaryDynamodbTableRangeKey)\n .apply(key => key || \"SK\"),\n item: pulumi.interpolate`{\n \"PK\": {\"S\": \"ADMIN#SETTINGS\"},\n \"SK\": {\"S\": \"${app.params.run.variant || \"default\"}\"},\n \"data\": {\n \"M\": {\n \"appUrl\": {\n \"S\": \"${cloudfront.output.domainName.apply(\n value => `https://${value}`\n )}\"\n }\n }\n }\n }`\n }\n });\n\n return {\n ...bucket,\n cloudfront\n };\n }\n });\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA8BO,MAAMA,oBAAoB,GAAIC,gBAAD,IAAkD;EAClF,OAAO,IAAAC,uBAAA,EAAgB;IACnBC,IAAI,EAAEF,gBAAgB,CAACE,IADJ;IAEnBC,IAAI,EAAEH,gBAAgB,CAACI,MAFJ;IAGnBC,MAAM,EAAEL,gBAHW;IAInBM,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;MAHb,CAAb;MAMA;AACZ;AACA;;MACY9D,GAAG,CAACc,WAAJ,CAAgBC,GAAG,CAACiD,QAAJ,CAAaC,SAA7B,EAAwC;QACpCtE,IAAI,EAAE,eAD8B;QAEpCG,MAAM,EAAE;UACJoE,SAAS,EAAE5D,IAAI,CAAC6D,wBADZ;UAEJC,OAAO,EAAE9D,IAAI,CAAC+D,2BAFV;UAGJC,QAAQ,EAAE7D,MAAM,CACXyC,MADK,CACE5C,IAAI,CAACiE,4BADP,EAELhB,KAFK,CAECiB,GAAG,IAAIA,GAAG,IAAI,IAFf,CAHN;UAMJC,IAAI,EAAEhE,MAAM,CAACiE,WAAY;AAC7C;AACA,yCAAyC1E,GAAG,CAAC2E,MAAJ,CAAWC,GAAX,CAAeC,OAAf,IAA0B,SAAU;AAC7E;AACA;AACA;AACA,wCAAwChE,UAAU,CAACqC,MAAX,CAAkBG,UAAlB,CAA6BE,KAA7B,CACJC,KAAK,IAAK,WAAUA,KAAM,EADtB,CAEN;AAClC;AACA;AACA;AACA;QAlBwB;MAF4B,CAAxC;MAwBA,mEACO7C,MADP;QAEIE;MAFJ;IAIH;EApHkB,CAAhB,CAAP;AAsHH,CAvHM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./createReactPulumiApp";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _createReactPulumiApp = require("./createReactPulumiApp");
|
|
8
|
+
|
|
9
|
+
Object.keys(_createReactPulumiApp).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _createReactPulumiApp[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _createReactPulumiApp[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createReactPulumiApp\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
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.applyTenantRouter = applyTenantRouter;
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var _fs = require("fs");
|
|
15
|
+
|
|
16
|
+
var pulumi = _interopRequireWildcard(require("@pulumi/pulumi"));
|
|
17
|
+
|
|
18
|
+
var aws = _interopRequireWildcard(require("@pulumi/aws"));
|
|
19
|
+
|
|
20
|
+
var _common = require("./common");
|
|
21
|
+
|
|
22
|
+
function createFunctionArchive({
|
|
23
|
+
dynamoDbTable,
|
|
24
|
+
region
|
|
25
|
+
}) {
|
|
26
|
+
const handler = (0, _fs.readFileSync)(__dirname + "/../components/tenantRouter/functions/origin/request.js", "utf-8");
|
|
27
|
+
const source = handler.replace("{DB_TABLE_NAME}", dynamoDbTable).replace("{DB_TABLE_REGION}", region);
|
|
28
|
+
return new pulumi.asset.AssetArchive({
|
|
29
|
+
"index.js": new pulumi.asset.StringAsset(source)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const PREFIX = "website-router";
|
|
34
|
+
|
|
35
|
+
function applyTenantRouter(app, cloudfront) {
|
|
36
|
+
const region = String(process.env.AWS_REGION); // Get Core app output
|
|
37
|
+
|
|
38
|
+
const core = app.getModule(_common.CoreOutput); // `primaryDynamodbTableName` is a string, hence the type cast here.
|
|
39
|
+
|
|
40
|
+
const dynamoDbTable = core.primaryDynamodbTableName; // Because of JSON.stringify, we need to resolve promises upfront.
|
|
41
|
+
|
|
42
|
+
const inlinePolicies = pulumi.all([aws.getCallerIdentity({}), dynamoDbTable]).apply(([identity, dynamoDbTable]) => [{
|
|
43
|
+
name: "tenant-router-policy",
|
|
44
|
+
policy: JSON.stringify({
|
|
45
|
+
Version: "2012-10-17",
|
|
46
|
+
Statement: [{
|
|
47
|
+
Sid: "PermissionForDynamodb",
|
|
48
|
+
Effect: "Allow",
|
|
49
|
+
Action: ["dynamodb:GetItem", "dynamodb:Query"],
|
|
50
|
+
Resource: [`arn:aws:dynamodb:${region}:${identity.accountId}:table/${dynamoDbTable}`, `arn:aws:dynamodb:${region}:${identity.accountId}:table/${dynamoDbTable}/*`]
|
|
51
|
+
}]
|
|
52
|
+
})
|
|
53
|
+
}]);
|
|
54
|
+
const role = app.addResource(aws.iam.Role, {
|
|
55
|
+
name: `${PREFIX}-role`,
|
|
56
|
+
config: {
|
|
57
|
+
inlinePolicies,
|
|
58
|
+
managedPolicyArns: [aws.iam.ManagedPolicies.AWSLambdaBasicExecutionRole],
|
|
59
|
+
assumeRolePolicy: {
|
|
60
|
+
Version: "2012-10-17",
|
|
61
|
+
Statement: [{
|
|
62
|
+
Action: "sts:AssumeRole",
|
|
63
|
+
Principal: aws.iam.Principals.LambdaPrincipal,
|
|
64
|
+
Effect: "Allow"
|
|
65
|
+
}, {
|
|
66
|
+
Action: "sts:AssumeRole",
|
|
67
|
+
Principal: aws.iam.Principals.EdgeLambdaPrincipal,
|
|
68
|
+
Effect: "Allow"
|
|
69
|
+
}]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const awsUsEast1 = new aws.Provider("us-east-1", {
|
|
74
|
+
region: "us-east-1"
|
|
75
|
+
});
|
|
76
|
+
const originLambda = app.addResource(aws.lambda.Function, {
|
|
77
|
+
name: `${PREFIX}-origin-request`,
|
|
78
|
+
config: {
|
|
79
|
+
publish: true,
|
|
80
|
+
runtime: "nodejs14.x",
|
|
81
|
+
handler: "index.handler",
|
|
82
|
+
role: role.output.arn,
|
|
83
|
+
timeout: 5,
|
|
84
|
+
memorySize: 128,
|
|
85
|
+
code: dynamoDbTable.apply(dynamoDbTable => {
|
|
86
|
+
return createFunctionArchive({
|
|
87
|
+
region,
|
|
88
|
+
dynamoDbTable
|
|
89
|
+
});
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
opts: {
|
|
93
|
+
provider: awsUsEast1
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
cloudfront.config.defaultCacheBehavior(value => {
|
|
97
|
+
var _value$forwardedValue, _value$forwardedValue2, _value$forwardedValue3;
|
|
98
|
+
|
|
99
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, value), {}, {
|
|
100
|
+
// We need to forward the `Host` header so the Lambda@Edge knows what custom domain was requested.
|
|
101
|
+
forwardedValues: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, value.forwardedValues), {}, {
|
|
102
|
+
queryString: ((_value$forwardedValue = value.forwardedValues) === null || _value$forwardedValue === void 0 ? void 0 : _value$forwardedValue.queryString) || false,
|
|
103
|
+
cookies: ((_value$forwardedValue2 = value.forwardedValues) === null || _value$forwardedValue2 === void 0 ? void 0 : _value$forwardedValue2.cookies) || {
|
|
104
|
+
forward: "none"
|
|
105
|
+
},
|
|
106
|
+
headers: [...(((_value$forwardedValue3 = value.forwardedValues) === null || _value$forwardedValue3 === void 0 ? void 0 : _value$forwardedValue3.headers) || []), "Host"]
|
|
107
|
+
}),
|
|
108
|
+
lambdaFunctionAssociations: [...(value.lambdaFunctionAssociations || []), {
|
|
109
|
+
eventType: "origin-request",
|
|
110
|
+
includeBody: false,
|
|
111
|
+
lambdaArn: originLambda.output.qualifiedArn
|
|
112
|
+
}]
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFunctionArchive","dynamoDbTable","region","handler","readFileSync","__dirname","source","replace","pulumi","asset","AssetArchive","StringAsset","PREFIX","applyTenantRouter","app","cloudfront","String","process","env","AWS_REGION","core","getModule","CoreOutput","primaryDynamodbTableName","inlinePolicies","all","aws","getCallerIdentity","apply","identity","name","policy","JSON","stringify","Version","Statement","Sid","Effect","Action","Resource","accountId","role","addResource","iam","Role","config","managedPolicyArns","ManagedPolicies","AWSLambdaBasicExecutionRole","assumeRolePolicy","Principal","Principals","LambdaPrincipal","EdgeLambdaPrincipal","awsUsEast1","Provider","originLambda","lambda","Function","publish","runtime","output","arn","timeout","memorySize","code","opts","provider","defaultCacheBehavior","value","forwardedValues","queryString","cookies","forward","headers","lambdaFunctionAssociations","eventType","includeBody","lambdaArn","qualifiedArn"],"sources":["tenantRouter.ts"],"sourcesContent":["import { readFileSync } from \"fs\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { PulumiApp, PulumiAppResource } from \"@webiny/pulumi\";\nimport { CoreOutput } from \"./common\";\n\ninterface Params {\n region: string;\n dynamoDbTable: string;\n}\n\nfunction createFunctionArchive({ dynamoDbTable, region }: Params) {\n const handler = readFileSync(\n __dirname + \"/../components/tenantRouter/functions/origin/request.js\",\n \"utf-8\"\n );\n\n const source = handler\n .replace(\"{DB_TABLE_NAME}\", dynamoDbTable)\n .replace(\"{DB_TABLE_REGION}\", region);\n\n return new pulumi.asset.AssetArchive({\n \"index.js\": new pulumi.asset.StringAsset(source)\n });\n}\n\nconst PREFIX = \"website-router\";\n\nexport function applyTenantRouter(\n app: PulumiApp,\n cloudfront: PulumiAppResource<typeof aws.cloudfront.Distribution>\n) {\n const region = String(process.env.AWS_REGION);\n\n // Get Core app output\n const core = app.getModule(CoreOutput);\n\n // `primaryDynamodbTableName` is a string, hence the type cast here.\n const dynamoDbTable = core.primaryDynamodbTableName;\n\n // Because of JSON.stringify, we need to resolve promises upfront.\n const inlinePolicies = pulumi\n .all([aws.getCallerIdentity({}), dynamoDbTable])\n .apply(([identity, dynamoDbTable]) => [\n {\n name: \"tenant-router-policy\",\n policy: JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\"dynamodb:GetItem\", \"dynamodb:Query\"],\n Resource: [\n `arn:aws:dynamodb:${region}:${identity.accountId}:table/${dynamoDbTable}`,\n `arn:aws:dynamodb:${region}:${identity.accountId}:table/${dynamoDbTable}/*`\n ]\n }\n ]\n })\n }\n ]);\n\n const role = app.addResource(aws.iam.Role, {\n name: `${PREFIX}-role`,\n config: {\n inlinePolicies,\n managedPolicyArns: [aws.iam.ManagedPolicies.AWSLambdaBasicExecutionRole],\n assumeRolePolicy: {\n Version: \"2012-10-17\",\n Statement: [\n {\n Action: \"sts:AssumeRole\",\n Principal: aws.iam.Principals.LambdaPrincipal,\n Effect: \"Allow\"\n },\n {\n Action: \"sts:AssumeRole\",\n Principal: aws.iam.Principals.EdgeLambdaPrincipal,\n Effect: \"Allow\"\n }\n ]\n }\n }\n });\n\n const awsUsEast1 = new aws.Provider(\"us-east-1\", { region: \"us-east-1\" });\n\n const originLambda = app.addResource(aws.lambda.Function, {\n name: `${PREFIX}-origin-request`,\n config: {\n publish: true,\n runtime: \"nodejs14.x\",\n handler: \"index.handler\",\n role: role.output.arn,\n timeout: 5,\n memorySize: 128,\n code: dynamoDbTable.apply(dynamoDbTable => {\n return createFunctionArchive({\n region,\n dynamoDbTable\n });\n })\n },\n opts: { provider: awsUsEast1 }\n });\n\n cloudfront.config.defaultCacheBehavior(value => {\n return {\n ...value,\n // We need to forward the `Host` header so the Lambda@Edge knows what custom domain was requested.\n forwardedValues: {\n ...value.forwardedValues,\n queryString: value.forwardedValues?.queryString || false,\n cookies: value.forwardedValues?.cookies || { forward: \"none\" },\n headers: [...(value.forwardedValues?.headers || []), \"Host\"]\n },\n lambdaFunctionAssociations: [\n ...(value.lambdaFunctionAssociations || []),\n {\n eventType: \"origin-request\",\n includeBody: false,\n lambdaArn: originLambda.output.qualifiedArn\n }\n ]\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAOA,SAASA,qBAAT,CAA+B;EAAEC,aAAF;EAAiBC;AAAjB,CAA/B,EAAkE;EAC9D,MAAMC,OAAO,GAAG,IAAAC,gBAAA,EACZC,SAAS,GAAG,yDADA,EAEZ,OAFY,CAAhB;EAKA,MAAMC,MAAM,GAAGH,OAAO,CACjBI,OADU,CACF,iBADE,EACiBN,aADjB,EAEVM,OAFU,CAEF,mBAFE,EAEmBL,MAFnB,CAAf;EAIA,OAAO,IAAIM,MAAM,CAACC,KAAP,CAAaC,YAAjB,CAA8B;IACjC,YAAY,IAAIF,MAAM,CAACC,KAAP,CAAaE,WAAjB,CAA6BL,MAA7B;EADqB,CAA9B,CAAP;AAGH;;AAED,MAAMM,MAAM,GAAG,gBAAf;;AAEO,SAASC,iBAAT,CACHC,GADG,EAEHC,UAFG,EAGL;EACE,MAAMb,MAAM,GAAGc,MAAM,CAACC,OAAO,CAACC,GAAR,CAAYC,UAAb,CAArB,CADF,CAGE;;EACA,MAAMC,IAAI,GAAGN,GAAG,CAACO,SAAJ,CAAcC,kBAAd,CAAb,CAJF,CAME;;EACA,MAAMrB,aAAa,GAAGmB,IAAI,CAACG,wBAA3B,CAPF,CASE;;EACA,MAAMC,cAAc,GAAGhB,MAAM,CACxBiB,GADkB,CACd,CAACC,GAAG,CAACC,iBAAJ,CAAsB,EAAtB,CAAD,EAA4B1B,aAA5B,CADc,EAElB2B,KAFkB,CAEZ,CAAC,CAACC,QAAD,EAAW5B,aAAX,CAAD,KAA+B,CAClC;IACI6B,IAAI,EAAE,sBADV;IAEIC,MAAM,EAAEC,IAAI,CAACC,SAAL,CA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face PreRenderingServiceParams {
|
|
4
|
+
dbTableName: pulumi.Output<string>;
|
|
5
|
+
dbTableHashKey: pulumi.Output<string>;
|
|
6
|
+
dbTableRangeKey: pulumi.Output<string>;
|
|
7
|
+
appUrl: pulumi.Output<string>;
|
|
8
|
+
deliveryUrl: pulumi.Output<string>;
|
|
9
|
+
bucket: pulumi.Output<string>;
|
|
10
|
+
cloudfrontId: pulumi.Output<string>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createPrerenderingService(app: PulumiApp, params: PreRenderingServiceParams): {
|
|
13
|
+
subscriber: {
|
|
14
|
+
policy: pulumi.Output<import("@pulumi/aws/iam/policy").Policy>;
|
|
15
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
16
|
+
lambda: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
17
|
+
eventRule: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventRule").EventRule>;
|
|
18
|
+
eventPermission: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/permission").Permission>;
|
|
19
|
+
eventTarget: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
|
|
20
|
+
};
|
|
21
|
+
renderer: {
|
|
22
|
+
policy: pulumi.Output<import("@pulumi/aws/iam/policy").Policy>;
|
|
23
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
24
|
+
lambda: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
25
|
+
eventSourceMapping: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/eventSourceMapping").EventSourceMapping>;
|
|
26
|
+
};
|
|
27
|
+
flush: {
|
|
28
|
+
policy: pulumi.Output<import("@pulumi/aws/iam/policy").Policy>;
|
|
29
|
+
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role").Role>;
|
|
30
|
+
lambda: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function").Function>;
|
|
31
|
+
eventRule: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventRule").EventRule>;
|
|
32
|
+
eventPermission: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/permission").Permission>;
|
|
33
|
+
eventTarget: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/eventTarget").EventTarget>;
|
|
34
|
+
};
|
|
35
|
+
settings: {
|
|
36
|
+
tableItem: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/dynamodb/tableItem").TableItem>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export {};
|