@webiny/project-aws 6.6.0-alpha.12 → 6.6.0-alpha.14
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 +1 -1
- package/_templates/extensions/OpenSearch/api/graphql/src/index.ts +2 -2
- package/_templates/extensions/OpenSearch/api/graphql/src/web.ts +1 -1
- package/_templates/extensions/Postgres/api/graphql/src/index.ts +3 -6
- package/_templates/extensions/Postgres/api/graphql/src/web.ts +1 -1
- package/_templates/extensions/TenantStorages/ddb/api/graphql/src/index.ts +25 -0
- package/_templates/extensions/TenantStorages/ddb/api/graphql/src/web.ts +17 -0
- package/_templates/extensions/TenantStorages/ddb-os/api/graphql/src/index.ts +25 -0
- package/_templates/extensions/TenantStorages/ddb-os/api/graphql/src/web.ts +17 -0
- package/_templates/extensions/TenantStorages/pg/api/graphql/src/index.ts +25 -0
- package/_templates/extensions/TenantStorages/pg/api/graphql/src/web.ts +16 -0
- package/api.d.ts +6 -6
- package/api.js +3 -2
- package/api.js.map +1 -1
- package/decorators/GetPulumiServiceWithDownloadInfo.d.ts +1 -3
- package/decorators/GetPulumiServiceWithDownloadInfo.js +15 -11
- package/decorators/GetPulumiServiceWithDownloadInfo.js.map +1 -1
- package/extensions/AuroraPostgresCluster.d.ts +12 -0
- package/extensions/{Postgres.js → AuroraPostgresCluster.js} +7 -7
- package/extensions/AuroraPostgresCluster.js.map +1 -0
- package/extensions/OpenSearch/ReplaceApiLambdaFnHandlers.d.ts +3 -2
- package/extensions/OpenSearch/ReplaceApiLambdaFnHandlers.js +7 -3
- package/extensions/OpenSearch/ReplaceApiLambdaFnHandlers.js.map +1 -1
- package/extensions/Postgres/AddCorePostgres.d.ts +1 -1
- package/extensions/Postgres/AddCorePostgres.js +0 -2
- package/extensions/Postgres/AddCorePostgres.js.map +1 -1
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.d.ts +4 -3
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.js.map +1 -1
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.d.ts +6 -5
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js +6 -2
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js.map +1 -1
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.d.ts +1 -1
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js +8 -10
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js.map +1 -1
- package/extensions/Postgres/assertPostgresNetwork.d.ts +19 -0
- package/extensions/Postgres/assertPostgresNetwork.js +16 -0
- package/extensions/Postgres/assertPostgresNetwork.js.map +1 -0
- package/extensions/Postgres/copyPgRuntimeModules.d.ts +1 -1
- package/extensions/Postgres/copyPgRuntimeModules.js +2 -2
- package/extensions/Postgres/copyPgRuntimeModules.js.map +1 -1
- package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.d.ts +17 -2
- package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js +26 -19
- package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js.map +1 -1
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.d.ts +2 -2
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.js +1 -1
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.js.map +1 -1
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.d.ts +3 -3
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.js +1 -1
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.js.map +1 -1
- package/extensions/ProjectAws/TenantStorages/AddTenantStorages.d.ts +34 -0
- package/extensions/ProjectAws/TenantStorages/AddTenantStorages.js +55 -0
- package/extensions/ProjectAws/TenantStorages/AddTenantStorages.js.map +1 -0
- package/extensions/ProjectAws/TenantStorages/ApplyTenantStoragesApiEntry.d.ts +26 -0
- package/extensions/ProjectAws/TenantStorages/ApplyTenantStoragesApiEntry.js +49 -0
- package/extensions/ProjectAws/TenantStorages/ApplyTenantStoragesApiEntry.js.map +1 -0
- package/extensions/ProjectAws/TenantStorages/CopyPgModulesForTenantStorages.d.ts +17 -0
- package/extensions/ProjectAws/TenantStorages/CopyPgModulesForTenantStorages.js +26 -0
- package/extensions/ProjectAws/TenantStorages/CopyPgModulesForTenantStorages.js.map +1 -0
- package/extensions/ProjectAws/TenantStorages/EnsureStoragesNotRemoved.d.ts +41 -0
- package/extensions/ProjectAws/TenantStorages/EnsureStoragesNotRemoved.js +55 -0
- package/extensions/ProjectAws/TenantStorages/EnsureStoragesNotRemoved.js.map +1 -0
- package/extensions/ProjectAws/TenantStorages/ValidateTenantStoragesBeforeCoreDeploy.d.ts +48 -0
- package/extensions/ProjectAws/TenantStorages/ValidateTenantStoragesBeforeCoreDeploy.js +78 -0
- package/extensions/ProjectAws/TenantStorages/ValidateTenantStoragesBeforeCoreDeploy.js.map +1 -0
- package/extensions/ProjectAws.js +11 -1
- package/extensions/ProjectAws.js.map +1 -1
- package/extensions/definitions.js +2 -4
- package/extensions/definitions.js.map +1 -1
- package/extensions/index.d.ts +3 -3
- package/extensions/index.js +3 -4
- package/extensions/registerExtensionImplementations.js +3 -5
- package/extensions/registerExtensionImplementations.js.map +1 -1
- package/infra.d.ts +13 -8
- package/infra.js +9 -10
- package/infra.js.map +1 -1
- package/package.json +19 -18
- package/project.d.ts +4 -2
- package/pulumi/apps/admin/createAdminPulumiApp.js.map +1 -1
- package/pulumi/apps/api/ApiGraphql.js.map +1 -1
- package/pulumi/apps/api/ApiGraphqlWeb.js.map +1 -1
- package/pulumi/apps/api/ApiOutput.js.map +1 -1
- package/pulumi/apps/api/ApiSchemaSetup.d.ts +35 -13
- package/pulumi/apps/api/ApiSchemaSetup.js +31 -8
- package/pulumi/apps/api/ApiSchemaSetup.js.map +1 -1
- package/pulumi/apps/api/apiDynamoDb.js.map +1 -1
- package/pulumi/apps/api/backgroundTask/types.js.map +1 -1
- package/pulumi/apps/api/createApiPulumiApp.js +14 -7
- package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
- package/pulumi/apps/common/CoreOutput.d.ts +11 -0
- package/pulumi/apps/common/CoreOutput.js +2 -1
- 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/CorePostgres.d.ts +6 -4
- package/pulumi/apps/core/CorePostgres.js +26 -20
- package/pulumi/apps/core/CorePostgres.js.map +1 -1
- 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 +2 -2
- package/pulumi/apps/core/coreDynamoDb.js.map +1 -1
- package/pulumi/apps/core/coreServiceManifests.d.ts +6 -4
- package/pulumi/apps/core/coreServiceManifests.js.map +1 -1
- package/pulumi/apps/core/coreVpcEndpoints.d.ts +9 -2
- package/pulumi/apps/core/coreVpcEndpoints.js +15 -11
- package/pulumi/apps/core/coreVpcEndpoints.js.map +1 -1
- package/pulumi/apps/core/createCorePulumiApp.js +8 -1
- package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.d.ts +4 -2
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.js +4 -3
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.js.map +1 -1
- package/pulumi/apps/extensions/getTenantStoragesFromExtension.d.ts +19 -0
- package/pulumi/apps/extensions/getTenantStoragesFromExtension.js +32 -0
- package/pulumi/apps/extensions/getTenantStoragesFromExtension.js.map +1 -0
- package/pulumi/apps/extensions/projectUsesPostgres.d.ts +1 -1
- package/pulumi/apps/extensions/projectUsesPostgres.js.map +1 -1
- package/pulumi/apps/react/adminSettingsItem.d.ts +1 -1
- package/pulumi/apps/react/adminSettingsItem.js.map +1 -1
- package/pulumi/apps/react/createReactPulumiApp.js.map +1 -1
- package/pulumi/extensions/index.d.ts +8 -0
- package/pulumi/extensions/index.js +2 -1
- package/pulumi/extensions/index.js.map +1 -1
- package/pulumi/types.d.ts +2 -2
- package/pulumi/utils/lambdaEnvVariables.js +2 -2
- package/pulumi/utils/lambdaEnvVariables.js.map +1 -1
- package/pulumi/utils/withServiceManifest.d.ts +2 -2
- package/pulumi/utils/withServiceManifest.js.map +1 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js +1 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js.map +1 -1
- package/extensions/Postgres.d.ts +0 -11
- package/extensions/Postgres.js.map +0 -1
- package/extensions/RdsProxy/EnsurePostgresWithRdsProxy.d.ts +0 -14
- package/extensions/RdsProxy/EnsurePostgresWithRdsProxy.js +0 -23
- package/extensions/RdsProxy/EnsurePostgresWithRdsProxy.js.map +0 -1
- package/extensions/RdsProxy.d.ts +0 -9
- package/extensions/RdsProxy.js +0 -31
- package/extensions/RdsProxy.js.map +0 -1
- package/pulumi/apps/extensions/getRdsProxyConfigFromExtension.d.ts +0 -5
- package/pulumi/apps/extensions/getRdsProxyConfigFromExtension.js +0 -8
- package/pulumi/apps/extensions/getRdsProxyConfigFromExtension.js.map +0 -1
|
@@ -24,7 +24,7 @@ const getPostgresLambdaEnv = (pg)=>{
|
|
|
24
24
|
"pgUser",
|
|
25
25
|
"pgSecretArn"
|
|
26
26
|
].filter((name)=>!pg[name]);
|
|
27
|
-
if (missing.length) throw new Error(`The core app has no Postgres database (missing outputs: ${missing.join(", ")}). Deploy the core app with \`<Infra.
|
|
27
|
+
if (missing.length) throw new Error(`The core app has no Postgres database (missing outputs: ${missing.join(", ")}). Deploy the core app with \`<Infra.AuroraPostgres />\` first: \`yarn webiny deploy core\`.`);
|
|
28
28
|
return {
|
|
29
29
|
WEBINY_PG_HOST: pg.pgProxyHost || pg.pgWriterHost,
|
|
30
30
|
WEBINY_PG_WRITER_HOST: pg.pgWriterHost,
|
|
@@ -50,7 +50,22 @@ const getPostgresWebFunctionEnv = (postgres)=>{
|
|
|
50
50
|
NODE_EXTRA_CA_CERTS: WEB_FUNCTION_RDS_CA_CERTS
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
const
|
|
53
|
+
const TENANT_STORAGES_ENV = "WEBINY_TENANT_STORAGES";
|
|
54
|
+
const getTenantStoragesLambdaEnv = (storages)=>JSON.stringify(storages.map((storage)=>{
|
|
55
|
+
const { NODE_EXTRA_CA_CERTS, ...connection } = getPostgresLambdaEnv(storage);
|
|
56
|
+
return {
|
|
57
|
+
id: storage.id,
|
|
58
|
+
label: storage.label,
|
|
59
|
+
retired: true === storage.retired,
|
|
60
|
+
type: "postgres",
|
|
61
|
+
connection
|
|
62
|
+
};
|
|
63
|
+
}));
|
|
64
|
+
const getTenantStoragesLambdaEnvFromCore = (core)=>({
|
|
65
|
+
[TENANT_STORAGES_ENV]: core.apply(({ storages })=>getTenantStoragesLambdaEnv(storages ?? [])),
|
|
66
|
+
NODE_EXTRA_CA_CERTS: LAMBDA_RDS_CA_CERTS
|
|
67
|
+
});
|
|
68
|
+
const createPostgresSecretPolicy = (secretArns)=>({
|
|
54
69
|
Version: "2012-10-17",
|
|
55
70
|
Statement: [
|
|
56
71
|
{
|
|
@@ -59,8 +74,8 @@ const createPostgresSecretPolicy = (secretArn)=>({
|
|
|
59
74
|
Action: [
|
|
60
75
|
"secretsmanager:GetSecretValue"
|
|
61
76
|
],
|
|
62
|
-
Resource: [
|
|
63
|
-
|
|
77
|
+
Resource: Array.isArray(secretArns) ? secretArns : [
|
|
78
|
+
secretArns
|
|
64
79
|
]
|
|
65
80
|
}
|
|
66
81
|
]
|
|
@@ -92,9 +107,17 @@ const ApiSchemaSetup = createAppModule({
|
|
|
92
107
|
name: "api-lambda-pg-secret",
|
|
93
108
|
config: {
|
|
94
109
|
role: graphql.role.output.id,
|
|
95
|
-
policy:
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
policy: __rspack_external__pulumi_pulumi_f3e773ed.all([
|
|
111
|
+
params.postgres,
|
|
112
|
+
params.tenantStorages
|
|
113
|
+
]).apply(([postgres, storages])=>{
|
|
114
|
+
const arns = [
|
|
115
|
+
...postgres ? [
|
|
116
|
+
getPostgresLambdaEnv(postgres).WEBINY_PG_SECRET_ARN
|
|
117
|
+
] : [],
|
|
118
|
+
...(storages ?? []).map((storage)=>getPostgresLambdaEnv(storage).WEBINY_PG_SECRET_ARN)
|
|
119
|
+
];
|
|
120
|
+
return JSON.stringify(createPostgresSecretPolicy(arns));
|
|
98
121
|
})
|
|
99
122
|
}
|
|
100
123
|
});
|
|
@@ -134,6 +157,6 @@ const ApiSchemaSetup = createAppModule({
|
|
|
134
157
|
};
|
|
135
158
|
}
|
|
136
159
|
});
|
|
137
|
-
export { ApiSchemaSetup, ApiSchemaSetupLambdaName, SQL_SCHEMA_SETUP_EVENT, createPostgresSecretPolicy, createSchemaSetupEvent, getPostgresLambdaEnv, getPostgresLambdaEnvFromCore, getPostgresWebFunctionEnv, getSchemaSetupServiceManifests };
|
|
160
|
+
export { ApiSchemaSetup, ApiSchemaSetupLambdaName, SQL_SCHEMA_SETUP_EVENT, TENANT_STORAGES_ENV, createPostgresSecretPolicy, createSchemaSetupEvent, getPostgresLambdaEnv, getPostgresLambdaEnvFromCore, getPostgresWebFunctionEnv, getSchemaSetupServiceManifests, getTenantStoragesLambdaEnv, getTenantStoragesLambdaEnvFromCore };
|
|
138
161
|
|
|
139
162
|
//# sourceMappingURL=ApiSchemaSetup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/ApiSchemaSetup.js","sources":["../../../../src/pulumi/apps/api/ApiSchemaSetup.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport type { PostgresOutputs } from \"~/pulumi/apps/common/CoreOutput.js\";\nimport type { PostgresExtensionConfig } from \"~/pulumi/apps/extensions/getPostgresConfigFromExtension.js\";\nimport type { ServiceManifest } from \"~/pulumi/utils/addServiceManifestTableItem.js\";\nimport { WEB_FUNCTION_RDS_CA_CERTS } from \"~/extensions/Postgres/rdsCaBundle.js\";\nimport { ApiGraphql } from \"./ApiGraphql.js\";\n\n/* The event `@webiny/api-event-handler-aws-pg` answers with the schema setup. */\nexport const SQL_SCHEMA_SETUP_EVENT = \"WebinySqlSchemaSetup\";\n\nexport const ApiSchemaSetupLambdaName = \"schema-setup\";\n\n/* The CA bundle of the Lambda Node.js runtime, which has the Amazon RDS certificates. */\nconst LAMBDA_RDS_CA_CERTS = \"/var/runtime/ca-cert.pem\";\n\nconst POSTGRES_DEFAULT_PORT = 5432;\n\nexport interface PostgresLambdaEnv {\n WEBINY_PG_HOST: string;\n WEBINY_PG_WRITER_HOST: string;\n WEBINY_PG_PORT: string;\n WEBINY_PG_DATABASE: string;\n WEBINY_PG_USER: string;\n WEBINY_PG_SECRET_ARN: string;\n WEBINY_PG_SSL: string;\n NODE_EXTRA_CA_CERTS: string;\n}\n\nconst POSTGRES_LAMBDA_ENV_NAMES: Array<keyof PostgresLambdaEnv> = [\n \"WEBINY_PG_HOST\",\n \"WEBINY_PG_WRITER_HOST\",\n \"WEBINY_PG_PORT\",\n \"WEBINY_PG_DATABASE\",\n \"WEBINY_PG_USER\",\n \"WEBINY_PG_SECRET_ARN\",\n \"WEBINY_PG_SSL\",\n \"NODE_EXTRA_CA_CERTS\"\n];\n\n/**\n * The env vars an API function connects to Postgres with, from the core stack's Postgres outputs.\n * The API goes through the RDS Proxy when the core has one, else to the cluster's writer; the schema\n * setup always goes to the writer (`WEBINY_PG_WRITER_HOST`). Over TLS, verified against the RDS\n * certificates of the Lambda runtime. No password: the functions read it from the secret.\n *\n * Throws when the core stack has no Postgres database, which is the case until `deploy core` runs\n * with `<Infra.Postgres />`.\n */\nexport const getPostgresLambdaEnv = (pg: PostgresOutputs): PostgresLambdaEnv => {\n const missing = ([\"pgWriterHost\", \"pgDatabase\", \"pgUser\", \"pgSecretArn\"] as const).filter(\n name => !pg[name]\n );\n if (missing.length) {\n throw new Error(\n `The core app has no Postgres database (missing outputs: ${missing.join(\", \")}). ` +\n \"Deploy the core app with `<Infra.Postgres />` first: `yarn webiny deploy core`.\"\n );\n }\n\n return {\n WEBINY_PG_HOST: (pg.pgProxyHost || pg.pgWriterHost) as string,\n WEBINY_PG_WRITER_HOST: pg.pgWriterHost as string,\n WEBINY_PG_PORT: String(pg.pgPort || POSTGRES_DEFAULT_PORT),\n WEBINY_PG_DATABASE: pg.pgDatabase as string,\n WEBINY_PG_USER: pg.pgUser as string,\n WEBINY_PG_SECRET_ARN: pg.pgSecretArn as string,\n WEBINY_PG_SSL: \"true\",\n NODE_EXTRA_CA_CERTS: LAMBDA_RDS_CA_CERTS\n };\n};\n\n/**\n * {@link getPostgresLambdaEnv} for the core stack's output, one Pulumi output per env var, so it can\n * be spread into a function's env next to the other variables.\n */\nexport const getPostgresLambdaEnvFromCore = (\n core: pulumi.Output<PostgresOutputs>\n): Record<keyof PostgresLambdaEnv, pulumi.Output<string>> => {\n const env = core.apply(getPostgresLambdaEnv);\n return Object.fromEntries(\n POSTGRES_LAMBDA_ENV_NAMES.map(name => [name, env.apply(values => values[name])])\n ) as Record<keyof PostgresLambdaEnv, pulumi.Output<string>>;\n};\n\n/**\n * Env only the API's web function gets, on top of the `graphql` Lambda's (and over it), with\n * `<Infra.Postgres />`. Nothing without Postgres.\n *\n * - `WEBINY_PG_POOL_MAX`: its pool size. One web function environment serves several requests at\n * once, so it needs more than the 1 connection the plain Lambda functions keep.\n * - `NODE_EXTRA_CA_CERTS`: the RDS CA bundle shipped in its code. Its runtime has no\n * `/var/runtime/ca-cert.pem`, the bundle the plain Lambda functions verify the database with.\n */\nexport const getPostgresWebFunctionEnv = (\n postgres: Pick<PostgresExtensionConfig, \"poolSize\"> | undefined\n): Record<string, string> => {\n if (!postgres) {\n return {};\n }\n return {\n WEBINY_PG_POOL_MAX: String(postgres.poolSize),\n NODE_EXTRA_CA_CERTS: WEB_FUNCTION_RDS_CA_CERTS\n };\n};\n\n/* Lets the API functions read the database password, and nothing else, from the core's secret. */\nexport const createPostgresSecretPolicy = (secretArn: string): aws.iam.PolicyDocument => {\n return {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForPostgresSecret\",\n Effect: \"Allow\",\n Action: [\"secretsmanager:GetSecretValue\"],\n Resource: [secretArn]\n }\n ]\n };\n};\n\n/* The event the deploy invokes the schema-setup function with. */\nexport const createSchemaSetupEvent = (serviceManifests: ServiceManifest[]) => {\n return {\n [SQL_SCHEMA_SETUP_EVENT]: {\n serviceManifests: serviceManifests.map(({ name, manifest }) => ({ name, manifest }))\n }\n };\n};\n\n/**\n * The manifests the api deploy stores: the core's (from the core stack output; the core deploys\n * before this function exists), then the api app's own. On a repeated name the api's own wins.\n *\n * Throws when the core stack has no service manifests: a core deployed before the core put them\n * in its output. Its `core` manifest would never reach the database.\n */\nexport const getSchemaSetupServiceManifests = (\n coreManifests: ServiceManifest[] | undefined,\n apiManifests: ServiceManifest[]\n): ServiceManifest[] => {\n if (!coreManifests) {\n throw new Error(\n \"The core app's stack output has no service manifests, which the api deploy stores \" +\n \"in the database. Deploy the core app again: `yarn webiny deploy core`.\"\n );\n }\n\n const byName = new Map<string, ServiceManifest>();\n for (const manifest of [...coreManifests, ...apiManifests]) {\n byName.set(manifest.name, manifest);\n }\n return [...byName.values()];\n};\n\nexport interface ApiSchemaSetupParams {\n /* The core stack's Postgres outputs. */\n postgres: pulumi.Output<PostgresOutputs>;\n /* Stored in the database by the setup, for service discovery. */\n serviceManifests: pulumi.Input<ServiceManifest[]>;\n /* Changes on every deploy, so every deploy runs the setup. Replaced in tests. */\n trigger?: string;\n}\n\nexport type ApiSchemaSetup = PulumiAppModule<typeof ApiSchemaSetup>;\n\n/**\n * The API on Postgres, at deploy time:\n * - lets the API role read the database password from the core's secret;\n * - adds the `schema-setup` function: the GraphQL function's bundle, role, env and VPC, with time\n * for the setup and no route to it;\n * - invokes it on every deploy with the `WebinySqlSchemaSetup` event. A failed setup fails the\n * deploy, so the schema is in place before the after-deploy hooks (AutoInstall) run. With RDS\n * Proxy the setup also waits until the proxy accepts the API's connections, and fails the deploy\n * when it doesn't within 10 minutes.\n *\n * The GraphQL function gets the `WEBINY_PG_*` env from `createApiPulumiApp`, before this module\n * copies its config.\n */\nexport const ApiSchemaSetup = createAppModule({\n name: \"ApiSchemaSetup\",\n config(app: PulumiApp, params: ApiSchemaSetupParams) {\n const graphql = app.getModule(ApiGraphql);\n\n const secretPolicy = app.addResource(aws.iam.RolePolicy, {\n name: \"api-lambda-pg-secret\",\n config: {\n role: graphql.role.output.id,\n policy: params.postgres.apply(pg => {\n const { WEBINY_PG_SECRET_ARN } = getPostgresLambdaEnv(pg);\n return JSON.stringify(createPostgresSecretPolicy(WEBINY_PG_SECRET_ARN));\n })\n }\n });\n\n const baseConfig = graphql.functions.graphql.config.clone();\n\n const schemaSetup = app.addResource(aws.lambda.Function, {\n name: ApiSchemaSetupLambdaName,\n config: {\n ...baseConfig,\n description: \"Sets the Webiny API up on Postgres. Invoked by every deploy.\",\n // Lambda's maximum. Creating the tables of a new database takes longer than a request\n // may, and with RDS Proxy the setup then waits (up to 10 minutes) until the proxy\n // accepts the API's connections: a new proxy refuses them for a few minutes.\n timeout: 900,\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n const invocation = app.addResource(aws.lambda.Invocation, {\n name: ApiSchemaSetupLambdaName,\n config: {\n functionName: schemaSetup.output.name,\n input: pulumi\n .output(params.serviceManifests)\n .apply(manifests =>\n JSON.stringify(createSchemaSetupEvent(manifests as ServiceManifest[]))\n ),\n triggers: {\n deploy: params.trigger ?? new Date().toISOString()\n }\n },\n opts: {\n // The function reads the password from the secret as soon as it runs.\n dependsOn: [secretPolicy.output]\n }\n });\n\n return {\n secretPolicy,\n functions: {\n schemaSetup\n },\n invocation\n };\n }\n});\n"],"names":["SQL_SCHEMA_SETUP_EVENT","ApiSchemaSetupLambdaName","LAMBDA_RDS_CA_CERTS","POSTGRES_DEFAULT_PORT","POSTGRES_LAMBDA_ENV_NAMES","getPostgresLambdaEnv","pg","missing","name","Error","String","getPostgresLambdaEnvFromCore","core","env","Object","values","getPostgresWebFunctionEnv","postgres","WEB_FUNCTION_RDS_CA_CERTS","createPostgresSecretPolicy","secretArn","createSchemaSetupEvent","serviceManifests","manifest","getSchemaSetupServiceManifests","coreManifests","apiManifests","byName","Map","ApiSchemaSetup","createAppModule","app","params","graphql","ApiGraphql","secretPolicy","aws","WEBINY_PG_SECRET_ARN","JSON","baseConfig","schemaSetup","invocation","pulumi","manifests","Date"],"mappings":";;;;;AAWO,MAAMA,yBAAyB;AAE/B,MAAMC,2BAA2B;AAGxC,MAAMC,sBAAsB;AAE5B,MAAMC,wBAAwB;AAa9B,MAAMC,4BAA4D;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAWM,MAAMC,uBAAuB,CAACC;IACjC,MAAMC,UAAW;QAAC;QAAgB;QAAc;QAAU;KAAc,CAAW,MAAM,CACrFC,CAAAA,OAAQ,CAACF,EAAE,CAACE,KAAK;IAErB,IAAID,QAAQ,MAAM,EACd,MAAM,IAAIE,MACN,CAAC,wDAAwD,EAAEF,QAAQ,IAAI,CAAC,MAAM,sFAAG,CAAC;IAK1F,OAAO;QACH,gBAAiBD,GAAG,WAAW,IAAIA,GAAG,YAAY;QAClD,uBAAuBA,GAAG,YAAY;QACtC,gBAAgBI,OAAOJ,GAAG,MAAM,IAAIH;QACpC,oBAAoBG,GAAG,UAAU;QACjC,gBAAgBA,GAAG,MAAM;QACzB,sBAAsBA,GAAG,WAAW;QACpC,eAAe;QACf,qBAAqBJ;IACzB;AACJ;AAMO,MAAMS,+B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AC1B,CAAAA;oBAC1B,MAAM,EAAE+B,oBAAoB,EAAE,GAAGhC,qBAAqBC;oBACtD,OAAOgC,KAAK,SAAS,CAACnB,2BAA2BkB;gBACrD;YACJ;QACJ;QAEA,MAAME,aAAaN,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAEzD,MAAMO,cAAcT,IAAI,WAAW,CAACK,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YACrD,MAAMnC;YACN,QAAQ;gBACJ,GAAGsC,UAAU;gBACb,aAAa;gBAIb,SAAS;gBACT,eAAe;oBACX,WAAW;gBACf;YACJ;QACJ;QAEA,MAAME,aAAaV,IAAI,WAAW,CAACK,uCAAAA,MAAAA,CAAAA,UAAqB,EAAE;YACtD,MAAMnC;YACN,QAAQ;gBACJ,cAAcuC,YAAY,MAAM,CAAC,IAAI;gBACrC,OAAOE,0CAAAA,MACI,CAACV,OAAO,gBAAgB,EAC9B,KAAK,CAACW,CAAAA,YACHL,KAAK,SAAS,CAACjB,uBAAuBsB;gBAE9C,UAAU;oBACN,QAAQX,OAAO,OAAO,IAAI,IAAIY,OAAO,WAAW;gBACpD;YACJ;YACA,MAAM;gBAEF,WAAW;oBAACT,aAAa,MAAM;iBAAC;YACpC;QACJ;QAEA,OAAO;YACHA;YACA,WAAW;gBACPK;YACJ;YACAC;QACJ;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/ApiSchemaSetup.js","sources":["../../../../src/pulumi/apps/api/ApiSchemaSetup.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport type { PostgresOutputs, TenantStorageOutput } from \"~/pulumi/apps/common/CoreOutput.js\";\nimport type { PostgresExtensionConfig } from \"~/pulumi/apps/extensions/getPostgresConfigFromExtension.js\";\nimport type { ServiceManifest } from \"~/pulumi/utils/addServiceManifestTableItem.js\";\nimport { WEB_FUNCTION_RDS_CA_CERTS } from \"~/extensions/Postgres/rdsCaBundle.js\";\nimport { ApiGraphql } from \"./ApiGraphql.js\";\n\n/* The event `@webiny/api-composition-aws-pg` answers with the schema setup. */\nexport const SQL_SCHEMA_SETUP_EVENT = \"WebinySqlSchemaSetup\";\n\nexport const ApiSchemaSetupLambdaName = \"schema-setup\";\n\n/* The CA bundle of the Lambda Node.js runtime, which has the Amazon RDS certificates. */\nconst LAMBDA_RDS_CA_CERTS = \"/var/runtime/ca-cert.pem\";\n\nconst POSTGRES_DEFAULT_PORT = 5432;\n\nexport interface PostgresLambdaEnv {\n WEBINY_PG_HOST: string;\n WEBINY_PG_WRITER_HOST: string;\n WEBINY_PG_PORT: string;\n WEBINY_PG_DATABASE: string;\n WEBINY_PG_USER: string;\n WEBINY_PG_SECRET_ARN: string;\n WEBINY_PG_SSL: string;\n NODE_EXTRA_CA_CERTS: string;\n}\n\nconst POSTGRES_LAMBDA_ENV_NAMES: Array<keyof PostgresLambdaEnv> = [\n \"WEBINY_PG_HOST\",\n \"WEBINY_PG_WRITER_HOST\",\n \"WEBINY_PG_PORT\",\n \"WEBINY_PG_DATABASE\",\n \"WEBINY_PG_USER\",\n \"WEBINY_PG_SECRET_ARN\",\n \"WEBINY_PG_SSL\",\n \"NODE_EXTRA_CA_CERTS\"\n];\n\n/**\n * The env vars an API function connects to Postgres with, from the core stack's Postgres outputs.\n * The API goes through the RDS Proxy when the core has one, else to the cluster's writer; the schema\n * setup always goes to the writer (`WEBINY_PG_WRITER_HOST`). Over TLS, verified against the RDS\n * certificates of the Lambda runtime. No password: the functions read it from the secret.\n *\n * Throws when the core stack has no Postgres database, which is the case until `deploy core` runs\n * with `<Infra.AuroraPostgres />`.\n */\nexport const getPostgresLambdaEnv = (pg: PostgresOutputs): PostgresLambdaEnv => {\n const missing = ([\"pgWriterHost\", \"pgDatabase\", \"pgUser\", \"pgSecretArn\"] as const).filter(\n name => !pg[name]\n );\n if (missing.length) {\n throw new Error(\n `The core app has no Postgres database (missing outputs: ${missing.join(\", \")}). ` +\n \"Deploy the core app with `<Infra.AuroraPostgres />` first: `yarn webiny deploy core`.\"\n );\n }\n\n return {\n WEBINY_PG_HOST: (pg.pgProxyHost || pg.pgWriterHost) as string,\n WEBINY_PG_WRITER_HOST: pg.pgWriterHost as string,\n WEBINY_PG_PORT: String(pg.pgPort || POSTGRES_DEFAULT_PORT),\n WEBINY_PG_DATABASE: pg.pgDatabase as string,\n WEBINY_PG_USER: pg.pgUser as string,\n WEBINY_PG_SECRET_ARN: pg.pgSecretArn as string,\n WEBINY_PG_SSL: \"true\",\n NODE_EXTRA_CA_CERTS: LAMBDA_RDS_CA_CERTS\n };\n};\n\n/**\n * {@link getPostgresLambdaEnv} for the core stack's output, one Pulumi output per env var, so it can\n * be spread into a function's env next to the other variables.\n */\nexport const getPostgresLambdaEnvFromCore = (\n core: pulumi.Output<PostgresOutputs>\n): Record<keyof PostgresLambdaEnv, pulumi.Output<string>> => {\n const env = core.apply(getPostgresLambdaEnv);\n return Object.fromEntries(\n POSTGRES_LAMBDA_ENV_NAMES.map(name => [name, env.apply(values => values[name])])\n ) as Record<keyof PostgresLambdaEnv, pulumi.Output<string>>;\n};\n\n/**\n * Env only the API's web function gets, on top of the `graphql` Lambda's (and over it), with\n * `<Infra.AuroraPostgres />` or a `<Infra.TenantStorage.AuroraPostgres>`. Nothing without Postgres.\n *\n * - `WEBINY_PG_POOL_MAX`: its pool size, for each Postgres storage. One web function environment\n * serves several requests at once, so it needs more than the 1 connection the plain Lambda\n * functions keep.\n * - `NODE_EXTRA_CA_CERTS`: the RDS CA bundle shipped in its code. Its runtime has no\n * `/var/runtime/ca-cert.pem`, the bundle the plain Lambda functions verify the database with.\n */\nexport const getPostgresWebFunctionEnv = (\n postgres: Pick<PostgresExtensionConfig, \"poolSize\"> | undefined\n): Record<string, string> => {\n if (!postgres) {\n return {};\n }\n return {\n WEBINY_PG_POOL_MAX: String(postgres.poolSize),\n NODE_EXTRA_CA_CERTS: WEB_FUNCTION_RDS_CA_CERTS\n };\n};\n\n/* The env var the API reads its extra storages from (`createAwsPgTenantStorages`). */\nexport const TENANT_STORAGES_ENV = \"WEBINY_TENANT_STORAGES\";\n\n/**\n * The value of `WEBINY_TENANT_STORAGES` for the core's `storages` output: a JSON list of\n * `{ id, label, retired, type, connection }`, where `connection` holds the storage's `WEBINY_PG_*`\n * settings, as `getPostgresLambdaEnv` builds them for the default storage's cluster. Retired storages\n * are in it: tenants already on them keep running there.\n */\nexport const getTenantStoragesLambdaEnv = (storages: TenantStorageOutput[]): string => {\n return JSON.stringify(\n storages.map(storage => {\n // The CA bundle is the process's: the functions get it once, for every storage.\n const { NODE_EXTRA_CA_CERTS, ...connection } = getPostgresLambdaEnv(storage);\n void NODE_EXTRA_CA_CERTS;\n return {\n id: storage.id,\n label: storage.label,\n retired: storage.retired === true,\n type: \"postgres\",\n connection\n };\n })\n );\n};\n\n/**\n * The env an API function gets with a `<Infra.TenantStorage.AuroraPostgres>`: the storages'\n * connections, and the RDS certificates the plain Lambda functions verify every cluster with (the\n * web function's env replaces it with the bundle shipped in its code).\n */\nexport const getTenantStoragesLambdaEnvFromCore = (\n core: pulumi.Output<{ storages: TenantStorageOutput[] | undefined }>\n) => {\n return {\n [TENANT_STORAGES_ENV]: core.apply(({ storages }) =>\n getTenantStoragesLambdaEnv(storages ?? [])\n ),\n NODE_EXTRA_CA_CERTS: LAMBDA_RDS_CA_CERTS\n };\n};\n\n/*\n * Lets the API functions read the database passwords, and nothing else, from the secrets of the\n * deploy's clusters: the default storage's and every extra storage's.\n */\nexport const createPostgresSecretPolicy = (\n secretArns: string | string[]\n): aws.iam.PolicyDocument => {\n return {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForPostgresSecret\",\n Effect: \"Allow\",\n Action: [\"secretsmanager:GetSecretValue\"],\n Resource: Array.isArray(secretArns) ? secretArns : [secretArns]\n }\n ]\n };\n};\n\n/* The event the deploy invokes the schema-setup function with. */\nexport const createSchemaSetupEvent = (serviceManifests: ServiceManifest[]) => {\n return {\n [SQL_SCHEMA_SETUP_EVENT]: {\n serviceManifests: serviceManifests.map(({ name, manifest }) => ({ name, manifest }))\n }\n };\n};\n\n/**\n * The manifests the api deploy stores: the core's (from the core stack output; the core deploys\n * before this function exists), then the api app's own. On a repeated name the api's own wins.\n *\n * Throws when the core stack has no service manifests: a core deployed before the core put them\n * in its output. Its `core` manifest would never reach the database.\n */\nexport const getSchemaSetupServiceManifests = (\n coreManifests: ServiceManifest[] | undefined,\n apiManifests: ServiceManifest[]\n): ServiceManifest[] => {\n if (!coreManifests) {\n throw new Error(\n \"The core app's stack output has no service manifests, which the api deploy stores \" +\n \"in the database. Deploy the core app again: `yarn webiny deploy core`.\"\n );\n }\n\n const byName = new Map<string, ServiceManifest>();\n for (const manifest of [...coreManifests, ...apiManifests]) {\n byName.set(manifest.name, manifest);\n }\n return [...byName.values()];\n};\n\nexport interface ApiSchemaSetupParams {\n /* The core stack's Postgres outputs, with `<Infra.AuroraPostgres />` (a Postgres default storage). */\n postgres?: pulumi.Output<PostgresOutputs>;\n /* The core stack's `storages`, with a `<Infra.TenantStorage.AuroraPostgres>`. */\n tenantStorages?: pulumi.Output<TenantStorageOutput[] | undefined>;\n /*\n * Stored in the default storage's database by the setup, for service discovery. None on a\n * DynamoDB default storage, which keeps them in DynamoDB.\n */\n serviceManifests: pulumi.Input<ServiceManifest[]>;\n /* Changes on every deploy, so every deploy runs the setup. Replaced in tests. */\n trigger?: string;\n}\n\nexport type ApiSchemaSetup = PulumiAppModule<typeof ApiSchemaSetup>;\n\n/**\n * The API's Postgres storages, at deploy time: the default storage's cluster\n * (`<Infra.AuroraPostgres />`) and each `<Infra.TenantStorage.AuroraPostgres>`'s.\n * - lets the API role read the database passwords from the clusters' secrets;\n * - adds the `schema-setup` function: the GraphQL function's bundle, role, env and VPC, with time\n * for the setup and no route to it;\n * - invokes it on every deploy with the `WebinySqlSchemaSetup` event, which sets every cluster up,\n * each on its own writer. A failed setup fails the deploy, so the schema is in place before the\n * after-deploy hooks (AutoInstall) run. With RDS Proxy the setup also waits until the proxy accepts\n * the API's connections, and fails the deploy when it doesn't within 10 minutes.\n *\n * The GraphQL function gets the `WEBINY_PG_*` env from `createApiPulumiApp`, before this module\n * copies its config.\n */\nexport const ApiSchemaSetup = createAppModule({\n name: \"ApiSchemaSetup\",\n config(app: PulumiApp, params: ApiSchemaSetupParams) {\n const graphql = app.getModule(ApiGraphql);\n\n const secretPolicy = app.addResource(aws.iam.RolePolicy, {\n name: \"api-lambda-pg-secret\",\n config: {\n role: graphql.role.output.id,\n policy: pulumi\n .all([params.postgres, params.tenantStorages])\n .apply(([postgres, storages]) => {\n const arns = [\n ...(postgres\n ? [getPostgresLambdaEnv(postgres).WEBINY_PG_SECRET_ARN]\n : []),\n ...(storages ?? []).map(storage => {\n return getPostgresLambdaEnv(storage).WEBINY_PG_SECRET_ARN;\n })\n ];\n return JSON.stringify(createPostgresSecretPolicy(arns));\n })\n }\n });\n\n const baseConfig = graphql.functions.graphql.config.clone();\n\n const schemaSetup = app.addResource(aws.lambda.Function, {\n name: ApiSchemaSetupLambdaName,\n config: {\n ...baseConfig,\n description: \"Sets the Webiny API up on Postgres. Invoked by every deploy.\",\n // Lambda's maximum. Creating the tables of a new database takes longer than a request\n // may, and with RDS Proxy the setup then waits (up to 10 minutes) until the proxy\n // accepts the API's connections: a new proxy refuses them for a few minutes.\n timeout: 900,\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n const invocation = app.addResource(aws.lambda.Invocation, {\n name: ApiSchemaSetupLambdaName,\n config: {\n functionName: schemaSetup.output.name,\n input: pulumi\n .output(params.serviceManifests)\n .apply(manifests =>\n JSON.stringify(createSchemaSetupEvent(manifests as ServiceManifest[]))\n ),\n triggers: {\n deploy: params.trigger ?? new Date().toISOString()\n }\n },\n opts: {\n // The function reads the password from the secret as soon as it runs.\n dependsOn: [secretPolicy.output]\n }\n });\n\n return {\n secretPolicy,\n functions: {\n schemaSetup\n },\n invocation\n };\n }\n});\n"],"names":["SQL_SCHEMA_SETUP_EVENT","ApiSchemaSetupLambdaName","LAMBDA_RDS_CA_CERTS","POSTGRES_DEFAULT_PORT","POSTGRES_LAMBDA_ENV_NAMES","getPostgresLambdaEnv","pg","missing","name","Error","String","getPostgresLambdaEnvFromCore","core","env","Object","values","getPostgresWebFunctionEnv","postgres","WEB_FUNCTION_RDS_CA_CERTS","TENANT_STORAGES_ENV","getTenantStoragesLambdaEnv","storages","JSON","storage","NODE_EXTRA_CA_CERTS","connection","getTenantStoragesLambdaEnvFromCore","createPostgresSecretPolicy","secretArns","Array","createSchemaSetupEvent","serviceManifests","manifest","getSchemaSetupServiceManifests","coreManifests","apiManifests","byName","Map","ApiSchemaSetup","createAppModule","app","params","graphql","ApiGraphql","secretPolicy","aws","pulumi","arns","baseConfig","schemaSetup","invocation","manifests","Date"],"mappings":";;;;;AAWO,MAAMA,yBAAyB;AAE/B,MAAMC,2BAA2B;AAGxC,MAAMC,sBAAsB;AAE5B,MAAMC,wBAAwB;AAa9B,MAAMC,4BAA4D;IAC9D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAWM,MAAMC,uBAAuB,CAACC;IACjC,MAAMC,UAAW;QAAC;QAAgB;QAAc;QAAU;KAAc,CAAW,MAAM,CACrFC,CAAAA,OAAQ,CAACF,EAAE,CAACE,KAAK;IAErB,IAAID,QAAQ,MAAM,EACd,MAAM,IAAIE,MACN,CAAC,wDAAwD,EAAEF,QAAQ,IAAI,CAAC,MAAM,4FAAG,CAAC;IAK1F,OAAO;QACH,gBAAiBD,GAAG,WAAW,IAAIA,GAAG,YAAY;QAClD,uBAAuBA,GAAG,YAAY;QACtC,gBAAgBI,OAAOJ,GAAG,MAAM,IAAIH;QACpC,oBAAoBG,GAAG,UAAU;QACjC,gBAAgBA,GAAG,MAAM;QACzB,sBAAsBA,GAAG,WAAW;QACpC,eAAe;QAC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;gBACJ,cAAcgD,YAAY,MAAM,CAAC,IAAI;gBACrC,OAAOH,0CAAAA,MACI,CAACL,OAAO,gBAAgB,EAC9B,KAAK,CAACU,CAAAA,YACH7B,KAAK,SAAS,CAACQ,uBAAuBqB;gBAE9C,UAAU;oBACN,QAAQV,OAAO,OAAO,IAAI,IAAIW,OAAO,WAAW;gBACpD;YACJ;YACA,MAAM;gBAEF,WAAW;oBAACR,aAAa,MAAM;iBAAC;YACpC;QACJ;QAEA,OAAO;YACHA;YACA,WAAW;gBACPK;YACJ;YACAC;QACJ;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/apiDynamoDb.js","sources":["../../../../src/pulumi/apps/api/apiDynamoDb.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { CoreOutput } from \"~/pulumi/apps/common/CoreOutput.js\";\n\n/*\n * The api app's references to the core's DynamoDB tables. With `<Infra.
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/apiDynamoDb.js","sources":["../../../../src/pulumi/apps/api/apiDynamoDb.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { CoreOutput } from \"~/pulumi/apps/common/CoreOutput.js\";\n\n/*\n * The api app's references to the core's DynamoDB tables. With `<Infra.AuroraPostgres />` the core\n * has neither the primary nor the audit logs table, so there is no env or output for them. The\n * OpenSearch table belongs to `CoreOpenSearch` and exists whenever OpenSearch is configured, with\n * or without Postgres, so its env stays. The GraphQL policy's DynamoDB statement follows the\n * core's output instead (see `ApiGraphql`).\n */\n\nexport type DynamoDbLambdaEnv = Partial<\n Record<\"DB_TABLE\" | \"DB_TABLE_AUDIT_LOGS\" | \"DB_TABLE_OPENSEARCH\", pulumi.Output<unknown>>\n>;\n\n/* The env that names the core's DynamoDB tables, for the GraphQL functions. */\nexport const getDynamoDbLambdaEnv = (\n core: CoreOutput,\n usesPostgres: boolean\n): DynamoDbLambdaEnv => {\n if (usesPostgres) {\n // Unset (undefined) without OpenSearch, as before.\n return { DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName };\n }\n return {\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName,\n DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName\n };\n};\n\n/* The api stack outputs that name the core's DynamoDB tables. */\nexport const addDynamoDbOutputs = (app: PulumiApp, core: CoreOutput, usesPostgres: boolean) => {\n if (usesPostgres) {\n return;\n }\n app.addOutputs({\n dynamoDbTable: core.primaryDynamodbTableName,\n auditLogsDynamoDbTable: core.auditLogsDynamodbTableName\n });\n};\n"],"names":["getDynamoDbLambdaEnv","core","usesPostgres","addDynamoDbOutputs","app"],"mappings":"AAiBO,MAAMA,uBAAuB,CAChCC,MACAC;IAEA,IAAIA,cAEA,OAAO;QAAE,qBAAqBD,KAAK,2BAA2B;IAAC;IAEnE,OAAO;QACH,UAAUA,KAAK,wBAAwB;QACvC,qBAAqBA,KAAK,0BAA0B;QACpD,qBAAqBA,KAAK,2BAA2B;IACzD;AACJ;AAGO,MAAME,qBAAqB,CAACC,KAAgBH,MAAkBC;IACjE,IAAIA,cACA;IAEJE,IAAI,UAAU,CAAC;QACX,eAAeH,KAAK,wBAAwB;QAC5C,wBAAwBA,KAAK,0BAA0B;IAC3D;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/backgroundTask/types.js","sources":["../../../../../src/pulumi/apps/api/backgroundTask/types.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\n\n/**\n * Update types if required. Try to avoid generic objects\n */\nexport enum StepFunctionDefinitionStatesType {\n Task = \"Task\",\n Pass = \"Pass\",\n Choice = \"Choice\",\n Wait = \"Wait\",\n Fail = \"Fail\",\n Succeed = \"Succeed\"\n}\n\nexport interface StepFunctionDefinitionStatesCatch {\n ErrorEquals: string[];\n Next: string;\n ResultPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceBase {\n Variable: string;\n Next: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsNull?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceAndItem {\n Variable: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsTimestamp?: boolean;\n IsNumeric?: boolean;\n NumericGreaterThan?: number;\n}\nexport interface StepFunctionDefinitionStatesChoiceAnd {\n And: StepFunctionDefinitionStatesChoiceAndItem[];\n Next: string;\n}\n\nexport type StepFunctionDefinitionStatesChoice =\n | StepFunctionDefinitionStatesChoiceBase\n | StepFunctionDefinitionStatesChoiceAnd;\n\nexport interface StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType;\n Comment?: string;\n InputPath?: string;\n OutputPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeTask extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Task;\n Resource: pulumi.Input<string>;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n Catch: StepFunctionDefinitionStatesCatch[];\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypePass extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Pass;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypeChoice extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Choice;\n Choices: StepFunctionDefinitionStatesChoice[];\n Default?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeFail extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Fail;\n Error?: string;\n Cause?: string;\n CausePath?: string;\n ErrorPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeSucceed extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Succeed;\n}\n\nexport interface StepFunctionDefinitionStatesTypeWait extends StepFunctionDefinitionStatesTypeBase {\n Next: string;\n Seconds?: number;\n Timestamp?: string;\n SecondsPath?: string;\n TimestampPath?: string;\n}\n\nexport type StepFunctionDefinitionStatesTypes =\n | StepFunctionDefinitionStatesTypeTask\n | StepFunctionDefinitionStatesTypePass\n | StepFunctionDefinitionStatesTypeChoice\n | StepFunctionDefinitionStatesTypeFail\n | StepFunctionDefinitionStatesTypeSucceed\n | StepFunctionDefinitionStatesTypeWait;\n\nexport interface StepFunctionDefinition {\n Comment: string;\n StartAt: string;\n States: {\n [key: string]: StepFunctionDefinitionStatesTypes;\n };\n}\n"],"names":["StepFunctionDefinitionStatesType"],"mappings":"AAKO,IAAKA,yCAAgCA,WAAAA,GAAAA,
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/backgroundTask/types.js","sources":["../../../../../src/pulumi/apps/api/backgroundTask/types.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\n\n/**\n * Update types if required. Try to avoid generic objects\n */\nexport enum StepFunctionDefinitionStatesType {\n Task = \"Task\",\n Pass = \"Pass\",\n Choice = \"Choice\",\n Wait = \"Wait\",\n Fail = \"Fail\",\n Succeed = \"Succeed\"\n}\n\nexport interface StepFunctionDefinitionStatesCatch {\n ErrorEquals: string[];\n Next: string;\n ResultPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceBase {\n Variable: string;\n Next: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsNull?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesChoiceAndItem {\n Variable: string;\n StringEquals?: string;\n StringMatches?: string;\n IsPresent?: boolean;\n IsTimestamp?: boolean;\n IsNumeric?: boolean;\n NumericGreaterThan?: number;\n}\nexport interface StepFunctionDefinitionStatesChoiceAnd {\n And: StepFunctionDefinitionStatesChoiceAndItem[];\n Next: string;\n}\n\nexport type StepFunctionDefinitionStatesChoice =\n | StepFunctionDefinitionStatesChoiceBase\n | StepFunctionDefinitionStatesChoiceAnd;\n\nexport interface StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType;\n Comment?: string;\n InputPath?: string;\n OutputPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeTask extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Task;\n Resource: pulumi.Input<string>;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n Catch: StepFunctionDefinitionStatesCatch[];\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypePass extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Pass;\n Next: string;\n ResultPath?: string;\n Parameters: Record<string, any>;\n End?: boolean;\n}\n\nexport interface StepFunctionDefinitionStatesTypeChoice extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Choice;\n Choices: StepFunctionDefinitionStatesChoice[];\n Default?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeFail extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Fail;\n Error?: string;\n Cause?: string;\n CausePath?: string;\n ErrorPath?: string;\n}\n\nexport interface StepFunctionDefinitionStatesTypeSucceed extends StepFunctionDefinitionStatesTypeBase {\n Type: StepFunctionDefinitionStatesType.Succeed;\n}\n\nexport interface StepFunctionDefinitionStatesTypeWait extends StepFunctionDefinitionStatesTypeBase {\n Next: string;\n Seconds?: number;\n Timestamp?: string;\n SecondsPath?: string;\n TimestampPath?: string;\n}\n\nexport type StepFunctionDefinitionStatesTypes =\n | StepFunctionDefinitionStatesTypeTask\n | StepFunctionDefinitionStatesTypePass\n | StepFunctionDefinitionStatesTypeChoice\n | StepFunctionDefinitionStatesTypeFail\n | StepFunctionDefinitionStatesTypeSucceed\n | StepFunctionDefinitionStatesTypeWait;\n\nexport interface StepFunctionDefinition {\n Comment: string;\n StartAt: string;\n States: {\n [key: string]: StepFunctionDefinitionStatesTypes;\n };\n}\n"],"names":["StepFunctionDefinitionStatesType"],"mappings":"AAKO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAAA,gCAAAA"}
|
|
@@ -13,7 +13,9 @@ import { isWebFunctionEnabled } from "../extensions/isWebFunctionEnabled.js";
|
|
|
13
13
|
import { getOsConfigFromExtension } from "../extensions/getOsConfigFromExtension.js";
|
|
14
14
|
import { getPostgresConfigFromExtension } from "../extensions/getPostgresConfigFromExtension.js";
|
|
15
15
|
import { projectUsesPostgres } from "../extensions/projectUsesPostgres.js";
|
|
16
|
-
import { ApiSchemaSetup, getPostgresLambdaEnvFromCore, getPostgresWebFunctionEnv, getSchemaSetupServiceManifests } from "./ApiSchemaSetup.js";
|
|
16
|
+
import { ApiSchemaSetup, getPostgresLambdaEnvFromCore, getPostgresWebFunctionEnv, getSchemaSetupServiceManifests, getTenantStoragesLambdaEnvFromCore } from "./ApiSchemaSetup.js";
|
|
17
|
+
import { getTenantStoragesFromExtension } from "../extensions/getTenantStoragesFromExtension.js";
|
|
18
|
+
import { POSTGRES_DEFAULT_POOL_SIZE } from "@webiny/project-extensions-aws/extensions/AuroraPostgresCluster.js";
|
|
17
19
|
import { createApiServiceManifests } from "./apiServiceManifests.js";
|
|
18
20
|
import { addDynamoDbOutputs, getDynamoDbLambdaEnv } from "./apiDynamoDb.js";
|
|
19
21
|
import { handleGuardDutyEvents } from "./handleGuardDutyEvents.js";
|
|
@@ -36,6 +38,7 @@ const createApiPulumiApp = ()=>{
|
|
|
36
38
|
const openSearchExtensionConfig = getOsConfigFromExtension(projectConfig);
|
|
37
39
|
const postgresConfig = getPostgresConfigFromExtension(projectConfig);
|
|
38
40
|
const usesPostgres = Boolean(postgresConfig);
|
|
41
|
+
const hasTenantStorages = getTenantStoragesFromExtension(projectConfig).length > 0;
|
|
39
42
|
let searchEngineParams = null;
|
|
40
43
|
if (openSearchExtensionConfig) searchEngineParams = openSearchExtensionConfig;
|
|
41
44
|
if (searchEngineParams) {
|
|
@@ -102,7 +105,8 @@ const createApiPulumiApp = ()=>{
|
|
|
102
105
|
S3_BUCKET: core.fileManagerBucketId,
|
|
103
106
|
EVENT_BUS: core.eventBusArn,
|
|
104
107
|
OKTA_ISSUER: process.env["OKTA_ISSUER"],
|
|
105
|
-
...usesPostgres ? getPostgresLambdaEnvFromCore(core) : {}
|
|
108
|
+
...usesPostgres ? getPostgresLambdaEnvFromCore(core) : {},
|
|
109
|
+
...hasTenantStorages ? getTenantStoragesLambdaEnvFromCore(core) : {}
|
|
106
110
|
};
|
|
107
111
|
const graphql = app.addModule(ApiGraphql, {
|
|
108
112
|
env: graphqlEnv
|
|
@@ -128,7 +132,9 @@ const createApiPulumiApp = ()=>{
|
|
|
128
132
|
graphqlWeb = app.addModule(ApiGraphqlWeb, {
|
|
129
133
|
namePrefix: pulumiResourceNamePrefix ?? "",
|
|
130
134
|
vpc: graphqlWebVpc,
|
|
131
|
-
env: getPostgresWebFunctionEnv(postgresConfig
|
|
135
|
+
env: getPostgresWebFunctionEnv(postgresConfig ?? (hasTenantStorages ? {
|
|
136
|
+
poolSize: POSTGRES_DEFAULT_POOL_SIZE
|
|
137
|
+
} : void 0))
|
|
132
138
|
});
|
|
133
139
|
app.addOutputs({
|
|
134
140
|
graphqlWebFunctionName: graphqlWeb.fn.output.functionName,
|
|
@@ -150,12 +156,13 @@ const createApiPulumiApp = ()=>{
|
|
|
150
156
|
const cloudfront = app.addModule(ApiCloudfront);
|
|
151
157
|
const backgroundTask = app.addModule(ApiBackgroundTask);
|
|
152
158
|
const scheduler = app.addModule(ApiScheduler);
|
|
153
|
-
const schemaSetup = usesPostgres ? app.addModule(ApiSchemaSetup, {
|
|
154
|
-
postgres: core,
|
|
155
|
-
|
|
159
|
+
const schemaSetup = usesPostgres || hasTenantStorages ? app.addModule(ApiSchemaSetup, {
|
|
160
|
+
postgres: usesPostgres ? core : void 0,
|
|
161
|
+
tenantStorages: hasTenantStorages ? core.apply((output)=>output.storages) : void 0,
|
|
162
|
+
serviceManifests: usesPostgres ? __rspack_external__pulumi_pulumi_f3e773ed.all([
|
|
156
163
|
core.serviceManifests,
|
|
157
164
|
app.getServiceManifests()
|
|
158
|
-
]).apply(([coreManifests, apiManifests])=>getSchemaSetupServiceManifests(coreManifests, apiManifests))
|
|
165
|
+
]).apply(([coreManifests, apiManifests])=>getSchemaSetupServiceManifests(coreManifests, apiManifests)) : []
|
|
159
166
|
}) : null;
|
|
160
167
|
const [apiCustomDomains] = projectConfig.extensionsByType(ApiCustomDomains);
|
|
161
168
|
if (apiCustomDomains) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/createApiPulumiApp.js","sources":["../../../../src/pulumi/apps/api/createApiPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport pick from \"lodash/pick.js\";\nimport { createPulumiApp, isResourceOfType, type PulumiApp } from \"@webiny/pulumi\";\nimport {\n ApiBackgroundTask,\n ApiCloudfront,\n ApiFileManager,\n ApiGateway,\n ApiGraphql,\n ApiGraphqlStream,\n ApiWebsocket,\n CoreOutput,\n VpcConfig\n} from \"~/pulumi/apps/index.js\";\nimport { ApiGraphqlWeb } from \"~/pulumi/apps/index.js\";\nimport type { GraphqlWebVpc } from \"~/pulumi/apps/index.js\";\nimport {\n addDomainsUrlsOutputs,\n withCommonLambdaEnvVariables,\n withServiceManifest\n} from \"~/pulumi/utils/index.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\n// import { attachSyncSystem } from \"../syncSystem/api/index.js\";\nimport { applyAwsResourceTags, getAwsAccountId } from \"~/pulumi/apps/awsUtils.js\";\nimport {\n addServiceManifestTableItems,\n type WithServiceManifest\n} from \"~/pulumi/utils/withServiceManifest.js\";\nimport { ApiScheduler } from \"~/pulumi/apps/api/ApiScheduler.js\";\nimport { getAwsProjectSdk } from \"~/pulumi/getAwsProjectSdk.js\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { isVpcEnabled } from \"~/pulumi/apps/extensions/isVpcEnabled.js\";\nimport { isWebFunctionEnabled } from \"~/pulumi/apps/extensions/isWebFunctionEnabled.js\";\nimport { getOsConfigFromExtension } from \"~/pulumi/apps/extensions/getOsConfigFromExtension.js\";\nimport { getPostgresConfigFromExtension } from \"~/pulumi/apps/extensions/getPostgresConfigFromExtension.js\";\nimport { projectUsesPostgres } from \"~/pulumi/apps/extensions/projectUsesPostgres.js\";\nimport {\n ApiSchemaSetup,\n getPostgresLambdaEnvFromCore,\n getPostgresWebFunctionEnv,\n getSchemaSetupServiceManifests\n} from \"./ApiSchemaSetup.js\";\nimport { createApiServiceManifests } from \"./apiServiceManifests.js\";\nimport { addDynamoDbOutputs, getDynamoDbLambdaEnv } from \"./apiDynamoDb.js\";\nimport { handleGuardDutyEvents } from \"./handleGuardDutyEvents.js\";\nimport {\n ApiPulumi,\n SetApiCustomDomains\n} from \"@webiny/project-extensions-aws/abstractions/features/pulumi/index.js\";\nimport { apiPulumi } from \"~/pulumi/features/ApiPulumi/index.js\";\nimport { DefaultSetApiCustomDomains } from \"~/pulumi/features/DefaultSetApiCustomDomains.js\";\nimport { ApiCustomDomains as apiCustomDomainsExt } from \"@webiny/project-extensions-aws/extensions/ApiCustomDomains.js\";\nimport { applyCustomDomain } from \"~/pulumi/apps/customDomain.js\";\n\nexport type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;\n\nexport const createApiPulumiApp = () => {\n const baseApp = createPulumiApp({\n name: \"api\",\n path: \"apps/api\",\n program: async (app: PulumiApp & WithServiceManifest) => {\n const sdk = await getAwsProjectSdk();\n const projectConfig = await sdk.getProjectConfig();\n\n const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();\n const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);\n const openSearchExtensionConfig = getOsConfigFromExtension(projectConfig);\n const postgresConfig = getPostgresConfigFromExtension(projectConfig);\n const usesPostgres = Boolean(postgresConfig);\n\n let searchEngineParams: typeof openSearchExtensionConfig | null = null;\n\n if (openSearchExtensionConfig) {\n searchEngineParams = openSearchExtensionConfig;\n }\n\n if (searchEngineParams) {\n const params = searchEngineParams;\n if (typeof params === \"object\") {\n if (params.endpoint) {\n process.env.OPENSEARCH_ENDPOINT = params.endpoint;\n }\n\n if (params.domainName) {\n process.env.AWS_OS_DOMAIN_NAME = params.domainName;\n }\n\n if (params.indexPrefix) {\n process.env.OPENSEARCH_INDEX_PREFIX = params.indexPrefix;\n }\n\n if (params.sharedIndexes) {\n process.env.OPENSEARCH_SHARED_INDEXES = \"true\";\n }\n\n if (params.username) {\n process.env.OPENSEARCH_USERNAME = params.username;\n }\n\n if (params.password) {\n process.env.OPENSEARCH_PASSWORD = params.password;\n }\n }\n }\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 // <-------------------- Enterprise start -------------------->\n app.addHandler(async () => {\n const featureFlags = await sdk.getFeatureFlags();\n\n const usingAdvancedVpcParams =\n vpcExtensionsConfig && typeof vpcExtensionsConfig !== \"boolean\";\n\n if (featureFlags.isEnabled(\"fileManager.threatDetection\")) {\n handleGuardDutyEvents(app as ApiPulumiApp);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (usingAdvancedVpcParams) {\n const { onResource, addResource } = app;\n const { useExistingVpc } = vpcExtensionsConfig;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(\n useExistingVpc!.lambdaFunctionsVpcConfig\n );\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn:\n aws.iam.ManagedPolicy\n .AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n }\n });\n // <-------------------- Enterprise end -------------------->\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 sdk.getContainer().registerComposite(apiPulumi);\n\n // Make the `SetApiCustomDomains` service injectable into user-defined `ApiPulumi`\n // implementations. This allows applying custom domains using dynamically created\n // Pulumi resources (e.g. ACM certificates), from within a single implementation file.\n // We register an instance (bound to the current `app`) so that user implementations\n // only need to pass the custom domain params - not the `app` itself.\n sdk.getContainer().registerInstance(\n SetApiCustomDomains,\n new DefaultSetApiCustomDomains(app as ApiPulumiApp)\n );\n\n const pulumiHandlers = sdk.getContainer().resolve(ApiPulumi);\n\n app.addHandler(() => {\n return pulumiHandlers.execute(app as ApiPulumiApp);\n });\n\n const isProduction = app.env.isProduction;\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 = isVpcEnabled(vpcExtensionsConfig, isProduction);\n const vpcConfig = app.addModule(VpcConfig, {\n enabled: vpcEnabled\n });\n\n // Shared by the buffered `graphql` function and its response-streaming twin: both run the\n // same code bundle, so they must see the same environment.\n const dynamoDbEnv = getDynamoDbLambdaEnv(core, usesPostgres);\n const graphqlEnv = {\n COGNITO_REGION: getEnvVariableAwsRegion(),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n // The core's DynamoDB tables: none with `<Infra.Postgres />`.\n ...dynamoDbEnv,\n OPENSEARCH_ENDPOINT: core.opensearchDomainEndpoint,\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 OPENSEARCH_INDEX_PREFIX: process.env.OPENSEARCH_INDEX_PREFIX,\n OPENSEARCH_SHARED_INDEXES: process.env.OPENSEARCH_SHARED_INDEXES,\n OPENSEARCH_USERNAME: process.env.OPENSEARCH_USERNAME,\n OPENSEARCH_PASSWORD: process.env.OPENSEARCH_PASSWORD,\n\n S3_BUCKET: core.fileManagerBucketId,\n EVENT_BUS: core.eventBusArn,\n // TODO: move to okta plugin\n OKTA_ISSUER: process.env[\"OKTA_ISSUER\"],\n\n // With `<Infra.Postgres />`: the database the API runs on. The background-task,\n // fm-download and schema-setup functions copy this function's env.\n ...(usesPostgres ? getPostgresLambdaEnvFromCore(core) : {})\n };\n\n const graphql = app.addModule(ApiGraphql, { env: graphqlEnv });\n\n // Second Lambda function off the same bundle, fronted by a Function URL instead of API\n // Gateway, because API Gateway buffers the whole response and cannot stream. Added before\n // ApiCloudfront, which resolves this module to wire the `/stream/*` origin and behavior.\n const graphqlStream = app.addModule(ApiGraphqlStream, { env: graphqlEnv });\n\n // On unless the project sets `<Infra.Api.WebFunction enabled={false} />`. With it, the API's\n // HTTP routes go to the web function and there is no HTTP API Gateway; without it, the\n // previous setup. Added before ApiCloudfront, which routes to whichever exists.\n const webFunctionEnabled = isWebFunctionEnabled(projectConfig);\n let graphqlWeb: ApiGraphqlWeb | undefined;\n if (webFunctionEnabled) {\n let graphqlWebVpc: GraphqlWebVpc | null = null;\n const useExistingVpc =\n typeof vpcExtensionsConfig === \"object\" && vpcExtensionsConfig.useExistingVpc;\n if (useExistingVpc) {\n // Same subnets and security groups the enterprise handler above gives the\n // regular Lambdas.\n graphqlWebVpc = useExistingVpc.lambdaFunctionsVpcConfig;\n } else if (vpcEnabled) {\n const functionVpcConfig = vpcConfig.functionVpcConfig;\n // `pulumi.output` unwraps the nested inputs into a plain `string[]` output.\n const subnetIds = pulumi.output(functionVpcConfig.subnetIds);\n const securityGroupIds = pulumi.output(functionVpcConfig.securityGroupIds);\n graphqlWebVpc = { subnetIds, securityGroupIds };\n }\n\n graphqlWeb = app.addModule(ApiGraphqlWeb, {\n namePrefix: pulumiResourceNamePrefix ?? \"\",\n vpc: graphqlWebVpc,\n // With `<Infra.Postgres />`, a bigger pool than the plain Lambdas' 1.\n env: getPostgresWebFunctionEnv(postgresConfig)\n });\n app.addOutputs({\n graphqlWebFunctionName: graphqlWeb.fn.output.functionName,\n graphqlWebEndpointDomain: graphqlWeb.endpoint.output.domainName,\n // Read by `webiny watch` to publish its forwarder revision.\n graphqlWebEndpointName: graphqlWeb.endpoint.output.endpointName,\n graphqlWebCodeBucket: graphqlWeb.codeBucket.output.id\n });\n }\n\n const websocket = app.addModule(ApiWebsocket);\n\n const fileManager = app.addModule(ApiFileManager, {\n env: pick(dynamoDbEnv, [\"DB_TABLE\", \"DB_TABLE_AUDIT_LOGS\"]),\n functionUrl: webFunctionEnabled\n });\n\n let apiGateway: ApiGateway | undefined;\n if (!webFunctionEnabled) {\n apiGateway = createApiGateway(app, graphql, fileManager);\n }\n\n const cloudfront = app.addModule(ApiCloudfront);\n\n const backgroundTask = app.addModule(ApiBackgroundTask);\n const scheduler = app.addModule(ApiScheduler);\n\n // With `<Infra.Postgres />`, every deploy sets the database up and stores the service\n // manifests: the core's (from its stack output), then the api's own: `api` and\n // `scheduler` (see below) and any an extension adds with `addServiceManifest`.\n const schemaSetup = usesPostgres\n ? app.addModule(ApiSchemaSetup, {\n postgres: core,\n serviceManifests: pulumi\n .all([core.serviceManifests, app.getServiceManifests()])\n .apply(([coreManifests, apiManifests]) =>\n getSchemaSetupServiceManifests(coreManifests, apiManifests)\n )\n })\n : null;\n\n const [apiCustomDomains] = projectConfig.extensionsByType(apiCustomDomainsExt);\n if (apiCustomDomains) {\n const { domains, sslMethod, certificateArn, minimumProtocolVersion } =\n apiCustomDomains.params;\n applyCustomDomain(cloudfront, {\n domains,\n sslSupportMethod: sslMethod,\n acmCertificateArn: certificateArn,\n minimumProtocolVersion\n });\n }\n\n app.addOutputs({\n awsAccountId: getAwsAccountId(app),\n region: aws.config.region,\n cognitoUserPoolId: core.cognitoUserPoolId,\n cognitoAppClientId: core.cognitoAppClientId,\n cognitoUserPoolPasswordPolicy: core.cognitoUserPoolPasswordPolicy,\n graphqlLambdaName: graphql.functions.graphql.output.name,\n graphqlLambdaRole: graphql.role.output.arn,\n graphqlLambdaRoleName: graphql.role.output.name,\n graphqlStreamLambdaName: graphqlStream.functions.graphqlStream.output.name,\n graphqlStreamFunctionUrl: graphqlStream.functionUrl.output.functionUrl,\n backgroundTaskLambdaArn: backgroundTask.backgroundTask.output.arn,\n backgroundTaskStepFunctionArn: backgroundTask.stepFunction.output.arn,\n fileManagerDownloadLambdaArn: fileManager.functions.download.output.arn,\n websocketApiId: websocket.websocketApi.output.id,\n websocketApiUrl: websocket.websocketApiUrl,\n schedulerLambdaInvokeRole: scheduler.invokeRole.output.arn\n });\n\n // The core's DynamoDB tables: none with `<Infra.Postgres />`.\n addDynamoDbOutputs(app, core, usesPostgres);\n\n if (schemaSetup) {\n app.addOutputs({\n schemaSetupLambdaArn: schemaSetup.functions.schemaSetup.output.arn\n });\n }\n\n // Only add `dynamoDbOpensearchTable` output if using search engine (ES/OS).\n if (searchEngineParams) {\n app.addOutputs({\n dynamoDbOpensearchTable: core.opensearchDynamodbTableName\n });\n }\n\n app.addHandler(() => {\n addDomainsUrlsOutputs({\n app,\n cloudfrontDistribution: cloudfront,\n map: {\n distributionDomain: \"cloudfrontApiDomain\",\n distributionUrl: \"cloudfrontApiUrl\",\n usedDomain: \"apiDomain\",\n usedUrl: \"apiUrl\"\n }\n });\n });\n // /**\n // * We need to attach the Sync System if it exists.\n // */\n // await attachSyncSystem({\n // app,\n // core,\n // env: app.params.run.env\n // });\n\n // Applies internal and user-defined AWS tags.\n await applyAwsResourceTags(\"api\");\n\n return {\n fileManager,\n graphql,\n graphqlStream,\n graphqlWeb,\n apiGateway,\n websocket,\n cloudfront,\n backgroundTask,\n scheduler,\n schemaSetup\n };\n }\n });\n\n const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp), async manifests => {\n // With Postgres, the schema-setup invocation stores them (see `ApiSchemaSetup` above).\n if (await projectUsesPostgres()) {\n return;\n }\n addServiceManifestTableItems(baseApp, manifests);\n });\n\n app.addHandler(() => {\n for (const manifest of createApiServiceManifests(baseApp.resources)) {\n app.addServiceManifest(manifest);\n }\n });\n\n return app;\n};\n\n/**\n * The HTTP API Gateway, used only with `<Infra.Api.WebFunction enabled={false} />`.\n */\nfunction createApiGateway(app: PulumiApp, graphql: ApiGraphql, fileManager: ApiFileManager) {\n return 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 \"private-any\": {\n path: \"/private/{path+}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n },\n \"cms-post\": {\n path: \"/cms/{key+}\",\n method: \"POST\",\n function: graphql.functions.graphql.output.arn\n },\n \"cms-options\": {\n path: \"/cms/{key+}\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"redirects-get\": {\n path: \"/wb/redirects\",\n method: \"GET\",\n function: graphql.functions.graphql.output.arn\n },\n \"redirects-options\": {\n path: \"/wb/redirects\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"files-catch-all\": {\n path: \"/{path+}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n }\n });\n}\n"],"names":["createApiPulumiApp","baseApp","createPulumiApp","app","sdk","getAwsProjectSdk","projectConfig","pulumiResourceNamePrefix","vpcExtensionsConfig","getVpcConfigFromExtension","openSearchExtensionConfig","getOsConfigFromExtension","postgresConfig","getPostgresConfigFromExtension","usesPostgres","Boolean","searchEngineParams","params","process","resource","featureFlags","usingAdvancedVpcParams","handleGuardDutyEvents","onResource","addResource","useExistingVpc","Error","isResourceOfType","aws","canUseVpc","apiPulumi","SetApiCustomDomains","DefaultSetApiCustomDomains","pulumiHandlers","ApiPulumi","isProduction","core","CoreOutput","vpcEnabled","isVpcEnabled","vpcConfig","VpcConfig","dynamoDbEnv","getDynamoDbLambdaEnv","graphqlEnv","getEnvVariableAwsRegion","getPostgresLambdaEnvFromCore","graphql","ApiGraphql","graphqlStream","ApiGraphqlStream","webFunctionEnabled","isWebFunctionEnabled","graphqlWeb","graphqlWebVpc","functionVpcConfig","subnetIds","pulumi","securityGroupIds","ApiGraphqlWeb","getPostgresWebFunctionEnv","websocket","ApiWebsocket","fileManager","ApiFileManager","pick","apiGateway","createApiGateway","cloudfront","ApiCloudfront","backgroundTask","ApiBackgroundTask","scheduler","ApiScheduler","schemaSetup","ApiSchemaSetup","coreManifests","apiManifests","getSchemaSetupServiceManifests","apiCustomDomains","apiCustomDomainsExt","domains","sslMethod","certificateArn","minimumProtocolVersion","applyCustomDomain","getAwsAccountId","addDynamoDbOutputs","addDomainsUrlsOutputs","applyAwsResourceTags","withServiceManifest","withCommonLambdaEnvVariables","manifests","projectUsesPostgres","addServiceManifestTableItems","manifest","createApiServiceManifests","ApiGateway"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,MAAMA,qBAAqB;IAC9B,MAAMC,UAAUC,gBAAgB;QAC5B,MAAM;QACN,MAAM;QACN,SAAS,OAAOC;YACZ,MAAMC,MAAM,MAAMC;YAClB,MAAMC,gBAAgB,MAAMF,IAAI,gBAAgB;YAEhD,MAAMG,2BAA2B,MAAMH,IAAI,2BAA2B;YACtE,MAAMI,sBAAsBC,0BAA0BH;YACtD,MAAMI,4BAA4BC,yBAAyBL;YAC3D,MAAMM,iBAAiBC,+BAA+BP;YACtD,MAAMQ,eAAeC,QAAQH;YAE7B,IAAII,qBAA8D;YAElE,IAA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AAS,CAAC8F,YAAY;QAC7B,gBAAgB;YACZ,MAAM;YACN,QAAQ;YACR,UAAUlD,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QAClD;QACA,mBAAmB;YACf,MAAM;YACN,QAAQ;YACR,UAAUA,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QAClD;QACA,aAAa;YACT,MAAM;YACN,QAAQ;YACR,UAAUgB,YAAY,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;QACvD;QACA,eAAe;YACX,MAAM;YACN,QAAQ;YACR,UAAUA,YAAY,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;QACvD;QACA,YAAY;YACR,MAAM;YACN,QAAQ;YACR,UAAUhB,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QAClD;QACA,eAAe;YACX,MAAM;YACN,QAAQ;YACR,UAAUA,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QAClD;QACA,iBAAiB;YACb,MAAM;YACN,QAAQ;YACR,UAAUA,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QAClD;QACA,qBAAqB;YACjB,MAAM;YACN,QAAQ;YACR,UAAUA,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QAClD;QACA,mBAAmB;YACf,MAAM;YACN,QAAQ;YACR,UAAUgB,YAAY,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;QACvD;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/createApiPulumiApp.js","sources":["../../../../src/pulumi/apps/api/createApiPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport pick from \"lodash/pick.js\";\nimport { createPulumiApp, isResourceOfType, type PulumiApp } from \"@webiny/pulumi\";\nimport {\n ApiBackgroundTask,\n ApiCloudfront,\n ApiFileManager,\n ApiGateway,\n ApiGraphql,\n ApiGraphqlStream,\n ApiWebsocket,\n CoreOutput,\n VpcConfig\n} from \"~/pulumi/apps/index.js\";\nimport { ApiGraphqlWeb } from \"~/pulumi/apps/index.js\";\nimport type { GraphqlWebVpc } from \"~/pulumi/apps/index.js\";\nimport {\n addDomainsUrlsOutputs,\n withCommonLambdaEnvVariables,\n withServiceManifest\n} from \"~/pulumi/utils/index.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\n// import { attachSyncSystem } from \"../syncSystem/api/index.js\";\nimport { applyAwsResourceTags, getAwsAccountId } from \"~/pulumi/apps/awsUtils.js\";\nimport {\n addServiceManifestTableItems,\n type WithServiceManifest\n} from \"~/pulumi/utils/withServiceManifest.js\";\nimport { ApiScheduler } from \"~/pulumi/apps/api/ApiScheduler.js\";\nimport { getAwsProjectSdk } from \"~/pulumi/getAwsProjectSdk.js\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { isVpcEnabled } from \"~/pulumi/apps/extensions/isVpcEnabled.js\";\nimport { isWebFunctionEnabled } from \"~/pulumi/apps/extensions/isWebFunctionEnabled.js\";\nimport { getOsConfigFromExtension } from \"~/pulumi/apps/extensions/getOsConfigFromExtension.js\";\nimport { getPostgresConfigFromExtension } from \"~/pulumi/apps/extensions/getPostgresConfigFromExtension.js\";\nimport { projectUsesPostgres } from \"~/pulumi/apps/extensions/projectUsesPostgres.js\";\nimport {\n ApiSchemaSetup,\n getPostgresLambdaEnvFromCore,\n getPostgresWebFunctionEnv,\n getSchemaSetupServiceManifests,\n getTenantStoragesLambdaEnvFromCore\n} from \"./ApiSchemaSetup.js\";\nimport { getTenantStoragesFromExtension } from \"~/pulumi/apps/extensions/getTenantStoragesFromExtension.js\";\nimport { POSTGRES_DEFAULT_POOL_SIZE } from \"@webiny/project-extensions-aws/extensions/AuroraPostgresCluster.js\";\nimport { createApiServiceManifests } from \"./apiServiceManifests.js\";\nimport { addDynamoDbOutputs, getDynamoDbLambdaEnv } from \"./apiDynamoDb.js\";\nimport { handleGuardDutyEvents } from \"./handleGuardDutyEvents.js\";\nimport {\n ApiPulumi,\n SetApiCustomDomains\n} from \"@webiny/project-extensions-aws/abstractions/features/pulumi/index.js\";\nimport { apiPulumi } from \"~/pulumi/features/ApiPulumi/index.js\";\nimport { DefaultSetApiCustomDomains } from \"~/pulumi/features/DefaultSetApiCustomDomains.js\";\nimport { ApiCustomDomains as apiCustomDomainsExt } from \"@webiny/project-extensions-aws/extensions/ApiCustomDomains.js\";\nimport { applyCustomDomain } from \"~/pulumi/apps/customDomain.js\";\n\nexport type ApiPulumiApp = ReturnType<typeof createApiPulumiApp>;\n\nexport const createApiPulumiApp = () => {\n const baseApp = createPulumiApp({\n name: \"api\",\n path: \"apps/api\",\n program: async (app: PulumiApp & WithServiceManifest) => {\n const sdk = await getAwsProjectSdk();\n const projectConfig = await sdk.getProjectConfig();\n\n const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();\n const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);\n const openSearchExtensionConfig = getOsConfigFromExtension(projectConfig);\n const postgresConfig = getPostgresConfigFromExtension(projectConfig);\n const usesPostgres = Boolean(postgresConfig);\n // `<Infra.TenantStorage.AuroraPostgres>`: Postgres storages tenants can be placed on.\n const hasTenantStorages = getTenantStoragesFromExtension(projectConfig).length > 0;\n\n let searchEngineParams: typeof openSearchExtensionConfig | null = null;\n\n if (openSearchExtensionConfig) {\n searchEngineParams = openSearchExtensionConfig;\n }\n\n if (searchEngineParams) {\n const params = searchEngineParams;\n if (typeof params === \"object\") {\n if (params.endpoint) {\n process.env.OPENSEARCH_ENDPOINT = params.endpoint;\n }\n\n if (params.domainName) {\n process.env.AWS_OS_DOMAIN_NAME = params.domainName;\n }\n\n if (params.indexPrefix) {\n process.env.OPENSEARCH_INDEX_PREFIX = params.indexPrefix;\n }\n\n if (params.sharedIndexes) {\n process.env.OPENSEARCH_SHARED_INDEXES = \"true\";\n }\n\n if (params.username) {\n process.env.OPENSEARCH_USERNAME = params.username;\n }\n\n if (params.password) {\n process.env.OPENSEARCH_PASSWORD = params.password;\n }\n }\n }\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 // <-------------------- Enterprise start -------------------->\n app.addHandler(async () => {\n const featureFlags = await sdk.getFeatureFlags();\n\n const usingAdvancedVpcParams =\n vpcExtensionsConfig && typeof vpcExtensionsConfig !== \"boolean\";\n\n if (featureFlags.isEnabled(\"fileManager.threatDetection\")) {\n handleGuardDutyEvents(app as ApiPulumiApp);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (usingAdvancedVpcParams) {\n const { onResource, addResource } = app;\n const { useExistingVpc } = vpcExtensionsConfig;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (!useExistingVpc.lambdaFunctionsVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `lambdaFunctionsVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.lambda.Function)) {\n const canUseVpc = resource.meta.canUseVpc !== false;\n if (canUseVpc) {\n resource.config.vpcConfig(\n useExistingVpc!.lambdaFunctionsVpcConfig\n );\n }\n }\n\n if (isResourceOfType(resource, aws.iam.Role)) {\n if (resource.meta.isLambdaFunctionRole) {\n addResource(aws.iam.RolePolicyAttachment, {\n name: `${resource.name}-vpc-access-execution-role`,\n config: {\n role: resource.output.name,\n policyArn:\n aws.iam.ManagedPolicy\n .AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n }\n });\n // <-------------------- Enterprise end -------------------->\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 sdk.getContainer().registerComposite(apiPulumi);\n\n // Make the `SetApiCustomDomains` service injectable into user-defined `ApiPulumi`\n // implementations. This allows applying custom domains using dynamically created\n // Pulumi resources (e.g. ACM certificates), from within a single implementation file.\n // We register an instance (bound to the current `app`) so that user implementations\n // only need to pass the custom domain params - not the `app` itself.\n sdk.getContainer().registerInstance(\n SetApiCustomDomains,\n new DefaultSetApiCustomDomains(app as ApiPulumiApp)\n );\n\n const pulumiHandlers = sdk.getContainer().resolve(ApiPulumi);\n\n app.addHandler(() => {\n return pulumiHandlers.execute(app as ApiPulumiApp);\n });\n\n const isProduction = app.env.isProduction;\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 = isVpcEnabled(vpcExtensionsConfig, isProduction);\n const vpcConfig = app.addModule(VpcConfig, {\n enabled: vpcEnabled\n });\n\n // Shared by the buffered `graphql` function and its response-streaming twin: both run the\n // same code bundle, so they must see the same environment.\n const dynamoDbEnv = getDynamoDbLambdaEnv(core, usesPostgres);\n const graphqlEnv = {\n COGNITO_REGION: getEnvVariableAwsRegion(),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n // The core's DynamoDB tables: none with `<Infra.AuroraPostgres />`.\n ...dynamoDbEnv,\n OPENSEARCH_ENDPOINT: core.opensearchDomainEndpoint,\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 OPENSEARCH_INDEX_PREFIX: process.env.OPENSEARCH_INDEX_PREFIX,\n OPENSEARCH_SHARED_INDEXES: process.env.OPENSEARCH_SHARED_INDEXES,\n OPENSEARCH_USERNAME: process.env.OPENSEARCH_USERNAME,\n OPENSEARCH_PASSWORD: process.env.OPENSEARCH_PASSWORD,\n\n S3_BUCKET: core.fileManagerBucketId,\n EVENT_BUS: core.eventBusArn,\n // TODO: move to okta plugin\n OKTA_ISSUER: process.env[\"OKTA_ISSUER\"],\n\n // With `<Infra.AuroraPostgres />`: the database the API runs on. The\n // background-task, fm-download and schema-setup functions copy this function's env.\n ...(usesPostgres ? getPostgresLambdaEnvFromCore(core) : {}),\n\n // With `<Infra.TenantStorage.AuroraPostgres>`: the clusters tenants can run on.\n ...(hasTenantStorages ? getTenantStoragesLambdaEnvFromCore(core) : {})\n };\n\n const graphql = app.addModule(ApiGraphql, { env: graphqlEnv });\n\n // Second Lambda function off the same bundle, fronted by a Function URL instead of API\n // Gateway, because API Gateway buffers the whole response and cannot stream. Added before\n // ApiCloudfront, which resolves this module to wire the `/stream/*` origin and behavior.\n const graphqlStream = app.addModule(ApiGraphqlStream, { env: graphqlEnv });\n\n // On unless the project sets `<Infra.Api.WebFunction enabled={false} />`. With it, the API's\n // HTTP routes go to the web function and there is no HTTP API Gateway; without it, the\n // previous setup. Added before ApiCloudfront, which routes to whichever exists.\n const webFunctionEnabled = isWebFunctionEnabled(projectConfig);\n let graphqlWeb: ApiGraphqlWeb | undefined;\n if (webFunctionEnabled) {\n let graphqlWebVpc: GraphqlWebVpc | null = null;\n const useExistingVpc =\n typeof vpcExtensionsConfig === \"object\" && vpcExtensionsConfig.useExistingVpc;\n if (useExistingVpc) {\n // Same subnets and security groups the enterprise handler above gives the\n // regular Lambdas.\n graphqlWebVpc = useExistingVpc.lambdaFunctionsVpcConfig;\n } else if (vpcEnabled) {\n const functionVpcConfig = vpcConfig.functionVpcConfig;\n // `pulumi.output` unwraps the nested inputs into a plain `string[]` output.\n const subnetIds = pulumi.output(functionVpcConfig.subnetIds);\n const securityGroupIds = pulumi.output(functionVpcConfig.securityGroupIds);\n graphqlWebVpc = { subnetIds, securityGroupIds };\n }\n\n graphqlWeb = app.addModule(ApiGraphqlWeb, {\n namePrefix: pulumiResourceNamePrefix ?? \"\",\n vpc: graphqlWebVpc,\n // With Postgres, a bigger pool than the plain Lambdas' 1, for each Postgres storage.\n env: getPostgresWebFunctionEnv(\n postgresConfig ??\n (hasTenantStorages\n ? { poolSize: POSTGRES_DEFAULT_POOL_SIZE }\n : undefined)\n )\n });\n app.addOutputs({\n graphqlWebFunctionName: graphqlWeb.fn.output.functionName,\n graphqlWebEndpointDomain: graphqlWeb.endpoint.output.domainName,\n // Read by `webiny watch` to publish its forwarder revision.\n graphqlWebEndpointName: graphqlWeb.endpoint.output.endpointName,\n graphqlWebCodeBucket: graphqlWeb.codeBucket.output.id\n });\n }\n\n const websocket = app.addModule(ApiWebsocket);\n\n const fileManager = app.addModule(ApiFileManager, {\n env: pick(dynamoDbEnv, [\"DB_TABLE\", \"DB_TABLE_AUDIT_LOGS\"]),\n functionUrl: webFunctionEnabled\n });\n\n let apiGateway: ApiGateway | undefined;\n if (!webFunctionEnabled) {\n apiGateway = createApiGateway(app, graphql, fileManager);\n }\n\n const cloudfront = app.addModule(ApiCloudfront);\n\n const backgroundTask = app.addModule(ApiBackgroundTask);\n const scheduler = app.addModule(ApiScheduler);\n\n // With `<Infra.AuroraPostgres />`, every deploy sets the database up and stores the\n // service manifests: the core's (from its stack output), then the api's own: `api` and\n // `scheduler` (see below) and any an extension adds with `addServiceManifest`. With a\n // `<Infra.TenantStorage.AuroraPostgres>`, it sets every storage's cluster up too; on a\n // DynamoDB default the manifests stay in DynamoDB.\n const schemaSetup =\n usesPostgres || hasTenantStorages\n ? app.addModule(ApiSchemaSetup, {\n postgres: usesPostgres ? core : undefined,\n tenantStorages: hasTenantStorages\n ? core.apply(output => output.storages)\n : undefined,\n serviceManifests: usesPostgres\n ? pulumi\n .all([core.serviceManifests, app.getServiceManifests()])\n .apply(([coreManifests, apiManifests]) =>\n getSchemaSetupServiceManifests(coreManifests, apiManifests)\n )\n : []\n })\n : null;\n\n const [apiCustomDomains] = projectConfig.extensionsByType(apiCustomDomainsExt);\n if (apiCustomDomains) {\n const { domains, sslMethod, certificateArn, minimumProtocolVersion } =\n apiCustomDomains.params;\n applyCustomDomain(cloudfront, {\n domains,\n sslSupportMethod: sslMethod,\n acmCertificateArn: certificateArn,\n minimumProtocolVersion\n });\n }\n\n app.addOutputs({\n awsAccountId: getAwsAccountId(app),\n region: aws.config.region,\n cognitoUserPoolId: core.cognitoUserPoolId,\n cognitoAppClientId: core.cognitoAppClientId,\n cognitoUserPoolPasswordPolicy: core.cognitoUserPoolPasswordPolicy,\n graphqlLambdaName: graphql.functions.graphql.output.name,\n graphqlLambdaRole: graphql.role.output.arn,\n graphqlLambdaRoleName: graphql.role.output.name,\n graphqlStreamLambdaName: graphqlStream.functions.graphqlStream.output.name,\n graphqlStreamFunctionUrl: graphqlStream.functionUrl.output.functionUrl,\n backgroundTaskLambdaArn: backgroundTask.backgroundTask.output.arn,\n backgroundTaskStepFunctionArn: backgroundTask.stepFunction.output.arn,\n fileManagerDownloadLambdaArn: fileManager.functions.download.output.arn,\n websocketApiId: websocket.websocketApi.output.id,\n websocketApiUrl: websocket.websocketApiUrl,\n schedulerLambdaInvokeRole: scheduler.invokeRole.output.arn\n });\n\n // The core's DynamoDB tables: none with `<Infra.AuroraPostgres />`.\n addDynamoDbOutputs(app, core, usesPostgres);\n\n if (schemaSetup) {\n app.addOutputs({\n schemaSetupLambdaArn: schemaSetup.functions.schemaSetup.output.arn\n });\n }\n\n // Only add `dynamoDbOpensearchTable` output if using search engine (ES/OS).\n if (searchEngineParams) {\n app.addOutputs({\n dynamoDbOpensearchTable: core.opensearchDynamodbTableName\n });\n }\n\n app.addHandler(() => {\n addDomainsUrlsOutputs({\n app,\n cloudfrontDistribution: cloudfront,\n map: {\n distributionDomain: \"cloudfrontApiDomain\",\n distributionUrl: \"cloudfrontApiUrl\",\n usedDomain: \"apiDomain\",\n usedUrl: \"apiUrl\"\n }\n });\n });\n // /**\n // * We need to attach the Sync System if it exists.\n // */\n // await attachSyncSystem({\n // app,\n // core,\n // env: app.params.run.env\n // });\n\n // Applies internal and user-defined AWS tags.\n await applyAwsResourceTags(\"api\");\n\n return {\n fileManager,\n graphql,\n graphqlStream,\n graphqlWeb,\n apiGateway,\n websocket,\n cloudfront,\n backgroundTask,\n scheduler,\n schemaSetup\n };\n }\n });\n\n const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp), async manifests => {\n // With Postgres, the schema-setup invocation stores them (see `ApiSchemaSetup` above).\n if (await projectUsesPostgres()) {\n return;\n }\n addServiceManifestTableItems(baseApp, manifests);\n });\n\n app.addHandler(() => {\n for (const manifest of createApiServiceManifests(baseApp.resources)) {\n app.addServiceManifest(manifest);\n }\n });\n\n return app;\n};\n\n/**\n * The HTTP API Gateway, used only with `<Infra.Api.WebFunction enabled={false} />`.\n */\nfunction createApiGateway(app: PulumiApp, graphql: ApiGraphql, fileManager: ApiFileManager) {\n return 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 \"private-any\": {\n path: \"/private/{path+}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n },\n \"cms-post\": {\n path: \"/cms/{key+}\",\n method: \"POST\",\n function: graphql.functions.graphql.output.arn\n },\n \"cms-options\": {\n path: \"/cms/{key+}\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"redirects-get\": {\n path: \"/wb/redirects\",\n method: \"GET\",\n function: graphql.functions.graphql.output.arn\n },\n \"redirects-options\": {\n path: \"/wb/redirects\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"files-catch-all\": {\n path: \"/{path+}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n }\n });\n}\n"],"names":["createApiPulumiApp","baseApp","createPulumiApp","app","sdk","getAwsProjectSdk","projectConfig","pulumiResourceNamePrefix","vpcExtensionsConfig","getVpcConfigFromExtension","openSearchExtensionConfig","getOsConfigFromExtension","postgresConfig","getPostgresConfigFromExtension","usesPostgres","Boolean","hasTenantStorages","getTenantStoragesFromExtension","searchEngineParams","params","process","resource","featureFlags","usingAdvancedVpcParams","handleGuardDutyEvents","onResource","addResource","useExistingVpc","Error","isResourceOfType","aws","canUseVpc","apiPulumi","SetApiCustomDomains","DefaultSetApiCustomDomains","pulumiHandlers","ApiPulumi","isProduction","core","CoreOutput","vpcEnabled","isVpcEnabled","vpcConfig","VpcConfig","dynamoDbEnv","getDynamoDbLambdaEnv","graphqlEnv","getEnvVariableAwsRegion","getPostgresLambdaEnvFromCore","getTenantStoragesLambdaEnvFromCore","graphql","ApiGraphql","graphqlStream","ApiGraphqlStream","webFunctionEnabled","isWebFunctionEnabled","graphqlWeb","graphqlWebVpc","functionVpcConfig","subnetIds","pulumi","securityGroupIds","ApiGraphqlWeb","getPostgresWebFunctionEnv","POSTGRES_DEFAULT_POOL_SIZE","undefined","websocket","ApiWebsocket","fileManager","ApiFileManager","pick","apiGateway","createApiGateway","cloudfront","ApiCloudfront","backgroundTask","ApiBackgroundTask","scheduler","ApiScheduler","schemaSetup","ApiSchemaSetup","output","coreManifests","apiManifests","getSchemaSetupServiceManifests","apiCustomDomains","apiCustomDomainsExt","domains","sslMethod","certificateArn","minimumProtocolVersion","applyCustomDomain","getAwsAccountId","addDynamoDbOutputs","addDomainsUrlsOutputs","applyAwsResourceTags","withServiceManifest","withCommonLambdaEnvVariables","manifests","projectUsesPostgres","addServiceManifestTableItems","manifest","createApiServiceManifests","ApiGateway"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DO,MAAMA,qBAAqB;IAC9B,MAAMC,UAAUC,gBAAgB;QAC5B,MAAM;QACN,MAAM;QACN,SAAS,OAAOC;YACZ,MAAMC,MAAM,MAAMC;YAClB,MAAMC,gBAAgB,MAAMF,IAAI,gBAAgB;YAEhD,MAAMG,2BAA2B,MAAMH,IAAI,2BAA2B;YACtE,MAAMI,sBAAsBC,0BAA0BH;YACtD,MAAMI,4BAA4BC,yBAAyBL;YAC3D,MAAMM,iBAAiBC,+BAA+BP;YACtD,MAAMQ,eAAeC,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SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;QACvD;IACJ;AACJ"}
|
|
@@ -40,9 +40,20 @@ export interface ICoreOutput {
|
|
|
40
40
|
pgUser: string | undefined;
|
|
41
41
|
pgSecretArn: string | undefined;
|
|
42
42
|
serviceManifests: ServiceManifest[] | undefined;
|
|
43
|
+
storages: TenantStorageOutput[] | undefined;
|
|
43
44
|
}
|
|
44
45
|
declare const POSTGRES_OUTPUTS: readonly ["pgWriterHost", "pgReaderHost", "pgProxyHost", "pgPort", "pgDatabase", "pgUser", "pgSecretArn"];
|
|
45
46
|
export type PostgresOutputs = Pick<ICoreOutput, (typeof POSTGRES_OUTPUTS)[number]>;
|
|
47
|
+
/**
|
|
48
|
+
* One storage in the core stack's `storages` output (`AddTenantStorages`): what the deploy guard
|
|
49
|
+
* compares (`EnsureStoragesNotRemoved`) and what the api app connects with. No password: the API reads
|
|
50
|
+
* it from the storage's secret.
|
|
51
|
+
*/
|
|
52
|
+
export interface TenantStorageOutput extends PostgresOutputs {
|
|
53
|
+
id: string;
|
|
54
|
+
label: string;
|
|
55
|
+
retired: boolean;
|
|
56
|
+
}
|
|
46
57
|
export declare const pickPostgresOutputs: (output: Record<string, unknown>) => PostgresOutputs;
|
|
47
58
|
export declare const CoreOutput: import("@webiny/pulumi").PulumiAppModuleDefinition<import("@pulumi/pulumi").Output<import("@pulumi/pulumi").UnwrappedObject<ICoreOutput>>, void>;
|
|
48
59
|
export {};
|
|
@@ -44,7 +44,8 @@ const CoreOutput = createAppModule({
|
|
|
44
44
|
opensearchDynamodbTableArn: output["opensearchDynamodbTableArn"],
|
|
45
45
|
opensearchDynamodbTableName: output["opensearchDynamodbTableName"],
|
|
46
46
|
...pickPostgresOutputs(output),
|
|
47
|
-
serviceManifests: output["serviceManifests"]
|
|
47
|
+
serviceManifests: output["serviceManifests"],
|
|
48
|
+
storages: output["storages"] ?? []
|
|
48
49
|
};
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/common/CoreOutput.js","sources":["../../../../src/pulumi/apps/common/CoreOutput.ts"],"sourcesContent":["import { createAppModule, type PulumiAppModule } from \"@webiny/pulumi\";\nimport { getAwsProjectSdk } from \"~/pulumi/getAwsProjectSdk.js\";\nimport type { ApiStackOutputService } from \"@webiny/project-extensions-aws/abstractions/services/ApiStackOutputService.js\";\nimport type { ServiceManifest } from \"~/pulumi/utils/addServiceManifestTableItem.js\";\n\nexport type CoreOutput = PulumiAppModule<typeof CoreOutput>;\n\nexport interface ICoreOutput {\n deploymentId: string;\n region: string;\n dynamoDbTable: string;\n iotAuthorizerName: string;\n cognitoUserPoolArn: string;\n cognitoAppClientId: string;\n cognitoUserPoolId: string;\n cognitoUserPoolPasswordPolicy: ApiStackOutputService.PasswordPolicy;\n fileManagerBucketId: string;\n fileManagerBucketArn: string;\n /*\n * The core's DynamoDB tables. Absent with `<Infra.
|
|
1
|
+
{"version":3,"file":"pulumi/apps/common/CoreOutput.js","sources":["../../../../src/pulumi/apps/common/CoreOutput.ts"],"sourcesContent":["import { createAppModule, type PulumiAppModule } from \"@webiny/pulumi\";\nimport { getAwsProjectSdk } from \"~/pulumi/getAwsProjectSdk.js\";\nimport type { ApiStackOutputService } from \"@webiny/project-extensions-aws/abstractions/services/ApiStackOutputService.js\";\nimport type { ServiceManifest } from \"~/pulumi/utils/addServiceManifestTableItem.js\";\n\nexport type CoreOutput = PulumiAppModule<typeof CoreOutput>;\n\nexport interface ICoreOutput {\n deploymentId: string;\n region: string;\n dynamoDbTable: string;\n iotAuthorizerName: string;\n cognitoUserPoolArn: string;\n cognitoAppClientId: string;\n cognitoUserPoolId: string;\n cognitoUserPoolPasswordPolicy: ApiStackOutputService.PasswordPolicy;\n fileManagerBucketId: string;\n fileManagerBucketArn: string;\n /*\n * The core's DynamoDB tables. Absent with `<Infra.AuroraPostgres />`: the core creates none.\n * The types stay non-optional so existing `CorePulumi` / `ApiPulumi` code keeps compiling.\n */\n primaryDynamodbTableArn: string;\n primaryDynamodbTableName: string;\n primaryDynamodbTableHashKey: string;\n primaryDynamodbTableRangeKey: string;\n auditLogsDynamodbTableArn: string;\n auditLogsDynamodbTableName: string;\n auditLogsDynamodbTableHashKey: string;\n auditLogsDynamodbTableRangeKey: string;\n eventBusName: string;\n eventBusArn: string;\n vpcPublicSubnetIds: string[] | undefined;\n vpcPrivateSubnetIds: string[] | undefined;\n vpcSecurityGroupIds: string[] | undefined;\n opensearchDomainArn: string | undefined;\n opensearchDomainEndpoint: string | undefined;\n opensearchDynamodbTableHashKey: string;\n opensearchDynamodbTableRangeKey: string;\n opensearchDynamodbTableArn: string | undefined;\n opensearchDynamodbTableName: string | undefined;\n /*\n * Set with `<Infra.AuroraPostgres />`. The password is in the `pgSecretArn` secret, never here.\n * `pgProxyHost` is set with `<Infra.AuroraPostgres rdsProxy />` only.\n */\n pgWriterHost: string | undefined;\n pgReaderHost: string | undefined;\n pgProxyHost: string | undefined;\n pgPort: number | undefined;\n pgDatabase: string | undefined;\n pgUser: string | undefined;\n pgSecretArn: string | undefined;\n /*\n * Set with `<Infra.AuroraPostgres />`: the core's service manifests (`core`, and any a\n * `CorePulumi` extension adds). The core deploys before the api's schema-setup function exists,\n * so the api deploy stores them in the database.\n */\n serviceManifests: ServiceManifest[] | undefined;\n /*\n * Every `<Infra.TenantStorage.AuroraPostgres>`, with its cluster's connection outputs. An empty\n * list without declarations; absent on a core deployed before tenant storages existed.\n */\n storages: TenantStorageOutput[] | undefined;\n}\n\nconst POSTGRES_OUTPUTS = [\n \"pgWriterHost\",\n \"pgReaderHost\",\n \"pgProxyHost\",\n \"pgPort\",\n \"pgDatabase\",\n \"pgUser\",\n \"pgSecretArn\"\n] as const;\n\nexport type PostgresOutputs = Pick<ICoreOutput, (typeof POSTGRES_OUTPUTS)[number]>;\n\n/**\n * One storage in the core stack's `storages` output (`AddTenantStorages`): what the deploy guard\n * compares (`EnsureStoragesNotRemoved`) and what the api app connects with. No password: the API reads\n * it from the storage's secret.\n */\nexport interface TenantStorageOutput extends PostgresOutputs {\n id: string;\n label: string;\n retired: boolean;\n}\n\n/* The Postgres connection outputs of the core stack, for the API app. No password among them. */\nexport const pickPostgresOutputs = (output: Record<string, unknown>): PostgresOutputs => {\n return Object.fromEntries(\n POSTGRES_OUTPUTS.map(name => [name, output[name]])\n ) as unknown as PostgresOutputs;\n};\n\nexport const CoreOutput = createAppModule({\n name: \"CoreOutput\",\n config(app) {\n return app.addHandler(async () => {\n const sdk = await getAwsProjectSdk();\n\n const output = await sdk.getAppStackOutput(\"core\");\n if (!output) {\n throw new Error(\"Core application is not deployed.\");\n }\n\n return {\n fileManagerBucketId: output[\"fileManagerBucketId\"],\n primaryDynamodbTableArn: output[\"primaryDynamodbTableArn\"],\n primaryDynamodbTableName: output[\"primaryDynamodbTableName\"],\n primaryDynamodbTableHashKey: output[\"primaryDynamodbTableHashKey\"],\n primaryDynamodbTableRangeKey: output[\"primaryDynamodbTableRangeKey\"],\n auditLogsDynamodbTableArn: output[\"auditLogsDynamodbTableArn\"],\n auditLogsDynamodbTableName: output[\"auditLogsDynamodbTableName\"],\n auditLogsDynamodbTableHashKey: output[\"auditLogsDynamodbTableHashKey\"],\n auditLogsDynamodbTableRangeKey: output[\"auditLogsDynamodbTableRangeKey\"],\n cognitoUserPoolId: output[\"cognitoUserPoolId\"],\n cognitoUserPoolArn: output[\"cognitoUserPoolArn\"],\n cognitoUserPoolPasswordPolicy: output[\"cognitoUserPoolPasswordPolicy\"],\n cognitoAppClientId: output[\"cognitoAppClientId\"],\n eventBusName: output[\"eventBusName\"],\n eventBusArn: output[\"eventBusArn\"],\n // These outputs are optional, since VPC is not always enabled.\n vpcPublicSubnetIds: output[\"vpcPublicSubnetIds\"],\n vpcPrivateSubnetIds: output[\"vpcPrivateSubnetIds\"],\n vpcSecurityGroupIds: output[\"vpcSecurityGroupIds\"],\n // These outputs are optional, since Opensearch is not always enabled.\n opensearchDomainArn: output[\"opensearchDomainArn\"],\n opensearchDomainEndpoint: output[\"opensearchDomainEndpoint\"],\n opensearchDynamodbTableArn: output[\"opensearchDynamodbTableArn\"],\n opensearchDynamodbTableName: output[\"opensearchDynamodbTableName\"],\n // These outputs are optional, since Postgres is not always enabled.\n ...pickPostgresOutputs(output),\n serviceManifests: output[\"serviceManifests\"],\n // Every `<Infra.TenantStorage.AuroraPostgres>`; none on an older core.\n storages: output[\"storages\"] ?? []\n } as ICoreOutput;\n });\n }\n});\n"],"names":["POSTGRES_OUTPUTS","pickPostgresOutputs","output","Object","name","CoreOutput","createAppModule","app","sdk","getAwsProjectSdk","Error"],"mappings":";;AAiEA,MAAMA,mBAAmB;IACrB;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAgBM,MAAMC,sBAAsB,CAACC,SACzBC,OAAO,WAAW,CACrBH,iBAAiB,GAAG,CAACI,CAAAA,OAAQ;YAACA;YAAMF,MAAM,CAACE,KAAK;SAAC;AAIlD,MAAMC,aAAaC,gBAAgB;IACtC,MAAM;IACN,QAAOC,GAAG;QACN,OAAOA,IAAI,UAAU,CAAC;YAClB,MAAMC,MAAM,MAAMC;YAElB,MAAMP,SAAS,MAAMM,IAAI,iBAAiB,CAAC;YAC3C,IAAI,CAACN,QACD,MAAM,IAAIQ,MAAM;YAGpB,OAAO;gBACH,qBAAqBR,MAAM,CAAC,sBAAsB;gBAClD,yBAAyBA,MAAM,CAAC,0BAA0B;gBAC1D,0BAA0BA,MAAM,CAAC,2BAA2B;gBAC5D,6BAA6BA,MAAM,CAAC,8BAA8B;gBAClE,8BAA8BA,MAAM,CAAC,+BAA+B;gBACpE,2BAA2BA,MAAM,CAAC,4BAA4B;gBAC9D,4BAA4BA,MAAM,CAAC,6BAA6B;gBAChE,+BAA+BA,MAAM,CAAC,gCAAgC;gBACtE,gCAAgCA,MAAM,CAAC,iCAAiC;gBACxE,mBAAmBA,MAAM,CAAC,oBAAoB;gBAC9C,oBAAoBA,MAAM,CAAC,qBAAqB;gBAChD,+BAA+BA,MAAM,CAAC,gCAAgC;gBACtE,oBAAoBA,MAAM,CAAC,qBAAqB;gBAChD,cAAcA,MAAM,CAAC,eAAe;gBACpC,aAAaA,MAAM,CAAC,cAAc;gBAElC,oBAAoBA,MAAM,CAAC,qBAAqB;gBAChD,qBAAqBA,MAAM,CAAC,sBAAsB;gBAClD,qBAAqBA,MAAM,CAAC,sBAAsB;gBAElD,qBAAqBA,MAAM,CAAC,sBAAsB;gBAClD,0BAA0BA,MAAM,CAAC,2BAA2B;gBAC5D,4BAA4BA,MAAM,CAAC,6BAA6B;gBAChE,6BAA6BA,MAAM,CAAC,8BAA8B;gBAElE,GAAGD,oBAAoBC,OAAO;gBAC9B,kBAAkBA,MAAM,CAAC,mBAAmB;gBAE5C,UAAUA,MAAM,CAAC,WAAW,IAAI,EAAE;YACtC;QACJ;IACJ;AACJ"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as aws from "@pulumi/aws";
|
|
2
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
1
3
|
import { type PulumiAppModule } from "@webiny/pulumi";
|
|
2
4
|
export interface CoreCognitoParams {
|
|
3
5
|
protect: boolean;
|
|
@@ -5,6 +7,18 @@ export interface CoreCognitoParams {
|
|
|
5
7
|
mfa?: boolean;
|
|
6
8
|
}
|
|
7
9
|
export type CoreCognito = PulumiAppModule<typeof CoreCognito>;
|
|
10
|
+
/**
|
|
11
|
+
* Attributes that users must never change themselves. `custom:id` is the Webiny identity id:
|
|
12
|
+
* a user who could write it would sign in as any other user. Webiny sets it with Cognito admin
|
|
13
|
+
* APIs, which `writeAttributes` doesn't restrict.
|
|
14
|
+
*/
|
|
15
|
+
export declare const USER_PROTECTED_ATTRIBUTES: string[];
|
|
16
|
+
/**
|
|
17
|
+
* Everything users could write before (all standard and all custom attributes of the pool,
|
|
18
|
+
* including custom attributes a project adds to the schema), except the protected ones.
|
|
19
|
+
* Cognito has no deny list for app clients, so the allowed list is built from the pool schema.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getUserWritableAttributes: (schemas: pulumi.Input<aws.types.input.cognito.UserPoolSchema[] | undefined>) => pulumi.Output<string[]>;
|
|
8
22
|
export declare const CoreCognito: import("@webiny/pulumi").PulumiAppModuleDefinition<{
|
|
9
23
|
userPool: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cognito/userPool").UserPool>;
|
|
10
24
|
userPoolClient: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cognito/userPoolClient").UserPoolClient>;
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import { createAppModule } from "@webiny/pulumi";
|
|
2
2
|
import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
|
|
3
|
+
import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
|
|
4
|
+
const STANDARD_USER_WRITABLE_ATTRIBUTES = [
|
|
5
|
+
"address",
|
|
6
|
+
"birthdate",
|
|
7
|
+
"email",
|
|
8
|
+
"family_name",
|
|
9
|
+
"gender",
|
|
10
|
+
"given_name",
|
|
11
|
+
"locale",
|
|
12
|
+
"middle_name",
|
|
13
|
+
"name",
|
|
14
|
+
"nickname",
|
|
15
|
+
"phone_number",
|
|
16
|
+
"picture",
|
|
17
|
+
"preferred_username",
|
|
18
|
+
"profile",
|
|
19
|
+
"updated_at",
|
|
20
|
+
"website",
|
|
21
|
+
"zoneinfo"
|
|
22
|
+
];
|
|
23
|
+
const USER_PROTECTED_ATTRIBUTES = [
|
|
24
|
+
"custom:id"
|
|
25
|
+
];
|
|
26
|
+
const getUserWritableAttributes = (schemas)=>__rspack_external__pulumi_pulumi_f3e773ed.output(schemas).apply((items)=>{
|
|
27
|
+
const custom = (items || []).map((schema)=>schema.name).filter((name)=>!STANDARD_USER_WRITABLE_ATTRIBUTES.includes(name)).filter((name)=>!name.endsWith("_verified")).map((name)=>name.startsWith("custom:") ? name : `custom:${name}`);
|
|
28
|
+
return [
|
|
29
|
+
...new Set([
|
|
30
|
+
...STANDARD_USER_WRITABLE_ATTRIBUTES,
|
|
31
|
+
...custom
|
|
32
|
+
])
|
|
33
|
+
].filter((name)=>!USER_PROTECTED_ATTRIBUTES.includes(name));
|
|
34
|
+
});
|
|
3
35
|
const CoreCognito = createAppModule({
|
|
4
36
|
name: "Cognito",
|
|
5
37
|
config (app, params) {
|
|
@@ -103,6 +135,7 @@ const CoreCognito = createAppModule({
|
|
|
103
135
|
name: "user-pool-client",
|
|
104
136
|
config: {
|
|
105
137
|
userPoolId: userPool.output.id,
|
|
138
|
+
writeAttributes: getUserWritableAttributes(userPool.output.schemas),
|
|
106
139
|
accessTokenValidity: 60,
|
|
107
140
|
idTokenValidity: 60,
|
|
108
141
|
refreshTokenValidity: 30,
|
|
@@ -119,6 +152,6 @@ const CoreCognito = createAppModule({
|
|
|
119
152
|
};
|
|
120
153
|
}
|
|
121
154
|
});
|
|
122
|
-
export { CoreCognito };
|
|
155
|
+
export { CoreCognito, USER_PROTECTED_ATTRIBUTES, getUserWritableAttributes };
|
|
123
156
|
|
|
124
157
|
//# sourceMappingURL=CoreCognito.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/CoreCognito.js","sources":["../../../../src/pulumi/apps/core/CoreCognito.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { createAppModule, type PulumiApp, type PulumiAppModule } from \"@webiny/pulumi\";\n\nexport interface CoreCognitoParams {\n protect: boolean;\n useEmailAsUsername: boolean;\n mfa?: boolean;\n}\n\nexport type CoreCognito = PulumiAppModule<typeof CoreCognito>;\n\nexport const CoreCognito = createAppModule({\n name: \"Cognito\",\n config(app: PulumiApp, params: CoreCognitoParams) {\n const userPool = app.addResource(aws.cognito.UserPool, {\n name: \"user-pool\",\n config: {\n passwordPolicy: {\n minimumLength: 8,\n requireLowercase: false,\n requireNumbers: false,\n requireSymbols: false,\n requireUppercase: false,\n temporaryPasswordValidityDays: 7\n },\n adminCreateUserConfig: {\n allowAdminCreateUserOnly: true\n },\n autoVerifiedAttributes: [\"email\"],\n emailConfiguration: {\n emailSendingAccount: \"COGNITO_DEFAULT\"\n },\n // In a legacy setup we use email as username.\n // We need to provide a way for users to have this setup,\n // because changing it would require whole cognito pool to be recreated.\n usernameAttributes: params.useEmailAsUsername ? [\"email\"] : undefined,\n aliasAttributes: params.useEmailAsUsername ? undefined : [\"preferred_username\"],\n lambdaConfig: {},\n mfaConfiguration: params.mfa ? \"ON\" : \"OFF\",\n softwareTokenMfaConfiguration: params.mfa ? { enabled: true } : undefined,\n userPoolAddOns: {\n advancedSecurityMode: \"OFF\" /* required */\n },\n verificationMessageTemplate: {\n defaultEmailOption: \"CONFIRM_WITH_CODE\"\n },\n accountRecoverySetting: {\n recoveryMechanisms: [{ name: \"verified_email\", priority: 1 }]\n },\n schemas: [\n {\n attributeDataType: \"String\",\n name: \"email\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"family_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"given_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"id\",\n required: false,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"36\",\n minLength: \"0\"\n }\n }\n ]\n },\n opts: {\n protect: params.protect\n }\n });\n\n const userPoolClient = app.addResource(aws.cognito.UserPoolClient, {\n name: \"user-pool-client\",\n config: {\n userPoolId: userPool.output.id,\n accessTokenValidity: 60,\n idTokenValidity: 60,\n refreshTokenValidity: 30,\n tokenValidityUnits: {\n accessToken: \"minutes\",\n idToken: \"minutes\",\n refreshToken: \"days\"\n }\n }\n });\n\n return {\n userPool,\n userPoolClient\n };\n }\n});\n"],"names":["CoreCognito","createAppModule","app","params","userPool","aws","undefined","userPoolClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/CoreCognito.js","sources":["../../../../src/pulumi/apps/core/CoreCognito.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { createAppModule, type PulumiApp, type PulumiAppModule } from \"@webiny/pulumi\";\n\nexport interface CoreCognitoParams {\n protect: boolean;\n useEmailAsUsername: boolean;\n mfa?: boolean;\n}\n\nexport type CoreCognito = PulumiAppModule<typeof CoreCognito>;\n\n/**\n * Standard attributes users may change themselves (with their own access token). The\n * `*_verified` flags are left out, so users can't mark an address they don't own as verified.\n */\nconst STANDARD_USER_WRITABLE_ATTRIBUTES = [\n \"address\",\n \"birthdate\",\n \"email\",\n \"family_name\",\n \"gender\",\n \"given_name\",\n \"locale\",\n \"middle_name\",\n \"name\",\n \"nickname\",\n \"phone_number\",\n \"picture\",\n \"preferred_username\",\n \"profile\",\n \"updated_at\",\n \"website\",\n \"zoneinfo\"\n];\n\n/**\n * Attributes that users must never change themselves. `custom:id` is the Webiny identity id:\n * a user who could write it would sign in as any other user. Webiny sets it with Cognito admin\n * APIs, which `writeAttributes` doesn't restrict.\n */\nexport const USER_PROTECTED_ATTRIBUTES = [\"custom:id\"];\n\n/**\n * Everything users could write before (all standard and all custom attributes of the pool,\n * including custom attributes a project adds to the schema), except the protected ones.\n * Cognito has no deny list for app clients, so the allowed list is built from the pool schema.\n */\nexport const getUserWritableAttributes = (\n schemas: pulumi.Input<aws.types.input.cognito.UserPoolSchema[] | undefined>\n): pulumi.Output<string[]> => {\n return pulumi.output(schemas).apply(items => {\n const custom = (items || [])\n .map(schema => schema.name)\n .filter(name => !STANDARD_USER_WRITABLE_ATTRIBUTES.includes(name))\n .filter(name => !name.endsWith(\"_verified\"))\n .map(name => (name.startsWith(\"custom:\") ? name : `custom:${name}`));\n\n return [...new Set([...STANDARD_USER_WRITABLE_ATTRIBUTES, ...custom])].filter(name => {\n return !USER_PROTECTED_ATTRIBUTES.includes(name);\n });\n });\n};\n\nexport const CoreCognito = createAppModule({\n name: \"Cognito\",\n config(app: PulumiApp, params: CoreCognitoParams) {\n const userPool = app.addResource(aws.cognito.UserPool, {\n name: \"user-pool\",\n config: {\n passwordPolicy: {\n minimumLength: 8,\n requireLowercase: false,\n requireNumbers: false,\n requireSymbols: false,\n requireUppercase: false,\n temporaryPasswordValidityDays: 7\n },\n adminCreateUserConfig: {\n allowAdminCreateUserOnly: true\n },\n autoVerifiedAttributes: [\"email\"],\n emailConfiguration: {\n emailSendingAccount: \"COGNITO_DEFAULT\"\n },\n // In a legacy setup we use email as username.\n // We need to provide a way for users to have this setup,\n // because changing it would require whole cognito pool to be recreated.\n usernameAttributes: params.useEmailAsUsername ? [\"email\"] : undefined,\n aliasAttributes: params.useEmailAsUsername ? undefined : [\"preferred_username\"],\n lambdaConfig: {},\n mfaConfiguration: params.mfa ? \"ON\" : \"OFF\",\n softwareTokenMfaConfiguration: params.mfa ? { enabled: true } : undefined,\n userPoolAddOns: {\n advancedSecurityMode: \"OFF\" /* required */\n },\n verificationMessageTemplate: {\n defaultEmailOption: \"CONFIRM_WITH_CODE\"\n },\n accountRecoverySetting: {\n recoveryMechanisms: [{ name: \"verified_email\", priority: 1 }]\n },\n schemas: [\n {\n attributeDataType: \"String\",\n name: \"email\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"family_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"given_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"id\",\n required: false,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"36\",\n minLength: \"0\"\n }\n }\n ]\n },\n opts: {\n protect: params.protect\n }\n });\n\n const userPoolClient = app.addResource(aws.cognito.UserPoolClient, {\n name: \"user-pool-client\",\n config: {\n userPoolId: userPool.output.id,\n writeAttributes: getUserWritableAttributes(userPool.output.schemas),\n accessTokenValidity: 60,\n idTokenValidity: 60,\n refreshTokenValidity: 30,\n tokenValidityUnits: {\n accessToken: \"minutes\",\n idToken: \"minutes\",\n refreshToken: \"days\"\n }\n }\n });\n\n return {\n userPool,\n userPoolClient\n };\n }\n});\n"],"names":["STANDARD_USER_WRITABLE_ATTRIBUTES","USER_PROTECTED_ATTRIBUTES","getUserWritableAttributes","schemas","pulumi","items","custom","schema","name","Set","CoreCognito","createAppModule","app","params","userPool","aws","undefined","userPoolClient"],"mappings":";;;AAgBA,MAAMA,oCAAoC;IACtC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAOM,MAAMC,4BAA4B;IAAC;CAAY;AAO/C,MAAMC,4BAA4B,CACrCC,UAEOC,0CAAAA,MAAa,CAACD,SAAS,KAAK,CAACE,CAAAA;QAChC,MAAMC,SAAUD,AAAAA,CAAAA,SAAS,EAAC,EACrB,GAAG,CAACE,CAAAA,SAAUA,OAAO,IAAI,EACzB,MAAM,CAACC,CAAAA,OAAQ,CAACR,kCAAkC,QAAQ,CAACQ,OAC3D,MAAM,CAACA,CAAAA,OAAQ,CAACA,KAAK,QAAQ,CAAC,cAC9B,GAAG,CAACA,CAAAA,OAASA,KAAK,UAAU,CAAC,aAAaA,OAAO,CAAC,OAAO,EAAEA,MAAM;QAEtE,OAAO;eAAI,IAAIC,IAAI;mBAAIT;mBAAsCM;aAAO;SAAE,CAAC,MAAM,CAACE,CAAAA,OACnE,CAACP,0BAA0B,QAAQ,CAACO;I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