@webiny/project-aws 6.6.0-alpha.11 → 6.6.0-alpha.13
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/_templates/appTemplates/api/graphql/package.json +2 -2
- package/_templates/appTemplates/api/graphql/src/index.ts +2 -2
- package/_templates/appTemplates/api/graphql/src/web.ts +15 -0
- package/_templates/appTemplates/api/graphql/webiny.config.ts +6 -1
- package/_templates/extensions/OpenSearch/api/graphql/src/index.ts +2 -2
- package/_templates/extensions/OpenSearch/api/graphql/src/web.ts +15 -0
- package/_templates/extensions/Postgres/api/graphql/src/index.ts +17 -0
- package/_templates/extensions/Postgres/api/graphql/src/web.ts +15 -0
- package/api.d.ts +6 -6
- package/api.js +3 -2
- package/api.js.map +1 -1
- package/apps/createApiApp.d.ts +18 -1
- package/apps/createCoreApp.d.ts +1 -1
- package/decorators/GetPulumiServiceWithDownloadInfo.d.ts +1 -3
- package/decorators/GetPulumiServiceWithDownloadInfo.js +15 -11
- package/decorators/GetPulumiServiceWithDownloadInfo.js.map +1 -1
- package/extensions/ApiRoute.d.ts +2 -1
- package/extensions/ApiRoute.js.map +1 -1
- package/extensions/AuroraPostgresCluster.d.ts +12 -0
- package/extensions/AuroraPostgresCluster.js +30 -0
- package/extensions/AuroraPostgresCluster.js.map +1 -0
- package/extensions/Postgres/AddCorePostgres.d.ts +27 -0
- package/extensions/Postgres/AddCorePostgres.js +52 -0
- package/extensions/Postgres/AddCorePostgres.js.map +1 -0
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.d.ts +16 -0
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.js +42 -0
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.js.map +1 -0
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.d.ts +17 -0
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js +33 -0
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js.map +1 -0
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.d.ts +23 -0
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js +41 -0
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js.map +1 -0
- package/extensions/Postgres/copyPgRuntimeModules.d.ts +27 -0
- package/extensions/Postgres/copyPgRuntimeModules.js +124 -0
- package/extensions/Postgres/copyPgRuntimeModules.js.map +1 -0
- package/extensions/Postgres/rds-ca-bundle.pem +2888 -0
- package/extensions/Postgres/rdsCaBundle.d.ts +13 -0
- package/extensions/Postgres/rdsCaBundle.js +7 -0
- package/extensions/Postgres/rdsCaBundle.js.map +1 -0
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.d.ts +20 -0
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.js +34 -0
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.js.map +1 -0
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.d.ts +20 -0
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.js +27 -0
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.js.map +1 -0
- package/extensions/ProjectAws.js +4 -0
- package/extensions/ProjectAws.js.map +1 -1
- package/extensions/definitions.js +3 -1
- package/extensions/definitions.js.map +1 -1
- package/extensions/index.d.ts +4 -1
- package/extensions/index.js +3 -2
- package/extensions/registerExtensionImplementations.js +3 -1
- package/extensions/registerExtensionImplementations.js.map +1 -1
- package/extensions/toCloudFrontPathPattern.d.ts +5 -0
- package/extensions/toCloudFrontPathPattern.js +8 -0
- package/extensions/toCloudFrontPathPattern.js.map +1 -0
- package/features/Watch/AwsWatch.js +1 -0
- package/features/Watch/AwsWatch.js.map +1 -1
- package/features/Watch/forwarder/createForwarderZip.d.ts +8 -0
- package/features/Watch/forwarder/createForwarderZip.js +19 -0
- package/features/Watch/forwarder/createForwarderZip.js.map +1 -0
- package/features/Watch/forwarder/lambdaHandler.cjs +124 -0
- package/features/Watch/forwarder/lambdaHandler.d.cts +1 -0
- package/features/Watch/forwarder/mqtt.cjs +4 -0
- package/features/Watch/forwarder/mqtt.d.cts +1 -0
- package/features/Watch/forwarder/webHandler.d.mts +1 -0
- package/features/Watch/forwarder/webHandler.mjs +298 -0
- package/features/Watch/replaceLambdaFunctions.d.ts +2 -0
- package/features/Watch/replaceLambdaFunctions.js +44 -3
- package/features/Watch/replaceLambdaFunctions.js.map +1 -1
- package/features/Watch/replaceWebFunction.d.ts +44 -0
- package/features/Watch/replaceWebFunction.js +119 -0
- package/features/Watch/replaceWebFunction.js.map +1 -0
- package/infra.d.ts +13 -0
- package/infra.js +8 -6
- package/infra.js.map +1 -1
- package/package.json +21 -17
- package/project.d.ts +1 -0
- package/pulumi/apps/admin/createAdminPulumiApp.js +1 -2
- package/pulumi/apps/admin/createAdminPulumiApp.js.map +1 -1
- package/pulumi/apps/api/ApiCloudfront.d.ts +5 -0
- package/pulumi/apps/api/ApiCloudfront.js +71 -198
- package/pulumi/apps/api/ApiCloudfront.js.map +1 -1
- package/pulumi/apps/api/ApiFileManager.d.ts +8 -1
- package/pulumi/apps/api/ApiFileManager.js +11 -1
- package/pulumi/apps/api/ApiFileManager.js.map +1 -1
- package/pulumi/apps/api/ApiGraphql.d.ts +1 -1
- package/pulumi/apps/api/ApiGraphql.js +78 -69
- package/pulumi/apps/api/ApiGraphql.js.map +1 -1
- package/pulumi/apps/api/ApiGraphqlWeb.d.ts +45 -0
- package/pulumi/apps/api/ApiGraphqlWeb.js +280 -0
- package/pulumi/apps/api/ApiGraphqlWeb.js.map +1 -0
- package/pulumi/apps/api/ApiOutput.d.ts +1 -0
- package/pulumi/apps/api/ApiOutput.js +2 -1
- package/pulumi/apps/api/ApiOutput.js.map +1 -1
- package/pulumi/apps/api/ApiSchemaSetup.d.ts +86 -0
- package/pulumi/apps/api/ApiSchemaSetup.js +139 -0
- package/pulumi/apps/api/ApiSchemaSetup.js.map +1 -0
- package/pulumi/apps/api/apiDynamoDb.d.ts +6 -0
- package/pulumi/apps/api/apiDynamoDb.js +20 -0
- package/pulumi/apps/api/apiDynamoDb.js.map +1 -0
- package/pulumi/apps/api/apiServiceManifests.d.ts +24 -0
- package/pulumi/apps/api/apiServiceManifests.js +27 -0
- package/pulumi/apps/api/apiServiceManifests.js.map +1 -0
- package/pulumi/apps/api/backgroundTask/types.js.map +1 -1
- package/pulumi/apps/api/cloudfront/addWebRouteBehavior.d.ts +8 -0
- package/pulumi/apps/api/cloudfront/addWebRouteBehavior.js +26 -0
- package/pulumi/apps/api/cloudfront/addWebRouteBehavior.js.map +1 -0
- package/pulumi/apps/api/cloudfront/allowFunctionUrlInvoke.d.ts +17 -0
- package/pulumi/apps/api/cloudfront/allowFunctionUrlInvoke.js +27 -0
- package/pulumi/apps/api/cloudfront/allowFunctionUrlInvoke.js.map +1 -0
- package/pulumi/apps/api/cloudfront/allowWebFunctionInvoke.d.ts +8 -0
- package/pulumi/apps/api/cloudfront/allowWebFunctionInvoke.js +31 -0
- package/pulumi/apps/api/cloudfront/allowWebFunctionInvoke.js.map +1 -0
- package/pulumi/apps/api/cloudfront/constants.d.ts +24 -0
- package/pulumi/apps/api/cloudfront/constants.js +43 -0
- package/pulumi/apps/api/cloudfront/constants.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createFilesRouting.d.ts +10 -0
- package/pulumi/apps/api/cloudfront/createFilesRouting.js +35 -0
- package/pulumi/apps/api/cloudfront/createFilesRouting.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createGatewayRouting.d.ts +10 -0
- package/pulumi/apps/api/cloudfront/createGatewayRouting.js +48 -0
- package/pulumi/apps/api/cloudfront/createGatewayRouting.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createStreamRouting.d.ts +10 -0
- package/pulumi/apps/api/cloudfront/createStreamRouting.js +87 -0
- package/pulumi/apps/api/cloudfront/createStreamRouting.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createWebRouting.d.ts +13 -0
- package/pulumi/apps/api/cloudfront/createWebRouting.js +140 -0
- package/pulumi/apps/api/cloudfront/createWebRouting.js.map +1 -0
- package/pulumi/apps/api/createApiPulumiApp.d.ts +22 -4
- package/pulumi/apps/api/createApiPulumiApp.js +122 -81
- package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
- package/pulumi/apps/api/index.d.ts +2 -0
- package/pulumi/apps/api/index.js +2 -0
- package/pulumi/apps/api/isRouteNameAllowed.d.ts +7 -0
- package/pulumi/apps/api/isRouteNameAllowed.js +6 -0
- package/pulumi/apps/api/isRouteNameAllowed.js.map +1 -0
- package/pulumi/apps/common/CoreOutput.d.ts +13 -0
- package/pulumi/apps/common/CoreOutput.js +17 -2
- package/pulumi/apps/common/CoreOutput.js.map +1 -1
- package/pulumi/apps/core/CoreCognito.d.ts +14 -0
- package/pulumi/apps/core/CoreCognito.js +34 -1
- package/pulumi/apps/core/CoreCognito.js.map +1 -1
- package/pulumi/apps/core/CoreOpenSearch.js +12 -6
- package/pulumi/apps/core/CoreOpenSearch.js.map +1 -1
- package/pulumi/apps/core/CorePostgres.d.ts +48 -0
- package/pulumi/apps/core/CorePostgres.js +262 -0
- package/pulumi/apps/core/CorePostgres.js.map +1 -0
- package/pulumi/apps/core/cognitoIdentityProviders/configure.js +11 -0
- package/pulumi/apps/core/cognitoIdentityProviders/configure.js.map +1 -1
- package/pulumi/apps/core/coreDynamoDb.d.ts +19 -0
- package/pulumi/apps/core/coreDynamoDb.js +34 -0
- package/pulumi/apps/core/coreDynamoDb.js.map +1 -0
- package/pulumi/apps/core/coreServiceManifests.d.ts +31 -0
- package/pulumi/apps/core/coreServiceManifests.js +31 -0
- package/pulumi/apps/core/coreServiceManifests.js.map +1 -0
- package/pulumi/apps/core/coreVpcEndpoints.d.ts +14 -0
- package/pulumi/apps/core/coreVpcEndpoints.js +55 -0
- package/pulumi/apps/core/coreVpcEndpoints.js.map +1 -0
- package/pulumi/apps/core/createCorePulumiApp.d.ts +1 -1
- package/pulumi/apps/core/createCorePulumiApp.js +18 -78
- package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
- package/pulumi/apps/core/index.d.ts +1 -0
- package/pulumi/apps/core/index.js +1 -0
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.d.ts +15 -0
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.js +16 -0
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.js.map +1 -0
- package/pulumi/apps/extensions/getVpcConfigFromExtension.d.ts +4 -0
- package/pulumi/apps/extensions/isWebFunctionEnabled.d.ts +5 -0
- package/pulumi/apps/extensions/isWebFunctionEnabled.js +9 -0
- package/pulumi/apps/extensions/isWebFunctionEnabled.js.map +1 -0
- package/pulumi/apps/extensions/projectUsesPostgres.d.ts +2 -0
- package/pulumi/apps/extensions/projectUsesPostgres.js +10 -0
- package/pulumi/apps/extensions/projectUsesPostgres.js.map +1 -0
- package/pulumi/apps/react/adminSettingsItem.d.ts +17 -0
- package/pulumi/apps/react/adminSettingsItem.js +28 -0
- package/pulumi/apps/react/adminSettingsItem.js.map +1 -0
- package/pulumi/apps/react/createReactPulumiApp.js +6 -19
- package/pulumi/apps/react/createReactPulumiApp.js.map +1 -1
- package/pulumi/extensions/index.d.ts +12 -45
- package/pulumi/extensions/index.js +2 -1
- package/pulumi/extensions/index.js.map +1 -1
- package/pulumi/types.d.ts +5 -0
- package/pulumi/utils/lambdaEnvVariables.js +2 -2
- package/pulumi/utils/lambdaEnvVariables.js.map +1 -1
- package/pulumi/utils/tagResources.js +2 -0
- package/pulumi/utils/tagResources.js.map +1 -1
- package/pulumi/utils/withServiceManifest.d.ts +35 -1
- package/pulumi/utils/withServiceManifest.js +53 -9
- package/pulumi/utils/withServiceManifest.js.map +1 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js +1 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js.map +1 -1
- package/features/Watch/handler/handler.zip +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ALL_METHODS, API_VIEWER_HEADERS, CORS_PREFLIGHT_HEADERS, WEB_ORIGIN_ID } from "./constants.js";
|
|
2
|
+
import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
|
|
3
|
+
function createWebRouting(app, graphqlWeb) {
|
|
4
|
+
const credentialsCacheKey = {
|
|
5
|
+
enableAcceptEncodingGzip: true,
|
|
6
|
+
enableAcceptEncodingBrotli: true,
|
|
7
|
+
headersConfig: {
|
|
8
|
+
headerBehavior: "whitelist",
|
|
9
|
+
headers: {
|
|
10
|
+
items: [
|
|
11
|
+
...API_VIEWER_HEADERS,
|
|
12
|
+
...CORS_PREFLIGHT_HEADERS,
|
|
13
|
+
"Authorization",
|
|
14
|
+
"X-Webiny-Authorization"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
cookiesConfig: {
|
|
19
|
+
cookieBehavior: "whitelist",
|
|
20
|
+
cookies: {
|
|
21
|
+
items: [
|
|
22
|
+
"wby-id-token"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
queryStringsConfig: {
|
|
27
|
+
queryStringBehavior: "all"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const uncachedPolicy = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.cloudfront.CachePolicy, {
|
|
31
|
+
name: "api-web-uncached-policy",
|
|
32
|
+
config: {
|
|
33
|
+
comment: "API web function routes: not cached, keyed on the caller's credentials",
|
|
34
|
+
minTtl: 0,
|
|
35
|
+
defaultTtl: 0,
|
|
36
|
+
maxTtl: 1,
|
|
37
|
+
parametersInCacheKeyAndForwardedToOrigin: credentialsCacheKey
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const routeCachePolicy = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.cloudfront.CachePolicy, {
|
|
41
|
+
name: "api-web-route-cache-policy",
|
|
42
|
+
config: {
|
|
43
|
+
comment: "Api.Route paths on the API web function: cached only when the route says so",
|
|
44
|
+
minTtl: 0,
|
|
45
|
+
defaultTtl: 0,
|
|
46
|
+
maxTtl: 31536000,
|
|
47
|
+
parametersInCacheKeyAndForwardedToOrigin: credentialsCacheKey
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const wbCachePolicy = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.cloudfront.CachePolicy, {
|
|
51
|
+
name: "api-web-wb-cache-policy",
|
|
52
|
+
config: {
|
|
53
|
+
comment: "Website builder routes on the API web function, keyed on the auth headers",
|
|
54
|
+
minTtl: 0,
|
|
55
|
+
defaultTtl: 86400,
|
|
56
|
+
maxTtl: 31536000,
|
|
57
|
+
parametersInCacheKeyAndForwardedToOrigin: {
|
|
58
|
+
enableAcceptEncodingGzip: true,
|
|
59
|
+
enableAcceptEncodingBrotli: true,
|
|
60
|
+
headersConfig: {
|
|
61
|
+
headerBehavior: "whitelist",
|
|
62
|
+
headers: {
|
|
63
|
+
items: [
|
|
64
|
+
...API_VIEWER_HEADERS,
|
|
65
|
+
...CORS_PREFLIGHT_HEADERS,
|
|
66
|
+
"Authorization",
|
|
67
|
+
"X-Webiny-Authorization"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
cookiesConfig: {
|
|
72
|
+
cookieBehavior: "none"
|
|
73
|
+
},
|
|
74
|
+
queryStringsConfig: {
|
|
75
|
+
queryStringBehavior: "all"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const oac = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.cloudfront.OriginAccessControl, {
|
|
81
|
+
name: "api-web-oac",
|
|
82
|
+
config: {
|
|
83
|
+
description: "Signs CloudFront requests to the API web function endpoint",
|
|
84
|
+
originAccessControlOriginType: "lambda",
|
|
85
|
+
signingBehavior: "always-amz-auth",
|
|
86
|
+
signingProtocol: "sigv4"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const behaviors = [];
|
|
90
|
+
for (const pathPattern of [
|
|
91
|
+
"/graphql",
|
|
92
|
+
"/cms*"
|
|
93
|
+
])behaviors.push({
|
|
94
|
+
compress: true,
|
|
95
|
+
allowedMethods: ALL_METHODS,
|
|
96
|
+
cachedMethods: [
|
|
97
|
+
"GET",
|
|
98
|
+
"HEAD"
|
|
99
|
+
],
|
|
100
|
+
cachePolicyId: uncachedPolicy.output.id,
|
|
101
|
+
pathPattern,
|
|
102
|
+
viewerProtocolPolicy: "allow-all",
|
|
103
|
+
targetOriginId: WEB_ORIGIN_ID
|
|
104
|
+
});
|
|
105
|
+
behaviors.push({
|
|
106
|
+
compress: true,
|
|
107
|
+
allowedMethods: ALL_METHODS,
|
|
108
|
+
cachedMethods: [
|
|
109
|
+
"GET",
|
|
110
|
+
"HEAD",
|
|
111
|
+
"OPTIONS"
|
|
112
|
+
],
|
|
113
|
+
cachePolicyId: wbCachePolicy.output.id,
|
|
114
|
+
pathPattern: "/wb/*",
|
|
115
|
+
viewerProtocolPolicy: "allow-all",
|
|
116
|
+
targetOriginId: WEB_ORIGIN_ID
|
|
117
|
+
});
|
|
118
|
+
const origin = {
|
|
119
|
+
domainName: graphqlWeb.endpoint.output.domainName,
|
|
120
|
+
originId: WEB_ORIGIN_ID,
|
|
121
|
+
originAccessControlId: oac.output.id,
|
|
122
|
+
customOriginConfig: {
|
|
123
|
+
httpPort: 80,
|
|
124
|
+
httpsPort: 443,
|
|
125
|
+
originProtocolPolicy: "https-only",
|
|
126
|
+
originSslProtocols: [
|
|
127
|
+
"TLSv1.2"
|
|
128
|
+
],
|
|
129
|
+
originReadTimeout: 60
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
origin,
|
|
134
|
+
behaviors,
|
|
135
|
+
routeCachePolicyId: routeCachePolicy.output.id
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export { createWebRouting };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=createWebRouting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/cloudfront/createWebRouting.js","sources":["../../../../../src/pulumi/apps/api/cloudfront/createWebRouting.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { ApiGraphqlWeb } from \"../ApiGraphqlWeb.js\";\nimport type { DistributionOrigin, OrderedCacheBehavior } from \"./constants.js\";\nimport {\n ALL_METHODS,\n API_VIEWER_HEADERS,\n CORS_PREFLIGHT_HEADERS,\n WEB_ORIGIN_ID\n} from \"./constants.js\";\n\n/**\n * The web function's origin and behaviors: `/graphql` and `/cms*` without caching, and `/wb/*` with\n * caching keyed on the auth headers. `<Api.Route>` paths are added to these later, by\n * `addWebRouteBehavior`, with `routeCachePolicyId`.\n */\nexport function createWebRouting(app: PulumiApp, graphqlWeb: ApiGraphqlWeb) {\n // For `/graphql` and `/cms*`. These routes are not meant to be cached: this policy exists only so\n // that `Authorization` reaches the web function on GET and HEAD requests. CloudFront strips\n // `Authorization` from GET and HEAD unless it is part of the cache key, and an origin request\n // policy is not allowed to forward it, so the cache key is the only place it can go. POST and the other methods keep `Authorization`\n // with or without this policy.\n //\n // The managed CachingDisabled policy can't have a cache key: a policy whose TTLs are all 0 takes\n // none. So this one has a 1 second max TTL, the smallest that allows a key, and a default of 0, and\n // nothing is cached unless the API sends `Cache-Control`.\n //\n // Every header the API reads is in the key, so even that one second is only ever shared by\n // identical requests: same tenant, same token in either header, same cookie, same query string.\n // Keys are also what gets forwarded, so there is no separate origin request policy to keep in\n // step. That is ten headers, the most a cache policy takes. `Host` is not among them: the endpoint\n // answers 404 to any Host but its own.\n const credentialsCacheKey: aws.types.input.cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOrigin =\n {\n enableAcceptEncodingGzip: true,\n enableAcceptEncodingBrotli: true,\n headersConfig: {\n headerBehavior: \"whitelist\",\n headers: {\n items: [\n ...API_VIEWER_HEADERS,\n ...CORS_PREFLIGHT_HEADERS,\n \"Authorization\",\n \"X-Webiny-Authorization\"\n ]\n }\n },\n cookiesConfig: {\n cookieBehavior: \"whitelist\",\n cookies: { items: [\"wby-id-token\"] }\n },\n queryStringsConfig: { queryStringBehavior: \"all\" }\n };\n const uncachedPolicy = app.addResource(aws.cloudfront.CachePolicy, {\n name: \"api-web-uncached-policy\",\n config: {\n comment: \"API web function routes: not cached, keyed on the caller's credentials\",\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 1,\n parametersInCacheKeyAndForwardedToOrigin: credentialsCacheKey\n }\n });\n\n // For `<Api.Route>` paths. Same cache key as above, so `Authorization` still reaches the web\n // function on GET, and the same default of 0, so a route is cached only when its handler sends\n // `Cache-Control`. The max is a year, so a route that serves public data can be cached at the\n // edge as long as it says; `/graphql` and `/cms*` stay capped at one second whatever a response\n // says. Nothing invalidates route paths on its own: a route cached for long needs an invalidation\n // (`CdnCache` in `@webiny/api-core`) when what it serves changes.\n const routeCachePolicy = app.addResource(aws.cloudfront.CachePolicy, {\n name: \"api-web-route-cache-policy\",\n config: {\n comment: \"Api.Route paths on the API web function: cached only when the route says so\",\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 31536000,\n parametersInCacheKeyAndForwardedToOrigin: credentialsCacheKey\n }\n });\n\n // `/wb/*` is cached, as it was behind API Gateway: `InvalidateRedirectsCache` invalidates\n // `/wb/redirects` after a change. The website builder SDK calls `GET /wb/redirects` with an\n // `Authorization` header, and CloudFront only passes that header on a GET when it is part of the\n // cache key, so it is. Same headers, TTLs and no cookies as the old behavior; cookies stay out so\n // a response authorized by one visitor's cookie is never cached for another. That is ten headers,\n // the most a cache policy takes.\n const wbCachePolicy = app.addResource(aws.cloudfront.CachePolicy, {\n name: \"api-web-wb-cache-policy\",\n config: {\n comment: \"Website builder routes on the API web function, keyed on the auth headers\",\n minTtl: 0,\n defaultTtl: 86400,\n maxTtl: 31536000,\n parametersInCacheKeyAndForwardedToOrigin: {\n enableAcceptEncodingGzip: true,\n enableAcceptEncodingBrotli: true,\n headersConfig: {\n headerBehavior: \"whitelist\",\n headers: {\n items: [\n ...API_VIEWER_HEADERS,\n ...CORS_PREFLIGHT_HEADERS,\n \"Authorization\",\n \"X-Webiny-Authorization\"\n ]\n }\n },\n cookiesConfig: { cookieBehavior: \"none\" },\n queryStringsConfig: { queryStringBehavior: \"all\" }\n }\n }\n });\n\n const oac = app.addResource(aws.cloudfront.OriginAccessControl, {\n name: \"api-web-oac\",\n config: {\n description: \"Signs CloudFront requests to the API web function endpoint\",\n originAccessControlOriginType: \"lambda\",\n // The only value web functions accept.\n signingBehavior: \"always-amz-auth\",\n signingProtocol: \"sigv4\"\n }\n });\n\n const behaviors: OrderedCacheBehavior[] = [];\n for (const pathPattern of [\"/graphql\", \"/cms*\"]) {\n behaviors.push({\n compress: true,\n allowedMethods: ALL_METHODS,\n cachedMethods: [\"GET\", \"HEAD\"],\n cachePolicyId: uncachedPolicy.output.id,\n pathPattern,\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: WEB_ORIGIN_ID\n });\n }\n behaviors.push({\n compress: true,\n allowedMethods: ALL_METHODS,\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n cachePolicyId: wbCachePolicy.output.id,\n pathPattern: \"/wb/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: WEB_ORIGIN_ID\n });\n\n const origin: DistributionOrigin = {\n domainName: graphqlWeb.endpoint.output.domainName,\n originId: WEB_ORIGIN_ID,\n originAccessControlId: oac.output.id,\n customOriginConfig: {\n httpPort: 80,\n httpsPort: 443,\n originProtocolPolicy: \"https-only\",\n originSslProtocols: [\"TLSv1.2\"],\n originReadTimeout: 60\n }\n };\n\n return { origin, behaviors, routeCachePolicyId: routeCachePolicy.output.id };\n}\n"],"names":["createWebRouting","app","graphqlWeb","credentialsCacheKey","API_VIEWER_HEADERS","CORS_PREFLIGHT_HEADERS","uncachedPolicy","aws","routeCachePolicy","wbCachePolicy","oac","behaviors","pathPattern","ALL_METHODS","WEB_ORIGIN_ID","origin"],"mappings":";;AAgBO,SAASA,iBAAiBC,GAAc,EAAEC,UAAyB;IAgBtE,MAAMC,sBACF;QACI,0BAA0B;QAC1B,4BAA4B;QAC5B,eAAe;YACX,gBAAgB;YAChB,SAAS;gBACL,OAAO;uBACAC;uBACAC;oBACH;oBACA;iBACH;YACL;QACJ;QACA,eAAe;YACX,gBAAgB;YAChB,SAAS;gBAAE,OAAO;oBAAC;iBAAe;YAAC;QACvC;QACA,oBAAoB;YAAE,qBAAqB;QAAM;IACrD;IACJ,MAAMC,iBAAiBL,IAAI,WAAW,CAACM,uCAAAA,UAAAA,CAAAA,WAA0B,EAAE;QAC/D,MAAM;QACN,QAAQ;YACJ,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,QAAQ;YACR,0CAA0CJ;QAC9C;IACJ;IAQA,MAAMK,mBAAmBP,IAAI,WAAW,CAACM,uCAAAA,UAAAA,CAAAA,WAA0B,EAAE;QACjE,MAAM;QACN,QAAQ;YACJ,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,QAAQ;YACR,0CAA0CJ;QAC9C;IACJ;IAQA,MAAMM,gBAAgBR,IAAI,WAAW,CAACM,uCAAAA,UAAAA,CAAAA,WAA0B,EAAE;QAC9D,MAAM;QACN,QAAQ;YACJ,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,QAAQ;YACR,0CAA0C;gBACtC,0BAA0B;gBAC1B,4BAA4B;gBAC5B,eAAe;oBACX,gBAAgB;oBAChB,SAAS;wBACL,OAAO;+BACAH;+BACAC;4BACH;4BACA;yBACH;oBACL;gBACJ;gBACA,eAAe;oBAAE,gBAAgB;gBAAO;gBACxC,oBAAoB;oBAAE,qBAAqB;gBAAM;YACrD;QACJ;IACJ;IAEA,MAAMK,MAAMT,IAAI,WAAW,CAACM,uCAAAA,UAAAA,CAAAA,mBAAkC,EAAE;QAC5D,MAAM;QACN,QAAQ;YACJ,aAAa;YACb,+BAA+B;YAE/B,iBAAiB;YACjB,iBAAiB;QACrB;IACJ;IAEA,MAAMI,YAAoC,EAAE;IAC5C,KAAK,MAAMC,eAAe;QAAC;QAAY;KAAQ,CAC3CD,UAAU,IAAI,CAAC;QACX,UAAU;QACV,gBAAgBE;QAChB,eAAe;YAAC;YAAO;SAAO;QAC9B,eAAeP,eAAe,MAAM,CAAC,EAAE;QACvCM;QACA,sBAAsB;QACtB,gBAAgBE;IACpB;IAEJH,UAAU,IAAI,CAAC;QACX,UAAU;QACV,gBAAgBE;QAChB,eAAe;YAAC;YAAO;YAAQ;SAAU;QACzC,eAAeJ,cAAc,MAAM,CAAC,EAAE;QACtC,aAAa;QACb,sBAAsB;QACtB,gBAAgBK;IACpB;IAEA,MAAMC,SAA6B;QAC/B,YAAYb,WAAW,QAAQ,CAAC,MAAM,CAAC,UAAU;QACjD,UAAUY;QACV,uBAAuBJ,IAAI,MAAM,CAAC,EAAE;QACpC,oBAAoB;YAChB,UAAU;YACV,WAAW;YACX,sBAAsB;YACtB,oBAAoB;gBAAC;aAAU;YAC/B,mBAAmB;QACvB;IACJ;IAEA,OAAO;QAAEK;QAAQJ;QAAW,oBAAoBH,iBAAiB,MAAM,CAAC,EAAE;IAAC;AAC/E"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
1
2
|
import { type PulumiApp } from "@webiny/pulumi";
|
|
2
|
-
import type
|
|
3
|
+
import { type WithServiceManifest } from "../../../pulumi/utils/withServiceManifest.js";
|
|
3
4
|
export type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;
|
|
4
5
|
export declare const createApiPulumiApp: () => PulumiApp<{
|
|
5
6
|
fileManager: {
|
|
6
7
|
functions: {
|
|
7
8
|
download: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function.js").Function>;
|
|
8
9
|
};
|
|
10
|
+
functionUrl: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/functionUrl.js").FunctionUrl> | null;
|
|
9
11
|
};
|
|
10
12
|
graphql: {
|
|
11
13
|
role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role.js").Role>;
|
|
@@ -21,8 +23,17 @@ export declare const createApiPulumiApp: () => PulumiApp<{
|
|
|
21
23
|
graphqlStream: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function.js").Function>;
|
|
22
24
|
};
|
|
23
25
|
functionUrl: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/functionUrl.js").FunctionUrl>;
|
|
24
|
-
functionUrlDomain:
|
|
26
|
+
functionUrlDomain: pulumi.Output<string>;
|
|
25
27
|
};
|
|
28
|
+
graphqlWeb: {
|
|
29
|
+
fn: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambdaweb/function.js").Function>;
|
|
30
|
+
revision: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambdaweb/functionRevision.js").FunctionRevision>;
|
|
31
|
+
endpoint: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambdaweb/functionEndpoint.js").FunctionEndpoint>;
|
|
32
|
+
codeBucket: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/s3/bucket.js").Bucket>;
|
|
33
|
+
logGroup: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudwatch/logGroup.js").LogGroup>;
|
|
34
|
+
addRoute(routePath: string): void;
|
|
35
|
+
onRoute(listener: (routePath: string) => void): void;
|
|
36
|
+
} | undefined;
|
|
26
37
|
apiGateway: {
|
|
27
38
|
api: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api.js").Api>;
|
|
28
39
|
stage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage.js").Stage>;
|
|
@@ -32,7 +43,7 @@ export declare const createApiPulumiApp: () => PulumiApp<{
|
|
|
32
43
|
permission: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/permission.js").Permission>;
|
|
33
44
|
}>;
|
|
34
45
|
addRoute: (name: string, params: import("~/pulumi/apps/index.js").ApiRouteParams) => void;
|
|
35
|
-
};
|
|
46
|
+
} | undefined;
|
|
36
47
|
websocket: {
|
|
37
48
|
websocketApi: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api.js").Api>;
|
|
38
49
|
websocketApiStage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage.js").Stage>;
|
|
@@ -42,7 +53,7 @@ export declare const createApiPulumiApp: () => PulumiApp<{
|
|
|
42
53
|
websocketLambdaPermission: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/permission.js").Permission>;
|
|
43
54
|
lambdaWebsocketPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/policy.js").Policy>;
|
|
44
55
|
lambdaWebsocketRolePolicyAttachment: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicyAttachment.js").RolePolicyAttachment>;
|
|
45
|
-
websocketApiUrl:
|
|
56
|
+
websocketApiUrl: pulumi.Output<string>;
|
|
46
57
|
};
|
|
47
58
|
cloudfront: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cloudfront/distribution.js").Distribution>;
|
|
48
59
|
backgroundTask: {
|
|
@@ -59,4 +70,11 @@ export declare const createApiPulumiApp: () => PulumiApp<{
|
|
|
59
70
|
invokePolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicy.js").RolePolicy>;
|
|
60
71
|
policyAttachment: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicyAttachment.js").RolePolicyAttachment>;
|
|
61
72
|
};
|
|
73
|
+
schemaSetup: {
|
|
74
|
+
secretPolicy: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/rolePolicy.js").RolePolicy>;
|
|
75
|
+
functions: {
|
|
76
|
+
schemaSetup: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function.js").Function>;
|
|
77
|
+
};
|
|
78
|
+
invocation: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/invocation.js").Invocation>;
|
|
79
|
+
} | null;
|
|
62
80
|
}> & import("../lambdaUtils.js").WithCommonLambdaEnvVariables & WithServiceManifest;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import pick from "lodash/pick.js";
|
|
1
2
|
import { createPulumiApp, isResourceOfType } from "@webiny/pulumi";
|
|
2
|
-
import { ApiBackgroundTask, ApiCloudfront, ApiFileManager, ApiGateway, ApiGraphql, ApiGraphqlStream, ApiWebsocket, CoreOutput, VpcConfig } from "../index.js";
|
|
3
|
-
import { addDomainsUrlsOutputs,
|
|
3
|
+
import { ApiBackgroundTask, ApiCloudfront, ApiFileManager, ApiGateway, ApiGraphql, ApiGraphqlStream, ApiGraphqlWeb, ApiWebsocket, CoreOutput, VpcConfig } from "../index.js";
|
|
4
|
+
import { addDomainsUrlsOutputs, withCommonLambdaEnvVariables, withServiceManifest } from "../../utils/index.js";
|
|
4
5
|
import { getEnvVariableAwsRegion } from "../../env/awsRegion.js";
|
|
5
6
|
import { applyAwsResourceTags, getAwsAccountId } from "../awsUtils.js";
|
|
7
|
+
import { addServiceManifestTableItems } from "../../utils/withServiceManifest.js";
|
|
6
8
|
import { ApiScheduler } from "./ApiScheduler.js";
|
|
7
9
|
import { getAwsProjectSdk } from "../../getAwsProjectSdk.js";
|
|
8
10
|
import { getVpcConfigFromExtension } from "../extensions/getVpcConfigFromExtension.js";
|
|
9
11
|
import { isVpcEnabled } from "../extensions/isVpcEnabled.js";
|
|
12
|
+
import { isWebFunctionEnabled } from "../extensions/isWebFunctionEnabled.js";
|
|
10
13
|
import { getOsConfigFromExtension } from "../extensions/getOsConfigFromExtension.js";
|
|
14
|
+
import { getPostgresConfigFromExtension } from "../extensions/getPostgresConfigFromExtension.js";
|
|
15
|
+
import { projectUsesPostgres } from "../extensions/projectUsesPostgres.js";
|
|
16
|
+
import { ApiSchemaSetup, getPostgresLambdaEnvFromCore, getPostgresWebFunctionEnv, getSchemaSetupServiceManifests } from "./ApiSchemaSetup.js";
|
|
17
|
+
import { createApiServiceManifests } from "./apiServiceManifests.js";
|
|
18
|
+
import { addDynamoDbOutputs, getDynamoDbLambdaEnv } from "./apiDynamoDb.js";
|
|
11
19
|
import { handleGuardDutyEvents } from "./handleGuardDutyEvents.js";
|
|
12
20
|
import { ApiPulumi, SetApiCustomDomains } from "@webiny/project-extensions-aws/abstractions/features/pulumi/index.js";
|
|
13
21
|
import { apiPulumi } from "../../features/ApiPulumi/index.js";
|
|
@@ -15,6 +23,7 @@ import { DefaultSetApiCustomDomains } from "../../features/DefaultSetApiCustomDo
|
|
|
15
23
|
import { ApiCustomDomains } from "@webiny/project-extensions-aws/extensions/ApiCustomDomains.js";
|
|
16
24
|
import { applyCustomDomain } from "../customDomain.js";
|
|
17
25
|
import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
|
|
26
|
+
import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
|
|
18
27
|
const createApiPulumiApp = ()=>{
|
|
19
28
|
const baseApp = createPulumiApp({
|
|
20
29
|
name: "api",
|
|
@@ -25,6 +34,8 @@ const createApiPulumiApp = ()=>{
|
|
|
25
34
|
const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();
|
|
26
35
|
const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);
|
|
27
36
|
const openSearchExtensionConfig = getOsConfigFromExtension(projectConfig);
|
|
37
|
+
const postgresConfig = getPostgresConfigFromExtension(projectConfig);
|
|
38
|
+
const usesPostgres = Boolean(postgresConfig);
|
|
28
39
|
let searchEngineParams = null;
|
|
29
40
|
if (openSearchExtensionConfig) searchEngineParams = openSearchExtensionConfig;
|
|
30
41
|
if (searchEngineParams) {
|
|
@@ -74,15 +85,15 @@ const createApiPulumiApp = ()=>{
|
|
|
74
85
|
app.addHandler(()=>pulumiHandlers.execute(app));
|
|
75
86
|
const isProduction = app.env.isProduction;
|
|
76
87
|
const core = app.addModule(CoreOutput);
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
const vpcEnabled = isVpcEnabled(vpcExtensionsConfig, isProduction);
|
|
89
|
+
const vpcConfig = app.addModule(VpcConfig, {
|
|
90
|
+
enabled: vpcEnabled
|
|
79
91
|
});
|
|
92
|
+
const dynamoDbEnv = getDynamoDbLambdaEnv(core, usesPostgres);
|
|
80
93
|
const graphqlEnv = {
|
|
81
94
|
COGNITO_REGION: getEnvVariableAwsRegion(),
|
|
82
95
|
COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
|
|
83
|
-
|
|
84
|
-
DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName,
|
|
85
|
-
DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName,
|
|
96
|
+
...dynamoDbEnv,
|
|
86
97
|
OPENSEARCH_ENDPOINT: core.opensearchDomainEndpoint,
|
|
87
98
|
OPENSEARCH_INDEX_PREFIX: process.env.OPENSEARCH_INDEX_PREFIX,
|
|
88
99
|
OPENSEARCH_SHARED_INDEXES: process.env.OPENSEARCH_SHARED_INDEXES,
|
|
@@ -90,7 +101,8 @@ const createApiPulumiApp = ()=>{
|
|
|
90
101
|
OPENSEARCH_PASSWORD: process.env.OPENSEARCH_PASSWORD,
|
|
91
102
|
S3_BUCKET: core.fileManagerBucketId,
|
|
92
103
|
EVENT_BUS: core.eventBusArn,
|
|
93
|
-
OKTA_ISSUER: process.env["OKTA_ISSUER"]
|
|
104
|
+
OKTA_ISSUER: process.env["OKTA_ISSUER"],
|
|
105
|
+
...usesPostgres ? getPostgresLambdaEnvFromCore(core) : {}
|
|
94
106
|
};
|
|
95
107
|
const graphql = app.addModule(ApiGraphql, {
|
|
96
108
|
env: graphqlEnv
|
|
@@ -98,63 +110,53 @@ const createApiPulumiApp = ()=>{
|
|
|
98
110
|
const graphqlStream = app.addModule(ApiGraphqlStream, {
|
|
99
111
|
env: graphqlEnv
|
|
100
112
|
});
|
|
113
|
+
const webFunctionEnabled = isWebFunctionEnabled(projectConfig);
|
|
114
|
+
let graphqlWeb;
|
|
115
|
+
if (webFunctionEnabled) {
|
|
116
|
+
let graphqlWebVpc = null;
|
|
117
|
+
const useExistingVpc = "object" == typeof vpcExtensionsConfig && vpcExtensionsConfig.useExistingVpc;
|
|
118
|
+
if (useExistingVpc) graphqlWebVpc = useExistingVpc.lambdaFunctionsVpcConfig;
|
|
119
|
+
else if (vpcEnabled) {
|
|
120
|
+
const functionVpcConfig = vpcConfig.functionVpcConfig;
|
|
121
|
+
const subnetIds = __rspack_external__pulumi_pulumi_f3e773ed.output(functionVpcConfig.subnetIds);
|
|
122
|
+
const securityGroupIds = __rspack_external__pulumi_pulumi_f3e773ed.output(functionVpcConfig.securityGroupIds);
|
|
123
|
+
graphqlWebVpc = {
|
|
124
|
+
subnetIds,
|
|
125
|
+
securityGroupIds
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
graphqlWeb = app.addModule(ApiGraphqlWeb, {
|
|
129
|
+
namePrefix: pulumiResourceNamePrefix ?? "",
|
|
130
|
+
vpc: graphqlWebVpc,
|
|
131
|
+
env: getPostgresWebFunctionEnv(postgresConfig)
|
|
132
|
+
});
|
|
133
|
+
app.addOutputs({
|
|
134
|
+
graphqlWebFunctionName: graphqlWeb.fn.output.functionName,
|
|
135
|
+
graphqlWebEndpointDomain: graphqlWeb.endpoint.output.domainName,
|
|
136
|
+
graphqlWebEndpointName: graphqlWeb.endpoint.output.endpointName,
|
|
137
|
+
graphqlWebCodeBucket: graphqlWeb.codeBucket.output.id
|
|
138
|
+
});
|
|
139
|
+
}
|
|
101
140
|
const websocket = app.addModule(ApiWebsocket);
|
|
102
141
|
const fileManager = app.addModule(ApiFileManager, {
|
|
103
|
-
env:
|
|
104
|
-
DB_TABLE
|
|
105
|
-
DB_TABLE_AUDIT_LOGS
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const apiGateway = app.addModule(ApiGateway, {
|
|
109
|
-
"graphql-post": {
|
|
110
|
-
path: "/graphql",
|
|
111
|
-
method: "POST",
|
|
112
|
-
function: graphql.functions.graphql.output.arn
|
|
113
|
-
},
|
|
114
|
-
"graphql-options": {
|
|
115
|
-
path: "/graphql",
|
|
116
|
-
method: "OPTIONS",
|
|
117
|
-
function: graphql.functions.graphql.output.arn
|
|
118
|
-
},
|
|
119
|
-
"files-any": {
|
|
120
|
-
path: "/files/{path+}",
|
|
121
|
-
method: "ANY",
|
|
122
|
-
function: fileManager.functions.download.output.arn
|
|
123
|
-
},
|
|
124
|
-
"private-any": {
|
|
125
|
-
path: "/private/{path+}",
|
|
126
|
-
method: "ANY",
|
|
127
|
-
function: fileManager.functions.download.output.arn
|
|
128
|
-
},
|
|
129
|
-
"cms-post": {
|
|
130
|
-
path: "/cms/{key+}",
|
|
131
|
-
method: "POST",
|
|
132
|
-
function: graphql.functions.graphql.output.arn
|
|
133
|
-
},
|
|
134
|
-
"cms-options": {
|
|
135
|
-
path: "/cms/{key+}",
|
|
136
|
-
method: "OPTIONS",
|
|
137
|
-
function: graphql.functions.graphql.output.arn
|
|
138
|
-
},
|
|
139
|
-
"redirects-get": {
|
|
140
|
-
path: "/wb/redirects",
|
|
141
|
-
method: "GET",
|
|
142
|
-
function: graphql.functions.graphql.output.arn
|
|
143
|
-
},
|
|
144
|
-
"redirects-options": {
|
|
145
|
-
path: "/wb/redirects",
|
|
146
|
-
method: "OPTIONS",
|
|
147
|
-
function: graphql.functions.graphql.output.arn
|
|
148
|
-
},
|
|
149
|
-
"files-catch-all": {
|
|
150
|
-
path: "/{path+}",
|
|
151
|
-
method: "ANY",
|
|
152
|
-
function: fileManager.functions.download.output.arn
|
|
153
|
-
}
|
|
142
|
+
env: pick(dynamoDbEnv, [
|
|
143
|
+
"DB_TABLE",
|
|
144
|
+
"DB_TABLE_AUDIT_LOGS"
|
|
145
|
+
]),
|
|
146
|
+
functionUrl: webFunctionEnabled
|
|
154
147
|
});
|
|
148
|
+
let apiGateway;
|
|
149
|
+
if (!webFunctionEnabled) apiGateway = createApiGateway(app, graphql, fileManager);
|
|
155
150
|
const cloudfront = app.addModule(ApiCloudfront);
|
|
156
151
|
const backgroundTask = app.addModule(ApiBackgroundTask);
|
|
157
152
|
const scheduler = app.addModule(ApiScheduler);
|
|
153
|
+
const schemaSetup = usesPostgres ? app.addModule(ApiSchemaSetup, {
|
|
154
|
+
postgres: core,
|
|
155
|
+
serviceManifests: __rspack_external__pulumi_pulumi_f3e773ed.all([
|
|
156
|
+
core.serviceManifests,
|
|
157
|
+
app.getServiceManifests()
|
|
158
|
+
]).apply(([coreManifests, apiManifests])=>getSchemaSetupServiceManifests(coreManifests, apiManifests))
|
|
159
|
+
}) : null;
|
|
158
160
|
const [apiCustomDomains] = projectConfig.extensionsByType(ApiCustomDomains);
|
|
159
161
|
if (apiCustomDomains) {
|
|
160
162
|
const { domains, sslMethod, certificateArn, minimumProtocolVersion } = apiCustomDomains.params;
|
|
@@ -171,8 +173,6 @@ const createApiPulumiApp = ()=>{
|
|
|
171
173
|
cognitoUserPoolId: core.cognitoUserPoolId,
|
|
172
174
|
cognitoAppClientId: core.cognitoAppClientId,
|
|
173
175
|
cognitoUserPoolPasswordPolicy: core.cognitoUserPoolPasswordPolicy,
|
|
174
|
-
dynamoDbTable: core.primaryDynamodbTableName,
|
|
175
|
-
auditLogsDynamoDbTable: core.auditLogsDynamodbTableName,
|
|
176
176
|
graphqlLambdaName: graphql.functions.graphql.output.name,
|
|
177
177
|
graphqlLambdaRole: graphql.role.output.arn,
|
|
178
178
|
graphqlLambdaRoleName: graphql.role.output.name,
|
|
@@ -185,6 +185,10 @@ const createApiPulumiApp = ()=>{
|
|
|
185
185
|
websocketApiUrl: websocket.websocketApiUrl,
|
|
186
186
|
schedulerLambdaInvokeRole: scheduler.invokeRole.output.arn
|
|
187
187
|
});
|
|
188
|
+
addDynamoDbOutputs(app, core, usesPostgres);
|
|
189
|
+
if (schemaSetup) app.addOutputs({
|
|
190
|
+
schemaSetupLambdaArn: schemaSetup.functions.schemaSetup.output.arn
|
|
191
|
+
});
|
|
188
192
|
if (searchEngineParams) app.addOutputs({
|
|
189
193
|
dynamoDbOpensearchTable: core.opensearchDynamodbTableName
|
|
190
194
|
});
|
|
@@ -205,37 +209,74 @@ const createApiPulumiApp = ()=>{
|
|
|
205
209
|
fileManager,
|
|
206
210
|
graphql,
|
|
207
211
|
graphqlStream,
|
|
212
|
+
graphqlWeb,
|
|
208
213
|
apiGateway,
|
|
209
214
|
websocket,
|
|
210
215
|
cloudfront,
|
|
211
216
|
backgroundTask,
|
|
212
|
-
scheduler
|
|
217
|
+
scheduler,
|
|
218
|
+
schemaSetup
|
|
213
219
|
};
|
|
214
220
|
}
|
|
215
221
|
});
|
|
216
|
-
const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp))
|
|
222
|
+
const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp), async (manifests)=>{
|
|
223
|
+
if (await projectUsesPostgres()) return;
|
|
224
|
+
addServiceManifestTableItems(baseApp, manifests);
|
|
225
|
+
});
|
|
217
226
|
app.addHandler(()=>{
|
|
218
|
-
app.addServiceManifest(
|
|
219
|
-
name: "api",
|
|
220
|
-
manifest: {
|
|
221
|
-
url: getDistributionUrl(baseApp.resources.cloudfront),
|
|
222
|
-
bgTaskSfn: baseApp.resources.backgroundTask.stepFunction.output.arn,
|
|
223
|
-
cloudfront: {
|
|
224
|
-
distributionId: baseApp.resources.cloudfront.output.id,
|
|
225
|
-
domain: baseApp.resources.cloudfront.output.domainName.apply((v)=>`https://${v}`)
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
app.addServiceManifest({
|
|
230
|
-
name: "scheduler",
|
|
231
|
-
manifest: {
|
|
232
|
-
lambdaArn: baseApp.resources.graphql.functions.graphql.output.arn,
|
|
233
|
-
roleArn: baseApp.resources.scheduler.invokeRole.output.arn
|
|
234
|
-
}
|
|
235
|
-
});
|
|
227
|
+
for (const manifest of createApiServiceManifests(baseApp.resources))app.addServiceManifest(manifest);
|
|
236
228
|
});
|
|
237
229
|
return app;
|
|
238
230
|
};
|
|
231
|
+
function createApiGateway(app, graphql, fileManager) {
|
|
232
|
+
return app.addModule(ApiGateway, {
|
|
233
|
+
"graphql-post": {
|
|
234
|
+
path: "/graphql",
|
|
235
|
+
method: "POST",
|
|
236
|
+
function: graphql.functions.graphql.output.arn
|
|
237
|
+
},
|
|
238
|
+
"graphql-options": {
|
|
239
|
+
path: "/graphql",
|
|
240
|
+
method: "OPTIONS",
|
|
241
|
+
function: graphql.functions.graphql.output.arn
|
|
242
|
+
},
|
|
243
|
+
"files-any": {
|
|
244
|
+
path: "/files/{path+}",
|
|
245
|
+
method: "ANY",
|
|
246
|
+
function: fileManager.functions.download.output.arn
|
|
247
|
+
},
|
|
248
|
+
"private-any": {
|
|
249
|
+
path: "/private/{path+}",
|
|
250
|
+
method: "ANY",
|
|
251
|
+
function: fileManager.functions.download.output.arn
|
|
252
|
+
},
|
|
253
|
+
"cms-post": {
|
|
254
|
+
path: "/cms/{key+}",
|
|
255
|
+
method: "POST",
|
|
256
|
+
function: graphql.functions.graphql.output.arn
|
|
257
|
+
},
|
|
258
|
+
"cms-options": {
|
|
259
|
+
path: "/cms/{key+}",
|
|
260
|
+
method: "OPTIONS",
|
|
261
|
+
function: graphql.functions.graphql.output.arn
|
|
262
|
+
},
|
|
263
|
+
"redirects-get": {
|
|
264
|
+
path: "/wb/redirects",
|
|
265
|
+
method: "GET",
|
|
266
|
+
function: graphql.functions.graphql.output.arn
|
|
267
|
+
},
|
|
268
|
+
"redirects-options": {
|
|
269
|
+
path: "/wb/redirects",
|
|
270
|
+
method: "OPTIONS",
|
|
271
|
+
function: graphql.functions.graphql.output.arn
|
|
272
|
+
},
|
|
273
|
+
"files-catch-all": {
|
|
274
|
+
path: "/{path+}",
|
|
275
|
+
method: "ANY",
|
|
276
|
+
function: fileManager.functions.download.output.arn
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
239
280
|
export { createApiPulumiApp };
|
|
240
281
|
|
|
241
282
|
//# sourceMappingURL=createApiPulumiApp.js.map
|