@webiny/project-aws 6.6.0-alpha.13 → 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.
Files changed (66) hide show
  1. package/_templates/extensions/TenantStorages/ddb/api/graphql/src/index.ts +25 -0
  2. package/_templates/extensions/TenantStorages/ddb/api/graphql/src/web.ts +17 -0
  3. package/_templates/extensions/TenantStorages/ddb-os/api/graphql/src/index.ts +25 -0
  4. package/_templates/extensions/TenantStorages/ddb-os/api/graphql/src/web.ts +17 -0
  5. package/_templates/extensions/TenantStorages/pg/api/graphql/src/index.ts +25 -0
  6. package/_templates/extensions/TenantStorages/pg/api/graphql/src/web.ts +16 -0
  7. package/extensions/OpenSearch/ReplaceApiLambdaFnHandlers.d.ts +3 -2
  8. package/extensions/OpenSearch/ReplaceApiLambdaFnHandlers.js +7 -3
  9. package/extensions/OpenSearch/ReplaceApiLambdaFnHandlers.js.map +1 -1
  10. package/extensions/Postgres/ReplaceApiLambdaFnHandlers.d.ts +3 -2
  11. package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js +6 -2
  12. package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js.map +1 -1
  13. package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js +6 -8
  14. package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js.map +1 -1
  15. package/extensions/Postgres/assertPostgresNetwork.d.ts +19 -0
  16. package/extensions/Postgres/assertPostgresNetwork.js +16 -0
  17. package/extensions/Postgres/assertPostgresNetwork.js.map +1 -0
  18. package/extensions/Postgres/copyPgRuntimeModules.js +1 -1
  19. package/extensions/Postgres/copyPgRuntimeModules.js.map +1 -1
  20. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.d.ts +17 -2
  21. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js +26 -19
  22. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js.map +1 -1
  23. package/extensions/ProjectAws/TenantStorages/AddTenantStorages.d.ts +34 -0
  24. package/extensions/ProjectAws/TenantStorages/AddTenantStorages.js +55 -0
  25. package/extensions/ProjectAws/TenantStorages/AddTenantStorages.js.map +1 -0
  26. package/extensions/ProjectAws/TenantStorages/ApplyTenantStoragesApiEntry.d.ts +26 -0
  27. package/extensions/ProjectAws/TenantStorages/ApplyTenantStoragesApiEntry.js +49 -0
  28. package/extensions/ProjectAws/TenantStorages/ApplyTenantStoragesApiEntry.js.map +1 -0
  29. package/extensions/ProjectAws/TenantStorages/CopyPgModulesForTenantStorages.d.ts +17 -0
  30. package/extensions/ProjectAws/TenantStorages/CopyPgModulesForTenantStorages.js +26 -0
  31. package/extensions/ProjectAws/TenantStorages/CopyPgModulesForTenantStorages.js.map +1 -0
  32. package/extensions/ProjectAws/TenantStorages/EnsureStoragesNotRemoved.d.ts +41 -0
  33. package/extensions/ProjectAws/TenantStorages/EnsureStoragesNotRemoved.js +55 -0
  34. package/extensions/ProjectAws/TenantStorages/EnsureStoragesNotRemoved.js.map +1 -0
  35. package/extensions/ProjectAws/TenantStorages/ValidateTenantStoragesBeforeCoreDeploy.d.ts +48 -0
  36. package/extensions/ProjectAws/TenantStorages/ValidateTenantStoragesBeforeCoreDeploy.js +78 -0
  37. package/extensions/ProjectAws/TenantStorages/ValidateTenantStoragesBeforeCoreDeploy.js.map +1 -0
  38. package/extensions/ProjectAws.js +11 -1
  39. package/extensions/ProjectAws.js.map +1 -1
  40. package/infra.d.ts +11 -0
  41. package/infra.js +4 -1
  42. package/infra.js.map +1 -1
  43. package/package.json +12 -12
  44. package/project.d.ts +3 -2
  45. package/pulumi/apps/api/ApiSchemaSetup.d.ts +34 -12
  46. package/pulumi/apps/api/ApiSchemaSetup.js +30 -7
  47. package/pulumi/apps/api/ApiSchemaSetup.js.map +1 -1
  48. package/pulumi/apps/api/createApiPulumiApp.js +14 -7
  49. package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
  50. package/pulumi/apps/common/CoreOutput.d.ts +11 -0
  51. package/pulumi/apps/common/CoreOutput.js +2 -1
  52. package/pulumi/apps/common/CoreOutput.js.map +1 -1
  53. package/pulumi/apps/core/CorePostgres.d.ts +2 -0
  54. package/pulumi/apps/core/CorePostgres.js +24 -19
  55. package/pulumi/apps/core/CorePostgres.js.map +1 -1
  56. package/pulumi/apps/core/coreVpcEndpoints.d.ts +7 -0
  57. package/pulumi/apps/core/coreVpcEndpoints.js +15 -11
  58. package/pulumi/apps/core/coreVpcEndpoints.js.map +1 -1
  59. package/pulumi/apps/core/createCorePulumiApp.js +8 -1
  60. package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
  61. package/pulumi/apps/extensions/getTenantStoragesFromExtension.d.ts +19 -0
  62. package/pulumi/apps/extensions/getTenantStoragesFromExtension.js +32 -0
  63. package/pulumi/apps/extensions/getTenantStoragesFromExtension.js.map +1 -0
  64. package/pulumi/extensions/index.d.ts +8 -0
  65. package/pulumi/extensions/index.js +2 -1
  66. package/pulumi/extensions/index.js.map +1 -1
@@ -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.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\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.AuroraPostgres />`, 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.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`.\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.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","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,M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":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;Q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;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,UAAUkB,YAAY,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.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\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/* 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 } as ICoreOutput;\n });\n }\n});\n"],"names":["POSTGRES_OUTPUTS","pickPostgresOutputs","output","Object","name","CoreOutput","createAppModule","app","sdk","getAwsProjectSdk","Error"],"mappings":";;AA4DA,MAAMA,mBAAmB;IACrB;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAKM,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;YAChD;QACJ;IACJ;AACJ"}
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"}
@@ -16,6 +16,8 @@ export interface CorePostgresParams {
16
16
  network: PostgresNetwork;
17
17
  protect: boolean;
18
18
  getEngineVersion?: () => pulumi.Input<string>;
19
+ namePrefix?: string;
20
+ description?: string;
19
21
  }
20
22
  /**
21
23
  * The Postgres database of a project with `<Infra.AuroraPostgres />`: an Aurora PostgreSQL 17
@@ -30,17 +30,21 @@ const CorePostgres = createAppModule({
30
30
  config (app, params) {
31
31
  const { network, protect } = params;
32
32
  const getEngineVersion = params.getEngineVersion ?? getLatestEngineVersion;
33
+ const prefix = params.namePrefix ?? "";
34
+ const name = (value)=>`${prefix}${value}`;
35
+ const database = params.description ?? "the Webiny Postgres database";
36
+ const Database = database.charAt(0).toUpperCase() + database.slice(1);
33
37
  const password = app.addResource(__rspack_external__pulumi_random_073a0f72.RandomPassword, {
34
- name: "pg-db-password",
38
+ name: name("pg-db-password"),
35
39
  config: {
36
40
  length: 32,
37
41
  special: false
38
42
  }
39
43
  });
40
44
  const secret = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.secretsmanager.Secret, {
41
- name: "pg-db",
45
+ name: name("pg-db"),
42
46
  config: {
43
- description: "Credentials of the Webiny Postgres database.",
47
+ description: `Credentials of ${database}.`,
44
48
  recoveryWindowInDays: protect ? 7 : 0
45
49
  },
46
50
  opts: {
@@ -48,7 +52,7 @@ const CorePostgres = createAppModule({
48
52
  }
49
53
  });
50
54
  app.addResource(__rspack_external__pulumi_aws_9e2bee2d.secretsmanager.SecretVersion, {
51
- name: "pg-db",
55
+ name: name("pg-db"),
52
56
  config: {
53
57
  secretId: secret.output.id,
54
58
  secretString: __rspack_external__pulumi_pulumi_f3e773ed.all([
@@ -60,17 +64,17 @@ const CorePostgres = createAppModule({
60
64
  }
61
65
  });
62
66
  const subnetGroup = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.SubnetGroup, {
63
- name: "pg-db",
67
+ name: name("pg-db"),
64
68
  config: {
65
- description: "Subnets of the Webiny Postgres database.",
69
+ description: `Subnets of ${database}.`,
66
70
  subnetIds: network.subnetIds
67
71
  }
68
72
  });
69
73
  const parameterGroup = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ClusterParameterGroup, {
70
- name: "pg-db",
74
+ name: name("pg-db"),
71
75
  config: {
72
76
  family: PARAMETER_GROUP_FAMILY,
73
- description: "Webiny Postgres database: TCP keepalives.",
77
+ description: `${Database}: TCP keepalives.`,
74
78
  parameters: [
75
79
  {
76
80
  name: "tcp_keepalives_idle",
@@ -88,13 +92,13 @@ const CorePostgres = createAppModule({
88
92
  }
89
93
  });
90
94
  const finalSnapshotSuffix = protect ? app.addResource(__rspack_external__pulumi_random_073a0f72.RandomId, {
91
- name: "pg-db-final-snapshot",
95
+ name: name("pg-db-final-snapshot"),
92
96
  config: {
93
97
  byteLength: 4
94
98
  }
95
99
  }) : null;
96
100
  const cluster = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.Cluster, {
97
- name: "pg-db",
101
+ name: name("pg-db"),
98
102
  config: {
99
103
  engine: ENGINE,
100
104
  engineMode: "provisioned",
@@ -120,7 +124,7 @@ const CorePostgres = createAppModule({
120
124
  backupRetentionPeriod: protect ? 35 : 1,
121
125
  deleteAutomatedBackups: protect ? false : void 0,
122
126
  skipFinalSnapshot: !protect,
123
- finalSnapshotIdentifier: finalSnapshotSuffix ? __rspack_external__pulumi_pulumi_f3e773ed.interpolate`webiny-pg-final-${finalSnapshotSuffix.output.hex}` : void 0,
127
+ finalSnapshotIdentifier: finalSnapshotSuffix ? __rspack_external__pulumi_pulumi_f3e773ed.interpolate`webiny-${prefix}pg-final-${finalSnapshotSuffix.output.hex}` : void 0,
124
128
  applyImmediately: true
125
129
  },
126
130
  opts: {
@@ -134,7 +138,7 @@ const CorePostgres = createAppModule({
134
138
  for(let index = 0; index <= params.readers; index++){
135
139
  const isWriter = 0 === index;
136
140
  instances.push(app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ClusterInstance, {
137
- name: isWriter ? "pg-db-writer" : `pg-db-reader-${index}`,
141
+ name: name(isWriter ? "pg-db-writer" : `pg-db-reader-${index}`),
138
142
  config: {
139
143
  clusterIdentifier: cluster.output.id,
140
144
  instanceClass: "db.serverless",
@@ -157,7 +161,8 @@ const CorePostgres = createAppModule({
157
161
  secret,
158
162
  cluster,
159
163
  instances,
160
- network
164
+ network,
165
+ prefix
161
166
  });
162
167
  return {
163
168
  cluster,
@@ -181,15 +186,15 @@ const CorePostgres = createAppModule({
181
186
  }
182
187
  });
183
188
  function addProxy(app, params) {
184
- const { secret, cluster, instances, network } = params;
189
+ const { secret, cluster, instances, network, prefix } = params;
185
190
  const role = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.Role, {
186
- name: "pg-proxy",
191
+ name: `${prefix}pg-proxy`,
187
192
  config: {
188
193
  assumeRolePolicy: assumeRolePolicy("rds.amazonaws.com")
189
194
  }
190
195
  });
191
196
  app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.RolePolicy, {
192
- name: "pg-proxy",
197
+ name: `${prefix}pg-proxy`,
193
198
  config: {
194
199
  role: role.output.id,
195
200
  policy: __rspack_external__pulumi_pulumi_f3e773ed.all([
@@ -211,7 +216,7 @@ function addProxy(app, params) {
211
216
  }
212
217
  });
213
218
  const proxy = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.Proxy, {
214
- name: "pg-proxy",
219
+ name: `${prefix}pg-proxy`,
215
220
  config: {
216
221
  engineFamily: "POSTGRESQL",
217
222
  auths: [
@@ -230,7 +235,7 @@ function addProxy(app, params) {
230
235
  }
231
236
  });
232
237
  const targetGroup = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ProxyDefaultTargetGroup, {
233
- name: "pg-proxy",
238
+ name: `${prefix}pg-proxy`,
234
239
  config: {
235
240
  dbProxyName: proxy.output.name,
236
241
  connectionPoolConfig: {
@@ -241,7 +246,7 @@ function addProxy(app, params) {
241
246
  }
242
247
  });
243
248
  app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ProxyTarget, {
244
- name: "pg-proxy",
249
+ name: `${prefix}pg-proxy`,
245
250
  config: {
246
251
  dbProxyName: proxy.output.name,
247
252
  targetGroupName: targetGroup.output.name,
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/apps/core/CorePostgres.js","sources":["../../../../src/pulumi/apps/core/CorePostgres.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as random from \"@pulumi/random\";\nimport {\n createAppModule,\n type PulumiApp,\n type PulumiAppModule,\n type PulumiAppResource\n} from \"@webiny/pulumi\";\n\nexport type CorePostgres = PulumiAppModule<typeof CorePostgres>;\n\nexport const POSTGRES_DATABASE = \"webiny\";\nexport const POSTGRES_USER = \"webiny\";\nexport const POSTGRES_PORT = 5432;\n\n/* Aurora PostgreSQL's major version, and its cluster parameter group family. */\nconst ENGINE = \"aurora-postgresql\";\nconst ENGINE_MAJOR_VERSION = \"17\";\nconst PARAMETER_GROUP_FAMILY = \"aurora-postgresql17\";\n\nexport interface PostgresNetwork {\n subnetIds: pulumi.Input<pulumi.Input<string>[]>;\n securityGroupIds: pulumi.Input<pulumi.Input<string>[]>;\n}\n\nexport interface CorePostgresParams {\n minCapacity: number;\n maxCapacity: number;\n readers: number;\n rdsProxy: boolean;\n network: PostgresNetwork;\n /*\n * On in production: deletion protection, 35 days of backups that outlive the cluster, and a\n * final snapshot.\n */\n protect: boolean;\n /*\n * The engine version a new cluster gets: the latest 17.x. Replaced in tests, where there is no\n * AWS to ask.\n */\n getEngineVersion?: () => pulumi.Input<string>;\n}\n\nconst getLatestEngineVersion = () => {\n return pulumi.output(\n aws.rds.getEngineVersion({ engine: ENGINE, version: ENGINE_MAJOR_VERSION, latest: true })\n ).versionActual;\n};\n\nconst assumeRolePolicy = (service: string) =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [{ Effect: \"Allow\", Principal: { Service: service }, Action: \"sts:AssumeRole\" }]\n });\n\n/**\n * The Postgres database of a project with `<Infra.AuroraPostgres />`: an Aurora PostgreSQL 17\n * Serverless v2 cluster with a writer and `readers` reader instances, and its credentials in a\n * Secrets Manager secret (`{ username, password }`). With `rdsProxy`, an RDS Proxy in front of it,\n * which reads the same secret.\n *\n * The cluster, its instances and the proxy go into `network`: the private subnets of the VPC the\n * core app creates and its default security group, which the API functions use too, or the\n * `postgresVpcConfig` of an existing VPC.\n *\n * No password leaves this module: the API reads it from the secret.\n */\nexport const CorePostgres = createAppModule({\n name: \"CorePostgres\",\n config(app: PulumiApp, params: CorePostgresParams) {\n const { network, protect } = params;\n const getEngineVersion = params.getEngineVersion ?? getLatestEngineVersion;\n\n const password = app.addResource(random.RandomPassword, {\n name: \"pg-db-password\",\n config: { length: 32, special: false }\n });\n\n const secret = app.addResource(aws.secretsmanager.Secret, {\n name: \"pg-db\",\n config: {\n description: \"Credentials of the Webiny Postgres database.\",\n // Outside production, a destroyed project can be deployed again at once.\n recoveryWindowInDays: protect ? 7 : 0\n },\n opts: { protect }\n });\n\n app.addResource(aws.secretsmanager.SecretVersion, {\n name: \"pg-db\",\n config: {\n secretId: secret.output.id,\n secretString: pulumi\n .all([password.output.result])\n .apply(([value]) =>\n JSON.stringify({ username: POSTGRES_USER, password: value })\n )\n }\n });\n\n const subnetGroup = app.addResource(aws.rds.SubnetGroup, {\n name: \"pg-db\",\n config: {\n description: \"Subnets of the Webiny Postgres database.\",\n subnetIds: network.subnetIds\n }\n });\n\n /*\n * The server notices a client that went away without closing its connection (a Lambda\n * environment that was recycled) within about two minutes, and frees the connection.\n */\n const parameterGroup = app.addResource(aws.rds.ClusterParameterGroup, {\n name: \"pg-db\",\n config: {\n family: PARAMETER_GROUP_FAMILY,\n description: \"Webiny Postgres database: TCP keepalives.\",\n parameters: [\n { name: \"tcp_keepalives_idle\", value: \"60\" },\n { name: \"tcp_keepalives_interval\", value: \"10\" },\n { name: \"tcp_keepalives_count\", value: \"6\" }\n ]\n }\n });\n\n // A final snapshot needs a name that no earlier snapshot of the account has.\n const finalSnapshotSuffix = protect\n ? app.addResource(random.RandomId, {\n name: \"pg-db-final-snapshot\",\n config: { byteLength: 4 }\n })\n : null;\n\n const cluster = app.addResource(aws.rds.Cluster, {\n name: \"pg-db\",\n config: {\n engine: ENGINE,\n engineMode: \"provisioned\",\n engineVersion: getEngineVersion(),\n databaseName: POSTGRES_DATABASE,\n masterUsername: POSTGRES_USER,\n masterPassword: password.output.result,\n port: POSTGRES_PORT,\n storageType: \"aurora\",\n storageEncrypted: true,\n dbSubnetGroupName: subnetGroup.output.name,\n dbClusterParameterGroupName: parameterGroup.output.name,\n vpcSecurityGroupIds: network.securityGroupIds,\n serverlessv2ScalingConfiguration: {\n minCapacity: params.minCapacity,\n maxCapacity: params.maxCapacity\n },\n enabledCloudwatchLogsExports: [\"postgresql\"],\n copyTagsToSnapshot: true,\n deletionProtection: protect,\n // Point-in-time restore is always on in Aurora; this is its window. Production\n // keeps the maximum, 35 days, the same as DynamoDB's point-in-time recovery.\n // Backup storage up to the cluster volume's size is free. Elsewhere, 1 day.\n backupRetentionPeriod: protect ? 35 : 1,\n // Production keeps its automated backups when the cluster is deleted, so it can\n // still be restored to a point in time until the window runs out. The first day is\n // free, later days are billed, and a region holds at most 40 retained automated\n // backups. Elsewhere the default (true) applies: a destroyed environment leaves\n // nothing behind.\n deleteAutomatedBackups: protect ? false : undefined,\n skipFinalSnapshot: !protect,\n finalSnapshotIdentifier: finalSnapshotSuffix\n ? pulumi.interpolate`webiny-pg-final-${finalSnapshotSuffix.output.hex}`\n : undefined,\n // Capacity changes apply now, not in the next maintenance window.\n applyImmediately: true\n },\n opts: {\n protect,\n // The version is picked when the cluster is created; AWS applies minor upgrades.\n // A newer 17.x must not make a later deploy upgrade the cluster.\n ignoreChanges: [\"engineVersion\"]\n }\n });\n\n const instances = [];\n for (let index = 0; index <= params.readers; index++) {\n const isWriter = index === 0;\n instances.push(\n app.addResource(aws.rds.ClusterInstance, {\n name: isWriter ? \"pg-db-writer\" : `pg-db-reader-${index}`,\n config: {\n clusterIdentifier: cluster.output.id,\n instanceClass: \"db.serverless\",\n engine: ENGINE,\n engineVersion: cluster.output.engineVersion,\n publiclyAccessible: false,\n performanceInsightsEnabled: true,\n // Readers in tier 0–1 scale with the writer, so a failover lands on a warm one.\n promotionTier: isWriter ? 0 : 1,\n applyImmediately: true\n },\n opts: { ignoreChanges: [\"engineVersion\"] }\n })\n );\n }\n\n let proxy: ReturnType<typeof addProxy> | null = null;\n if (params.rdsProxy) {\n proxy = addProxy(app, { secret, cluster, instances, network });\n }\n\n return {\n cluster,\n instances,\n secret,\n subnetGroup,\n parameterGroup,\n proxy: proxy?.proxy ?? null,\n outputs: {\n pgWriterHost: cluster.output.endpoint,\n pgReaderHost: cluster.output.readerEndpoint,\n ...(proxy ? { pgProxyHost: proxy.proxy.output.endpoint } : {}),\n pgPort: POSTGRES_PORT,\n pgDatabase: POSTGRES_DATABASE,\n pgUser: POSTGRES_USER,\n pgSecretArn: secret.output.arn\n }\n };\n }\n});\n\ninterface AddProxyParams {\n secret: PulumiAppResource<typeof aws.secretsmanager.Secret>;\n cluster: PulumiAppResource<typeof aws.rds.Cluster>;\n instances: PulumiAppResource<typeof aws.rds.ClusterInstance>[];\n network: PostgresNetwork;\n}\n\nfunction addProxy(app: PulumiApp, params: AddProxyParams) {\n const { secret, cluster, instances, network } = params;\n\n const role = app.addResource(aws.iam.Role, {\n name: \"pg-proxy\",\n config: { assumeRolePolicy: assumeRolePolicy(\"rds.amazonaws.com\") }\n });\n\n app.addResource(aws.iam.RolePolicy, {\n name: \"pg-proxy\",\n config: {\n role: role.output.id,\n policy: pulumi.all([secret.output.arn]).apply(([arn]) =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Action: [\"secretsmanager:GetSecretValue\"],\n Resource: [arn]\n }\n ]\n })\n )\n }\n });\n\n const proxy = app.addResource(aws.rds.Proxy, {\n name: \"pg-proxy\",\n config: {\n engineFamily: \"POSTGRESQL\",\n auths: [{ authScheme: \"SECRETS\", iamAuth: \"DISABLED\", secretArn: secret.output.arn }],\n roleArn: role.output.arn,\n vpcSubnetIds: network.subnetIds,\n vpcSecurityGroupIds: network.securityGroupIds,\n requireTls: true,\n idleClientTimeout: 900,\n debugLogging: false\n }\n });\n\n const targetGroup = app.addResource(aws.rds.ProxyDefaultTargetGroup, {\n name: \"pg-proxy\",\n config: {\n dbProxyName: proxy.output.name,\n connectionPoolConfig: {\n maxConnectionsPercent: 70,\n maxIdleConnectionsPercent: 50,\n connectionBorrowTimeout: 10\n }\n }\n });\n\n app.addResource(aws.rds.ProxyTarget, {\n name: \"pg-proxy\",\n config: {\n dbProxyName: proxy.output.name,\n targetGroupName: targetGroup.output.name,\n dbClusterIdentifier: cluster.output.id\n },\n // The proxy can only register a cluster whose instances are available.\n opts: { dependsOn: instances.map(instance => instance.output) }\n });\n\n return { role, proxy, targetGroup };\n}\n"],"names":["POSTGRES_DATABASE","POSTGRES_USER","POSTGRES_PORT","ENGINE","ENGINE_MAJOR_VERSION","PARAMETER_GROUP_FAMILY","getLatestEngineVersion","pulumi","aws","assumeRolePolicy","service","JSON","CorePostgres","createAppModule","app","params","network","protect","getEngineVersion","password","random","secret","value","subnetGroup","parameterGroup","finalSnapshotSuffix","cluster","undefined","instances","index","isWriter","proxy","addProxy","role","arn","targetGroup","instance"],"mappings":";;;;AAYO,MAAMA,oBAAoB;AAC1B,MAAMC,gBAAgB;AACtB,MAAMC,gBAAgB;AAG7B,MAAMC,SAAS;AACf,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAyB/B,MAAMC,yBAAyB,IACpBC,0CAAAA,MAAa,CAChBC,uCAAAA,GAAAA,CAAAA,gBAAwB,CAAC;QAAE,QAAQL;QAAQ,SAASC;QAAsB,QAAQ;IAAK,IACzF,aAAa;AAGnB,MAAMK,mBAAmB,CAACC,UACtBC,KAAK,SAAS,CAAC;QACX,SAAS;QACT,WAAW;YAAC;gBAAE,QAAQ;gBAAS,WAAW;oBAAE,SAASD;gBAAQ;gBAAG,QAAQ;YAAiB;SAAE;IAC/F;AAcG,MAAME,eAAeC,gBAAgB;IACxC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAA0B;QAC7C,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;QAC7B,MAAMG,mBAAmBH,OAAO,gBAAgB,IAAIT;QAEpD,MAAMa,WAAWL,IAAI,WAAW,CAACM,0CAAAA,cAAqB,EAAE;YACpD,MAAM;YACN,QAAQ;gBAAE,QAAQ;gBAAI,SAAS;YAAM;QACzC;QAEA,MAAMC,SAASP,IAAI,WAAW,CAACN,uCAAAA,cAAAA,CAAAA,MAAyB,EAAE;YACtD,MAAM;YACN,QAAQ;gBACJ,aAAa;gBAEb,sBAAsBS,UAAU,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B,cAAc;QAClB;IACJ;IAEA,MAAMmB,cAAcrB,IAAI,WAAW,CAACN,uCAAAA,GAAAA,CAAAA,uBAA+B,EAAE;QACjE,MAAM;QACN,QAAQ;YACJ,aAAauB,MAAM,MAAM,CAAC,IAAI;YAC9B,sBAAsB;gBAClB,uBAAuB;gBACvB,2BAA2B;gBAC3B,yBAAyB;YAC7B;QACJ;IACJ;IAEAjB,IAAI,WAAW,CAACN,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,aAAauB,MAAM,MAAM,CAAC,IAAI;YAC9B,iBAAiBI,YAAY,MAAM,CAAC,IAAI;YACxC,qBAAqBT,QAAQ,MAAM,CAAC,EAAE;QAC1C;QAEA,MAAM;YAAE,WAAWE,UAAU,GAAG,CAACQ,CAAAA,WAAYA,SAAS,MAAM;QAAE;IAClE;IAEA,OAAO;QAAEH;QAAMF;QAAOI;IAAY;AACtC"}
1
+ {"version":3,"file":"pulumi/apps/core/CorePostgres.js","sources":["../../../../src/pulumi/apps/core/CorePostgres.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as random from \"@pulumi/random\";\nimport {\n createAppModule,\n type PulumiApp,\n type PulumiAppModule,\n type PulumiAppResource\n} from \"@webiny/pulumi\";\n\nexport type CorePostgres = PulumiAppModule<typeof CorePostgres>;\n\nexport const POSTGRES_DATABASE = \"webiny\";\nexport const POSTGRES_USER = \"webiny\";\nexport const POSTGRES_PORT = 5432;\n\n/* Aurora PostgreSQL's major version, and its cluster parameter group family. */\nconst ENGINE = \"aurora-postgresql\";\nconst ENGINE_MAJOR_VERSION = \"17\";\nconst PARAMETER_GROUP_FAMILY = \"aurora-postgresql17\";\n\nexport interface PostgresNetwork {\n subnetIds: pulumi.Input<pulumi.Input<string>[]>;\n securityGroupIds: pulumi.Input<pulumi.Input<string>[]>;\n}\n\nexport interface CorePostgresParams {\n minCapacity: number;\n maxCapacity: number;\n readers: number;\n rdsProxy: boolean;\n network: PostgresNetwork;\n /*\n * On in production: deletion protection, 35 days of backups that outlive the cluster, and a\n * final snapshot.\n */\n protect: boolean;\n /*\n * The engine version a new cluster gets: the latest 17.x. Replaced in tests, where there is no\n * AWS to ask.\n */\n getEngineVersion?: () => pulumi.Input<string>;\n /*\n * Put before the name of every resource, so a project can have several clusters: none for the\n * cluster of `<Infra.AuroraPostgres />`, `storage-<id>-` for each `<Infra.TenantStorage.AuroraPostgres>`.\n * It is part of the resources' Pulumi names, so it can't change once a cluster is deployed.\n */\n namePrefix?: string;\n /* What the secret and the database's AWS descriptions call it. Default: \"the Webiny Postgres database\". */\n description?: string;\n}\n\nconst getLatestEngineVersion = () => {\n return pulumi.output(\n aws.rds.getEngineVersion({ engine: ENGINE, version: ENGINE_MAJOR_VERSION, latest: true })\n ).versionActual;\n};\n\nconst assumeRolePolicy = (service: string) =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [{ Effect: \"Allow\", Principal: { Service: service }, Action: \"sts:AssumeRole\" }]\n });\n\n/**\n * The Postgres database of a project with `<Infra.AuroraPostgres />`: an Aurora PostgreSQL 17\n * Serverless v2 cluster with a writer and `readers` reader instances, and its credentials in a\n * Secrets Manager secret (`{ username, password }`). With `rdsProxy`, an RDS Proxy in front of it,\n * which reads the same secret.\n *\n * The cluster, its instances and the proxy go into `network`: the private subnets of the VPC the\n * core app creates and its default security group, which the API functions use too, or the\n * `postgresVpcConfig` of an existing VPC.\n *\n * No password leaves this module: the API reads it from the secret.\n */\nexport const CorePostgres = createAppModule({\n name: \"CorePostgres\",\n config(app: PulumiApp, params: CorePostgresParams) {\n const { network, protect } = params;\n const getEngineVersion = params.getEngineVersion ?? getLatestEngineVersion;\n const prefix = params.namePrefix ?? \"\";\n const name = (value: string) => `${prefix}${value}`;\n const database = params.description ?? \"the Webiny Postgres database\";\n const Database = database.charAt(0).toUpperCase() + database.slice(1);\n\n const password = app.addResource(random.RandomPassword, {\n name: name(\"pg-db-password\"),\n config: { length: 32, special: false }\n });\n\n const secret = app.addResource(aws.secretsmanager.Secret, {\n name: name(\"pg-db\"),\n config: {\n description: `Credentials of ${database}.`,\n // Outside production, a destroyed project can be deployed again at once.\n recoveryWindowInDays: protect ? 7 : 0\n },\n opts: { protect }\n });\n\n app.addResource(aws.secretsmanager.SecretVersion, {\n name: name(\"pg-db\"),\n config: {\n secretId: secret.output.id,\n secretString: pulumi\n .all([password.output.result])\n .apply(([value]) =>\n JSON.stringify({ username: POSTGRES_USER, password: value })\n )\n }\n });\n\n const subnetGroup = app.addResource(aws.rds.SubnetGroup, {\n name: name(\"pg-db\"),\n config: {\n description: `Subnets of ${database}.`,\n subnetIds: network.subnetIds\n }\n });\n\n /*\n * The server notices a client that went away without closing its connection (a Lambda\n * environment that was recycled) within about two minutes, and frees the connection.\n */\n const parameterGroup = app.addResource(aws.rds.ClusterParameterGroup, {\n name: name(\"pg-db\"),\n config: {\n family: PARAMETER_GROUP_FAMILY,\n description: `${Database}: TCP keepalives.`,\n parameters: [\n { name: \"tcp_keepalives_idle\", value: \"60\" },\n { name: \"tcp_keepalives_interval\", value: \"10\" },\n { name: \"tcp_keepalives_count\", value: \"6\" }\n ]\n }\n });\n\n // A final snapshot needs a name that no earlier snapshot of the account has.\n const finalSnapshotSuffix = protect\n ? app.addResource(random.RandomId, {\n name: name(\"pg-db-final-snapshot\"),\n config: { byteLength: 4 }\n })\n : null;\n\n const cluster = app.addResource(aws.rds.Cluster, {\n name: name(\"pg-db\"),\n config: {\n engine: ENGINE,\n engineMode: \"provisioned\",\n engineVersion: getEngineVersion(),\n databaseName: POSTGRES_DATABASE,\n masterUsername: POSTGRES_USER,\n masterPassword: password.output.result,\n port: POSTGRES_PORT,\n storageType: \"aurora\",\n storageEncrypted: true,\n dbSubnetGroupName: subnetGroup.output.name,\n dbClusterParameterGroupName: parameterGroup.output.name,\n vpcSecurityGroupIds: network.securityGroupIds,\n serverlessv2ScalingConfiguration: {\n minCapacity: params.minCapacity,\n maxCapacity: params.maxCapacity\n },\n enabledCloudwatchLogsExports: [\"postgresql\"],\n copyTagsToSnapshot: true,\n deletionProtection: protect,\n // Point-in-time restore is always on in Aurora; this is its window. Production\n // keeps the maximum, 35 days, the same as DynamoDB's point-in-time recovery.\n // Backup storage up to the cluster volume's size is free. Elsewhere, 1 day.\n backupRetentionPeriod: protect ? 35 : 1,\n // Production keeps its automated backups when the cluster is deleted, so it can\n // still be restored to a point in time until the window runs out. The first day is\n // free, later days are billed, and a region holds at most 40 retained automated\n // backups. Elsewhere the default (true) applies: a destroyed environment leaves\n // nothing behind.\n deleteAutomatedBackups: protect ? false : undefined,\n skipFinalSnapshot: !protect,\n finalSnapshotIdentifier: finalSnapshotSuffix\n ? pulumi.interpolate`webiny-${prefix}pg-final-${finalSnapshotSuffix.output.hex}`\n : undefined,\n // Capacity changes apply now, not in the next maintenance window.\n applyImmediately: true\n },\n opts: {\n protect,\n // The version is picked when the cluster is created; AWS applies minor upgrades.\n // A newer 17.x must not make a later deploy upgrade the cluster.\n ignoreChanges: [\"engineVersion\"]\n }\n });\n\n const instances = [];\n for (let index = 0; index <= params.readers; index++) {\n const isWriter = index === 0;\n instances.push(\n app.addResource(aws.rds.ClusterInstance, {\n name: name(isWriter ? \"pg-db-writer\" : `pg-db-reader-${index}`),\n config: {\n clusterIdentifier: cluster.output.id,\n instanceClass: \"db.serverless\",\n engine: ENGINE,\n engineVersion: cluster.output.engineVersion,\n publiclyAccessible: false,\n performanceInsightsEnabled: true,\n // Readers in tier 0–1 scale with the writer, so a failover lands on a warm one.\n promotionTier: isWriter ? 0 : 1,\n applyImmediately: true\n },\n opts: { ignoreChanges: [\"engineVersion\"] }\n })\n );\n }\n\n let proxy: ReturnType<typeof addProxy> | null = null;\n if (params.rdsProxy) {\n proxy = addProxy(app, { secret, cluster, instances, network, prefix });\n }\n\n return {\n cluster,\n instances,\n secret,\n subnetGroup,\n parameterGroup,\n proxy: proxy?.proxy ?? null,\n outputs: {\n pgWriterHost: cluster.output.endpoint,\n pgReaderHost: cluster.output.readerEndpoint,\n ...(proxy ? { pgProxyHost: proxy.proxy.output.endpoint } : {}),\n pgPort: POSTGRES_PORT,\n pgDatabase: POSTGRES_DATABASE,\n pgUser: POSTGRES_USER,\n pgSecretArn: secret.output.arn\n }\n };\n }\n});\n\ninterface AddProxyParams {\n secret: PulumiAppResource<typeof aws.secretsmanager.Secret>;\n cluster: PulumiAppResource<typeof aws.rds.Cluster>;\n instances: PulumiAppResource<typeof aws.rds.ClusterInstance>[];\n network: PostgresNetwork;\n prefix: string;\n}\n\nfunction addProxy(app: PulumiApp, params: AddProxyParams) {\n const { secret, cluster, instances, network, prefix } = params;\n\n const role = app.addResource(aws.iam.Role, {\n name: `${prefix}pg-proxy`,\n config: { assumeRolePolicy: assumeRolePolicy(\"rds.amazonaws.com\") }\n });\n\n app.addResource(aws.iam.RolePolicy, {\n name: `${prefix}pg-proxy`,\n config: {\n role: role.output.id,\n policy: pulumi.all([secret.output.arn]).apply(([arn]) =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Action: [\"secretsmanager:GetSecretValue\"],\n Resource: [arn]\n }\n ]\n })\n )\n }\n });\n\n const proxy = app.addResource(aws.rds.Proxy, {\n name: `${prefix}pg-proxy`,\n config: {\n engineFamily: \"POSTGRESQL\",\n auths: [{ authScheme: \"SECRETS\", iamAuth: \"DISABLED\", secretArn: secret.output.arn }],\n roleArn: role.output.arn,\n vpcSubnetIds: network.subnetIds,\n vpcSecurityGroupIds: network.securityGroupIds,\n requireTls: true,\n idleClientTimeout: 900,\n debugLogging: false\n }\n });\n\n const targetGroup = app.addResource(aws.rds.ProxyDefaultTargetGroup, {\n name: `${prefix}pg-proxy`,\n config: {\n dbProxyName: proxy.output.name,\n connectionPoolConfig: {\n maxConnectionsPercent: 70,\n maxIdleConnectionsPercent: 50,\n connectionBorrowTimeout: 10\n }\n }\n });\n\n app.addResource(aws.rds.ProxyTarget, {\n name: `${prefix}pg-proxy`,\n config: {\n dbProxyName: proxy.output.name,\n targetGroupName: targetGroup.output.name,\n dbClusterIdentifier: cluster.output.id\n },\n // The proxy can only register a cluster whose instances are available.\n opts: { dependsOn: instances.map(instance => instance.output) }\n });\n\n return { role, proxy, targetGroup };\n}\n"],"names":["POSTGRES_DATABASE","POSTGRES_USER","POSTGRES_PORT","ENGINE","ENGINE_MAJOR_VERSION","PARAMETER_GROUP_FAMILY","getLatestEngineVersion","pulumi","aws","assumeRolePolicy","service","JSON","CorePostgres","createAppModule","app","params","network","protect","getEngineVersion","prefix","name","value","database","Database","password","random","secret","subnetGroup","parameterGroup","finalSnapshotSuffix","cluster","undefined","instances","index","isWriter","proxy","addProxy","role","arn","targetGroup","instance"],"mappings":";;;;AAYO,MAAMA,oBAAoB;AAC1B,MAAMC,gBAAgB;AACtB,MAAMC,gBAAgB;AAG7B,MAAMC,SAAS;AACf,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAiC/B,MAAMC,yBAAyB,IACpBC,0CAAAA,MAAa,CAChBC,uCAAAA,GAAAA,CAAAA,gBAAwB,CAAC;QAAE,QAAQL;QAAQ,SAASC;QAAsB,QAAQ;IAAK,IACzF,aAAa;AAGnB,MAAMK,mBAAmB,CAACC,UACtBC,KAAK,SAAS,CAAC;QACX,SAAS;QACT,WAAW;YAAC;gBAAE,QAAQ;gBAAS,WAAW;oBAAE,SAASD;gBAAQ;gBAAG,QAAQ;YAAiB;SAAE;IAC/F;AAcG,MAAME,eAAeC,gBAAgB;IACxC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAA0B;QAC7C,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;QAC7B,MAAMG,mBAAmBH,OAAO,gBAAgB,IAAIT;QACpD,MAAMa,SAASJ,OAAO,UAAU,IAAI;QACpC,MAAMK,OAAO,CAACC,QAAkB,GAAGF,SAASE,OAAO;QACnD,MAAMC,WAAWP,OAAO,WAAW,IAAI;QACvC,MAAMQ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OI;IAAY;AACtC"}
@@ -12,3 +12,10 @@ export interface CoreVpcEndpointsParams {
12
12
  * VPC talks to DynamoDB.
13
13
  */
14
14
  export declare const addCoreVpcEndpoints: (app: PulumiApp, params: CoreVpcEndpointsParams) => void;
15
+ /**
16
+ * The DynamoDB gateway endpoint: DynamoDB traffic from the private subnets goes to it instead of
17
+ * through the NAT gateway. Gateway endpoints cost nothing. Added by `<Infra.Vpc useVpcEndpoints />`,
18
+ * and on a DynamoDB default storage with a `<Infra.TenantStorage.AuroraPostgres>`, whose API functions
19
+ * run in the VPC.
20
+ */
21
+ export declare const addDynamoDbGatewayEndpoint: (app: PulumiApp, params: Pick<CoreVpcEndpointsParams, "vpc" | "region">) => import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/ec2/vpcEndpoint.js").VpcEndpoint>;
@@ -13,16 +13,7 @@ const addCoreVpcEndpoints = (app, params)=>{
13
13
  ]
14
14
  }
15
15
  });
16
- if (!params.usesPostgres) app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
17
- name: "vpc-dynamodb-vpc-endpoint",
18
- config: {
19
- vpcId: vpc.output.id,
20
- serviceName: __rspack_external__pulumi_pulumi_f3e773ed.interpolate`com.amazonaws.${region}.dynamodb`,
21
- routeTableIds: [
22
- routeTables.privateSubnets.output.id
23
- ]
24
- }
25
- });
16
+ if (!params.usesPostgres) addDynamoDbGatewayEndpoint(app, params);
26
17
  app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
27
18
  name: "vpc-sqs-vpc-endpoint",
28
19
  config: {
@@ -50,6 +41,19 @@ const addCoreVpcEndpoints = (app, params)=>{
50
41
  }
51
42
  });
52
43
  };
53
- export { addCoreVpcEndpoints };
44
+ const addDynamoDbGatewayEndpoint = (app, params)=>{
45
+ const { vpc, routeTables } = params.vpc;
46
+ return app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
47
+ name: "vpc-dynamodb-vpc-endpoint",
48
+ config: {
49
+ vpcId: vpc.output.id,
50
+ serviceName: __rspack_external__pulumi_pulumi_f3e773ed.interpolate`com.amazonaws.${params.region}.dynamodb`,
51
+ routeTableIds: [
52
+ routeTables.privateSubnets.output.id
53
+ ]
54
+ }
55
+ });
56
+ };
57
+ export { addCoreVpcEndpoints, addDynamoDbGatewayEndpoint };
54
58
 
55
59
  //# sourceMappingURL=coreVpcEndpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/apps/core/coreVpcEndpoints.js","sources":["../../../../src/pulumi/apps/core/coreVpcEndpoints.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { CoreVpc } from \"./CoreVpc.js\";\n\nexport interface CoreVpcEndpointsParams {\n vpc: Pick<CoreVpc, \"vpc\" | \"subnets\" | \"routeTables\">;\n region: pulumi.Input<string>;\n /* The project has `<Infra.AuroraPostgres />`. */\n usesPostgres: boolean;\n}\n\n/**\n * The VPC endpoints of `<Infra.Vpc useVpcEndpoints />`: gateways for S3 and DynamoDB, interfaces for\n * SQS and EventBridge. With `<Infra.AuroraPostgres />` there's no DynamoDB endpoint: nothing in the\n * VPC talks to DynamoDB.\n */\nexport const addCoreVpcEndpoints = (app: PulumiApp, params: CoreVpcEndpointsParams) => {\n const { vpc, subnets, routeTables } = params.vpc;\n const { region } = params;\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-s3-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.s3`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n if (!params.usesPostgres) {\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-dynamodb-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.dynamodb`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n }\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-sqs-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.sqs`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-events-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.events`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n};\n"],"names":["addCoreVpcEndpoints","app","params","vpc","subnets","routeTables","region","aws","pulumi","subNet"],"mappings":";;AAiBO,MAAMA,sBAAsB,CAACC,KAAgBC;IAChD,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,WAAW,EAAE,GAAGH,OAAO,GAAG;IAChD,MAAM,EAAEI,MAAM,EAAE,GAAGJ;IAEnBD,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,GAAG,CAAC;YAC3D,eAAe;gBAACD,YAAY,cAAc,CAAC,MAAM,CAAC,EAAE;aAAC;QACzD;IACJ;IAEA,IAAI,CAACH,OAAO,YAAY,EACpBD,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,SAAS,CAAC;YACjE,eAAe;gBAACD,YAAY,cAAc,CAAC,MAAM,CAAC,EAAE;aAAC;QACzD;IACJ;IAGJJ,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,IAAI,CAAC;YAC5D,iBAAiB;YACjB,mBAAmB;YACnB,kBAAkB;gBAACH,IAAI,MAAM,CAAC,sBAAsB;aAAC;YACrD,WAAWC,QAAQ,OAAO,CAAC,GAAG,CAACK,CAAAA,SAAUA,OAAO,MAAM,CAAC,EAAE;QAC7D;IACJ;IAEAR,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,OAAO,CAAC;YAC/D,iBAAiB;YACjB,mBAAmB;YACnB,kBAAkB;gBAACH,IAAI,MAAM,CAAC,sBAAsB;aAAC;YACrD,WAAWC,QAAQ,OAAO,CAAC,GAAG,CAACK,CAAAA,SAAUA,OAAO,MAAM,CAAC,EAAE;QAC7D;IACJ;AACJ"}
1
+ {"version":3,"file":"pulumi/apps/core/coreVpcEndpoints.js","sources":["../../../../src/pulumi/apps/core/coreVpcEndpoints.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { CoreVpc } from \"./CoreVpc.js\";\n\nexport interface CoreVpcEndpointsParams {\n vpc: Pick<CoreVpc, \"vpc\" | \"subnets\" | \"routeTables\">;\n region: pulumi.Input<string>;\n /* The project has `<Infra.AuroraPostgres />`. */\n usesPostgres: boolean;\n}\n\n/**\n * The VPC endpoints of `<Infra.Vpc useVpcEndpoints />`: gateways for S3 and DynamoDB, interfaces for\n * SQS and EventBridge. With `<Infra.AuroraPostgres />` there's no DynamoDB endpoint: nothing in the\n * VPC talks to DynamoDB.\n */\nexport const addCoreVpcEndpoints = (app: PulumiApp, params: CoreVpcEndpointsParams) => {\n const { vpc, subnets, routeTables } = params.vpc;\n const { region } = params;\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-s3-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.s3`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n if (!params.usesPostgres) {\n addDynamoDbGatewayEndpoint(app, params);\n }\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-sqs-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.sqs`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-events-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.events`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n};\n\n/**\n * The DynamoDB gateway endpoint: DynamoDB traffic from the private subnets goes to it instead of\n * through the NAT gateway. Gateway endpoints cost nothing. Added by `<Infra.Vpc useVpcEndpoints />`,\n * and on a DynamoDB default storage with a `<Infra.TenantStorage.AuroraPostgres>`, whose API functions\n * run in the VPC.\n */\nexport const addDynamoDbGatewayEndpoint = (\n app: PulumiApp,\n params: Pick<CoreVpcEndpointsParams, \"vpc\" | \"region\">\n) => {\n const { vpc, routeTables } = params.vpc;\n return app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-dynamodb-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${params.region}.dynamodb`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n};\n"],"names":["addCoreVpcEndpoints","app","params","vpc","subnets","routeTables","region","aws","pulumi","addDynamoDbGatewayEndpoint","subNet"],"mappings":";;AAiBO,MAAMA,sBAAsB,CAACC,KAAgBC;IAChD,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,WAAW,EAAE,GAAGH,OAAO,GAAG;IAChD,MAAM,EAAEI,MAAM,EAAE,GAAGJ;IAEnBD,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,GAAG,CAAC;YAC3D,eAAe;gBAACD,YAAY,cAAc,CAAC,MAAM,CAAC,EAAE;aAAC;QACzD;IACJ;IAEA,IAAI,CAACH,OAAO,YAAY,EACpBO,2BAA2BR,KAAKC;IAGpCD,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,IAAI,CAAC;YAC5D,iBAAiB;YACjB,mBAAmB;YACnB,kBAAkB;gBAACH,IAAI,MAAM,CAAC,sBAAsB;aAAC;YACrD,WAAWC,QAAQ,OAAO,CAAC,GAAG,CAACM,CAAAA,SAAUA,OAAO,MAAM,CAAC,EAAE;QAC7D;IACJ;IAEAT,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEF,OAAO,OAAO,CAAC;YAC/D,iBAAiB;YACjB,mBAAmB;YACnB,kBAAkB;gBAACH,IAAI,MAAM,CAAC,sBAAsB;aAAC;YACrD,WAAWC,QAAQ,OAAO,CAAC,GAAG,CAACM,CAAAA,SAAUA,OAAO,MAAM,CAAC,EAAE;QAC7D;IACJ;AACJ;AAQO,MAAMD,6BAA6B,CACtCR,KACAC;IAEA,MAAM,EAAEC,GAAG,EAAEE,WAAW,EAAE,GAAGH,OAAO,GAAG;IACvC,OAAOD,IAAI,WAAW,CAACM,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACxC,MAAM;QACN,QAAQ;YACJ,OAAOJ,IAAI,MAAM,CAAC,EAAE;YACpB,aAAaK,0CAAAA,WAAkB,CAAC,cAAc,EAAEN,OAAO,MAAM,CAAC,SAAS,CAAC;YACxE,eAAe;gBAACG,YAAY,cAAc,CAAC,MAAM,CAAC,EAAE;aAAC;QACzD;IACJ;AACJ"}
@@ -21,7 +21,8 @@ import { S3BucketVersioning } from "@webiny/project-extensions-aws/extensions/S3
21
21
  import { applyAwsResourceTags, getAwsRegion } from "../awsUtils.js";
22
22
  import { configureS3BucketMalwareProtection } from "./configureS3BucketMalwareProtection.js";
23
23
  import { addCoreDynamoDb } from "./coreDynamoDb.js";
24
- import { addCoreVpcEndpoints } from "./coreVpcEndpoints.js";
24
+ import { addCoreVpcEndpoints, addDynamoDbGatewayEndpoint } from "./coreVpcEndpoints.js";
25
+ import { getTenantStoragesFromExtension } from "../extensions/getTenantStoragesFromExtension.js";
25
26
  import { getPostgresConfigFromExtension } from "../extensions/getPostgresConfigFromExtension.js";
26
27
  import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
27
28
  import * as __rspack_external__pulumi_random_073a0f72 from "@pulumi/random";
@@ -121,6 +122,12 @@ function createCorePulumiApp() {
121
122
  pointInTimeRecovery
122
123
  });
123
124
  const vpc = isVpcEnabled(vpcExtensionsConfig, isProduction) ? app.addModule(CoreVpc) : null;
125
+ const usesVpcEndpoints = "object" == typeof vpcExtensionsConfig && Boolean(vpcExtensionsConfig.useVpcEndpoints);
126
+ const hasTenantStorages = getTenantStoragesFromExtension(projectConfig).length > 0;
127
+ if (vpc && hasTenantStorages && !usesPostgres && !usesVpcEndpoints) addDynamoDbGatewayEndpoint(app, {
128
+ vpc,
129
+ region: getAwsRegion(app)
130
+ });
124
131
  const cognito = app.addModule(CoreCognito, {
125
132
  protect,
126
133
  useEmailAsUsername: false,