@webiny/project-aws 6.6.0-alpha.0 → 6.6.0-alpha.2

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 (40) hide show
  1. package/_templates/appTemplates/api/graphql/src/index.ts +12 -1
  2. package/_templates/extensions/OpenSearch/api/graphql/src/index.ts +9 -1
  3. package/apps/createApiApp.d.ts +8 -0
  4. package/extensions/ApiRoute.d.ts +1 -1
  5. package/extensions/ApiRoute.js +14 -1
  6. package/extensions/ApiRoute.js.map +1 -1
  7. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.d.ts +1 -1
  8. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js +1 -2
  9. package/extensions/ProjectAws/AutoInstall/AutoInstallAfterApiDeploy.js.map +1 -1
  10. package/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js +1 -1
  11. package/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js.map +1 -1
  12. package/extensions/RegisterRoutesPulumi.js +2 -5
  13. package/extensions/RegisterRoutesPulumi.js.map +1 -1
  14. package/extensions/routePath.d.ts +20 -0
  15. package/extensions/routePath.js +13 -0
  16. package/extensions/routePath.js.map +1 -0
  17. package/package.json +15 -15
  18. package/project.d.ts +16 -11
  19. package/pulumi/apps/api/ApiCloudfront.js +103 -1
  20. package/pulumi/apps/api/ApiCloudfront.js.map +1 -1
  21. package/pulumi/apps/api/ApiGraphqlStream.d.ts +29 -0
  22. package/pulumi/apps/api/ApiGraphqlStream.js +58 -0
  23. package/pulumi/apps/api/ApiGraphqlStream.js.map +1 -0
  24. package/pulumi/apps/api/createApiPulumiApp.d.ts +8 -0
  25. package/pulumi/apps/api/createApiPulumiApp.js +24 -17
  26. package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
  27. package/pulumi/apps/api/index.d.ts +1 -0
  28. package/pulumi/apps/api/index.js +1 -0
  29. package/pulumi/apps/awsUtils.d.ts +1 -1
  30. package/pulumi/apps/core/CoreCognito.d.ts +1 -0
  31. package/pulumi/apps/core/CoreCognito.js +4 -1
  32. package/pulumi/apps/core/CoreCognito.js.map +1 -1
  33. package/pulumi/apps/core/cognitoIdentityProviders/configure.js +9 -1
  34. package/pulumi/apps/core/cognitoIdentityProviders/configure.js.map +1 -1
  35. package/pulumi/apps/core/createCorePulumiApp.js +18 -2
  36. package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
  37. package/pulumi/apps/syncSystem/SyncSystemLambda.d.ts +1 -1
  38. package/pulumi/apps/syncSystem/SyncSystemLambda.js +1 -1
  39. package/pulumi/apps/syncSystem/SyncSystemLambda.js.map +1 -1
  40. package/pulumi/extensions/index.d.ts +16 -16
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/apps/api/ApiCloudfront.js","sources":["../../../../src/pulumi/apps/api/ApiCloudfront.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\n\nimport { ApiGateway } from \"./ApiGateway.js\";\n\nexport type ApiCloudfront = PulumiAppModule<typeof ApiCloudfront>;\n\nexport const ApiCloudfront = createAppModule({\n name: \"ApiCloudfront\",\n config(app: PulumiApp) {\n const gateway = app.getModule(ApiGateway);\n\n const cookies = {\n forward: \"whitelist\",\n whitelistedNames: [\"wby-id-token\"]\n };\n\n const forwardHeaders = [\n \"Origin\",\n \"Authorization\",\n \"Accept\",\n \"Accept-Language\",\n \"X-Tenant\",\n \"X-Webiny-Sdk\"\n ];\n\n return app.addResource(aws.cloudfront.Distribution, {\n name: \"api-cloudfront\",\n config: {\n httpVersion: \"http2and3\",\n waitForDeployment: false,\n isIpv6Enabled: true,\n enabled: true,\n defaultCacheBehavior: {\n compress: true,\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\", \"PUT\", \"POST\", \"PATCH\", \"DELETE\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies,\n headers: forwardHeaders,\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 86400,\n targetOriginId: gateway.api.output.name,\n viewerProtocolPolicy: \"allow-all\"\n },\n orderedCacheBehaviors: [\n {\n compress: true,\n allowedMethods: [\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"PUT\",\n \"POST\",\n \"PATCH\",\n \"DELETE\"\n ],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: forwardHeaders,\n queryString: true\n },\n pathPattern: \"/cms*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n },\n {\n compress: true,\n allowedMethods: [\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"PUT\",\n \"POST\",\n \"PATCH\",\n \"DELETE\"\n ],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: forwardHeaders,\n queryString: true\n },\n pathPattern: \"/wb/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n },\n {\n allowedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n cachedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: forwardHeaders,\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 2592000,\n pathPattern: \"/files/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n },\n {\n allowedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n cachedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n forwardedValues: {\n cookies: cookies,\n headers: forwardHeaders,\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 2592000,\n pathPattern: \"/private/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n }\n ],\n origins: [\n {\n domainName: gateway.stage.output.invokeUrl.apply(\n (url: string) => new URL(url).hostname\n ),\n originPath: gateway.stage.output.invokeUrl.apply(\n (url: string) => new URL(url).pathname\n ),\n originId: gateway.api.output.name,\n customOriginConfig: {\n httpPort: 80,\n httpsPort: 443,\n originProtocolPolicy: \"https-only\",\n originSslProtocols: [\"TLSv1.2\"]\n }\n }\n ],\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n },\n opts: {\n // We are ignoring changes to the \"staging\" property. This is because of the following.\n // With the 5.41.0 release of Webiny, we also upgraded Pulumi to v6. This introduced a change\n // with how Cloudfront distributions are deployed, where Pulumi now also controls the new\n // `staging` property.\n // If not set, Pulumi will default it to `false`. Which is fine, but, the problem is\n // that, because this property did not exist before, it will always be considered as a change\n // upon deployment.\n // We might think this is fine, but, the problem is that a change in this property causes\n // a full replacement of the Cloudfront distribution, which is not acceptable. Especially\n // if a custom domain has already been associated with the distribution. This then would\n // require the user to disassociate the domain, wait for the distribution to be replaced,\n // and then re-associate the domain. This is not a good experience.\n ignoreChanges: [\"staging\"]\n }\n });\n }\n});\n"],"names":["ApiCloudfront","createAppModule","app","gateway","ApiGateway","cookies","forwardHeaders","aws","url","URL"],"mappings":";;;AAQO,MAAMA,gBAAgBC,gBAAgB;IACzC,MAAM;IACN,QAAOC,GAAc;QACjB,MAAMC,UAAUD,IAAI,SAAS,CAACE;QAE9B,MAAMC,UAAU;YACZ,SAAS;YACT,kBAAkB;gBAAC;aAAe;QACtC;QAEA,MAAMC,iBAAiB;YACnB;YACA;YACA;YACA;YACA;YACA;SACH;QAED,OAAOJ,IAAI,WAAW,CAACK,uCAAAA,UAAAA,CAAAA,YAA2B,EAAE;YAChD,MAAM;YACN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QAAQ,GAAG,CAAC,MAAM,CAAC,IAAI;oBAC3C;oBACA;wBACI,gBAAgB;4BAAC;4BAAQ;4BAAO;yBAAU;wBAC1C,eAAe;4BAAC;4BAAQ;4BAAO;yBAAU;wBACzC,iBAAiB;4BACb,SAASE;4BACT,SAASC;4BACT,aAAa;wBACjB;wBAEA,QAAQ;wBACR,YAAY;wBACZ,QAAQ;wBACR,aAAa;wBACb,sBAAsB;wBACtB,gBAAgBH,QAAQ,GAAG,CAAC,MAAM,CAAC,IAAI;oBAC3C;iBACH;gBACD,SAAS;oBACL;wBACI,YAAYA,QAAQ,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAC5C,CAACK,MAAgB,IAAIC,IAAID,KAAK,QAAQ;wBAE1C,YAAYL,QAAQ,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAC5C,CAACK,MAAgB,IAAIC,IAAID,KAAK,QAAQ;wBAE1C,UAAUL,QAAQ,GAAG,CAAC,MAAM,CAAC,IAAI;wBACjC,oBAAoB;4BAChB,UAAU;4BACV,WAAW;4BACX,sBAAsB;4BACtB,oBAAoB;gCAAC;6BAAU;wBACnC;oBACJ;iBACH;gBACD,cAAc;oBACV,gBAAgB;wBACZ,iBAAiB;oBACrB;gBACJ;gBACA,mBAAmB;oBACf,8BAA8B;gBAClC;YACJ;YACA,MAAM;gBAaF,eAAe;oBAAC;iBAAU;YAC9B;QACJ;IACJ;AACJ"}
1
+ {"version":3,"file":"pulumi/apps/api/ApiCloudfront.js","sources":["../../../../src/pulumi/apps/api/ApiCloudfront.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\n\nimport { ApiGateway } from \"./ApiGateway.js\";\nimport { ApiGraphqlStream } from \"./ApiGraphqlStream.js\";\n\nexport type ApiCloudfront = PulumiAppModule<typeof ApiCloudfront>;\n\nconst STREAM_ORIGIN_ID = \"graphql-stream-function-url\";\n\n// AWS's `Managed-CachingDisabled` cache policy. Managed policy IDs are global constants — the same\n// value in every account and region — so this is hardcoded rather than resolved via\n// `aws.cloudfront.getCachePolicyOutput({ name: \"Managed-CachingDisabled\" })` the way\n// `createCloudFrontDefaultCacheBehaviorPolicies` does. The lookup would need\n// `cloudfront:ListCachePolicies` on the deploy role, and that is not worth adding to every\n// project's default deployment path just to avoid a constant AWS itself documents.\nconst MANAGED_CACHING_DISABLED_POLICY_ID = \"4135ea2d-6df8-44a3-9df3-4b5a84be39ad\";\n\nexport const ApiCloudfront = createAppModule({\n name: \"ApiCloudfront\",\n config(app: PulumiApp) {\n const gateway = app.getModule(ApiGateway);\n const graphqlStream = app.getModule(ApiGraphqlStream);\n\n const cookies = {\n forward: \"whitelist\",\n whitelistedNames: [\"wby-id-token\"]\n };\n\n const forwardHeaders = [\n \"Origin\",\n \"Authorization\",\n \"Accept\",\n \"Accept-Language\",\n \"X-Tenant\",\n \"X-Webiny-Sdk\"\n ];\n\n // Lets CloudFront sign requests to the Lambda Function URL with SigV4, so the URL itself can\n // stay on AWS_IAM authorization instead of being reachable from the internet.\n const streamOac = app.addResource(aws.cloudfront.OriginAccessControl, {\n name: \"api-stream-oac\",\n config: {\n description: \"Signs CloudFront requests to the streaming Lambda Function URL\",\n originAccessControlOriginType: \"lambda\",\n signingBehavior: \"always\",\n signingProtocol: \"sigv4\"\n }\n });\n\n // The streaming behavior uses a cache policy + origin request policy instead of the legacy\n // `forwardedValues` the other behaviors use, because legacy forwarded values are deprecated\n // and this policy also has to forward the two CORS preflight headers (see below).\n //\n // It is NOT what fixed the `AccessDeniedException` that made Lambda reject every signed\n // CloudFront request — that was a missing `lambda:InvokeFunction` permission (see the two\n // permissions at the bottom of this file). Recorded because the wrong cause was assumed first.\n //\n // Do NOT replace this with a managed origin request policy. `Managed-AllViewer` forwards\n // `Host`, which breaks OAC signing against a Function URL origin.\n // `Managed-AllViewerExceptHostHeader` (used for the blue/green router in this same package)\n // fixes `Host` but still forwards `Authorization`, which OAC signing owns here — see below.\n const streamOriginRequestPolicy = app.addResource(aws.cloudfront.OriginRequestPolicy, {\n name: \"api-stream-origin-request-policy\",\n config: {\n comment: \"Headers/cookies forwarded to the streaming Lambda Function URL origin\",\n headersConfig: {\n headerBehavior: \"whitelist\",\n headers: {\n items: [\n \"Origin\",\n \"Accept\",\n \"Accept-Language\",\n // Required for CORS preflight: without these the origin can't build a\n // correct 204, so the browser blocks the real request.\n \"Access-Control-Request-Method\",\n \"Access-Control-Request-Headers\",\n \"X-Tenant\",\n \"X-Webiny-Sdk\",\n // `Authorization` is deliberately ABSENT — OAC signing owns that header.\n // Clients send their token in `X-Webiny-Authorization` instead.\n \"X-Webiny-Authorization\"\n ]\n }\n },\n cookiesConfig: {\n cookieBehavior: \"whitelist\",\n cookies: { items: [\"wby-id-token\"] }\n },\n queryStringsConfig: { queryStringBehavior: \"all\" }\n }\n });\n\n const distribution = app.addResource(aws.cloudfront.Distribution, {\n name: \"api-cloudfront\",\n config: {\n httpVersion: \"http2and3\",\n waitForDeployment: false,\n isIpv6Enabled: true,\n enabled: true,\n defaultCacheBehavior: {\n compress: true,\n allowedMethods: [\"GET\", \"HEAD\", \"OPTIONS\", \"PUT\", \"POST\", \"PATCH\", \"DELETE\"],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies,\n headers: forwardHeaders,\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 86400,\n targetOriginId: gateway.api.output.name,\n viewerProtocolPolicy: \"allow-all\"\n },\n orderedCacheBehaviors: [\n {\n // Streaming routes (SSE). Must come before the other behaviors so `/stream/*`\n // never falls through to the API Gateway origin, which cannot stream.\n //\n // `compress: false` is load-bearing: CloudFront compression buffers small\n // chunks, which defeats incremental delivery even though the origin streams.\n compress: false,\n allowedMethods: [\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"PUT\",\n \"POST\",\n \"PATCH\",\n \"DELETE\"\n ],\n cachedMethods: [\"GET\", \"HEAD\"],\n // Nothing on a streaming route is cacheable. TTLs must NOT be set\n // alongside a cache policy.\n cachePolicyId: MANAGED_CACHING_DISABLED_POLICY_ID,\n originRequestPolicyId: streamOriginRequestPolicy.output.id,\n pathPattern: \"/stream/*\",\n // Stricter than the other behaviors' `allow-all` on purpose: a streaming route\n // carries an auth token in a header, so plain HTTP is never acceptable here.\n viewerProtocolPolicy: \"https-only\",\n targetOriginId: STREAM_ORIGIN_ID\n },\n {\n compress: true,\n allowedMethods: [\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"PUT\",\n \"POST\",\n \"PATCH\",\n \"DELETE\"\n ],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: forwardHeaders,\n queryString: true\n },\n pathPattern: \"/cms*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n },\n {\n compress: true,\n allowedMethods: [\n \"GET\",\n \"HEAD\",\n \"OPTIONS\",\n \"PUT\",\n \"POST\",\n \"PATCH\",\n \"DELETE\"\n ],\n cachedMethods: [\"GET\", \"HEAD\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: forwardHeaders,\n queryString: true\n },\n pathPattern: \"/wb/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n },\n {\n allowedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n cachedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n forwardedValues: {\n cookies: {\n forward: \"none\"\n },\n headers: forwardHeaders,\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 2592000,\n pathPattern: \"/files/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n },\n {\n allowedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n cachedMethods: [\"HEAD\", \"GET\", \"OPTIONS\"],\n forwardedValues: {\n cookies: cookies,\n headers: forwardHeaders,\n queryString: true\n },\n // MinTTL <= DefaultTTL <= MaxTTL\n minTtl: 0,\n defaultTtl: 0,\n maxTtl: 2592000,\n pathPattern: \"/private/*\",\n viewerProtocolPolicy: \"allow-all\",\n targetOriginId: gateway.api.output.name\n }\n ],\n origins: [\n {\n domainName: gateway.stage.output.invokeUrl.apply(\n (url: string) => new URL(url).hostname\n ),\n originPath: gateway.stage.output.invokeUrl.apply(\n (url: string) => new URL(url).pathname\n ),\n originId: gateway.api.output.name,\n customOriginConfig: {\n httpPort: 80,\n httpsPort: 443,\n originProtocolPolicy: \"https-only\",\n originSslProtocols: [\"TLSv1.2\"]\n }\n },\n {\n // Lambda Function URL origin for streaming routes. A Function URL is a plain\n // HTTPS endpoint, hence customOriginConfig; the OAC is what makes CloudFront\n // sign the request so the URL can require AWS_IAM.\n domainName: graphqlStream.functionUrlDomain,\n originId: STREAM_ORIGIN_ID,\n originAccessControlId: streamOac.output.id,\n customOriginConfig: {\n httpPort: 80,\n httpsPort: 443,\n originProtocolPolicy: \"https-only\",\n originSslProtocols: [\"TLSv1.2\"],\n // NOT a cap on how long a response may stream. It is an IDLE timeout,\n // applied twice: to time-to-first-byte, and to the gap between any two\n // subsequent packets. A stream that keeps emitting can run as long as the\n // Lambda lives (300s here); only silence longer than this kills it.\n //\n // Raised from the 30s default because that is shorter than a slow model's\n // time to first token: CloudFront would abandon the stream while the Lambda\n // kept working. 60s is the ceiling without an AWS quota increase — a route\n // whose quiet gaps could exceed it must emit SSE heartbeat comments\n // (`: ping\\n\\n`), which clients ignore by spec, resetting the timer.\n originReadTimeout: 60\n }\n }\n ],\n restrictions: {\n geoRestriction: {\n restrictionType: \"none\"\n }\n },\n viewerCertificate: {\n cloudfrontDefaultCertificate: true\n }\n },\n opts: {\n // We are ignoring changes to the \"staging\" property. This is because of the following.\n // With the 5.41.0 release of Webiny, we also upgraded Pulumi to v6. This introduced a change\n // with how Cloudfront distributions are deployed, where Pulumi now also controls the new\n // `staging` property.\n // If not set, Pulumi will default it to `false`. Which is fine, but, the problem is\n // that, because this property did not exist before, it will always be considered as a change\n // upon deployment.\n // We might think this is fine, but, the problem is that a change in this property causes\n // a full replacement of the Cloudfront distribution, which is not acceptable. Especially\n // if a custom domain has already been associated with the distribution. This then would\n // require the user to disassociate the domain, wait for the distribution to be replaced,\n // and then re-associate the domain. This is not a good experience.\n ignoreChanges: [\"staging\"]\n }\n });\n\n // Allows THIS distribution — and nothing else — to invoke the streaming Function URL. Created\n // after the distribution because it needs its ARN; the Function URL is useless until it exists.\n //\n // BOTH statements are required. The OAC-for-Lambda docs list `lambda:InvokeFunctionUrl` AND\n // `lambda:InvokeFunction`; with only the former, Lambda's authorizer rejects every signed\n // request from CloudFront with `AccessDeniedException` and the function is never invoked.\n app.addResource(aws.lambda.Permission, {\n name: \"graphql-stream-url-cloudfront-invoke\",\n config: {\n action: \"lambda:InvokeFunctionUrl\",\n function: graphqlStream.functions.graphqlStream.output.name,\n principal: \"cloudfront.amazonaws.com\",\n sourceArn: distribution.output.arn,\n functionUrlAuthType: \"AWS_IAM\",\n statementId: \"allow-cloudfront-invoke-function-url\"\n }\n });\n\n app.addResource(aws.lambda.Permission, {\n name: \"graphql-stream-cloudfront-invoke-function\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: graphqlStream.functions.graphqlStream.output.name,\n principal: \"cloudfront.amazonaws.com\",\n sourceArn: distribution.output.arn,\n statementId: \"allow-cloudfront-invoke-function\"\n }\n });\n\n return distribution;\n }\n});\n"],"names":["STREAM_ORIGIN_ID","MANAGED_CACHING_DISABLED_POLICY_ID","ApiCloudfront","createAppModule","app","gateway","ApiGateway","graphqlStream","ApiGraphqlStream","cookies","forwardHeaders","streamOac","aws","streamOriginRequestPolicy","distribution","url","URL"],"mappings":";;;;AASA,MAAMA,mBAAmB;AAQzB,MAAMC,q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AAa;YACjB;QACJ;QAEAV,IAAI,WAAW,CAACQ,uCAAAA,MAAAA,CAAAA,UAAqB,EAAE;YACnC,MAAM;YACN,QAAQ;gBACJ,QAAQ;gBACR,UAAUL,cAAc,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI;gBAC3D,WAAW;gBACX,WAAWO,aAAa,MAAM,CAAC,GAAG;gBAClC,aAAa;YACjB;QACJ;QAEA,OAAOA;IACX;AACJ"}
@@ -0,0 +1,29 @@
1
+ import * as pulumi from "@pulumi/pulumi";
2
+ import type { PulumiAppModule } from "@webiny/pulumi";
3
+ interface GraphqlStreamParams {
4
+ env: Record<string, any>;
5
+ }
6
+ export type ApiGraphqlStream = PulumiAppModule<typeof ApiGraphqlStream>;
7
+ /**
8
+ * The response-streaming twin of {@link ApiGraphql}.
9
+ *
10
+ * Why a second Lambda function rather than a second route on the existing one: API Gateway buffers the
11
+ * entire Lambda response no matter how it was produced, so it cannot stream at all. Streaming requires
12
+ * a Lambda Function URL with `InvokeMode: RESPONSE_STREAM`, and the response has to be produced by an
13
+ * `awslambda.streamifyResponse` handler — but a Lambda's handler entry point is fixed per function. So:
14
+ * same code bundle, same IAM role, different entry point (`handler.streamHandler`), reached through a
15
+ * Function URL instead of API Gateway.
16
+ *
17
+ * The Function URL is NOT public. It uses `AWS_IAM` authorization and is invoked only by CloudFront,
18
+ * which signs each request using an Origin Access Control (see ApiCloudfront).
19
+ */
20
+ export declare const ApiGraphqlStream: import("@webiny/pulumi").PulumiAppModuleDefinition<{
21
+ role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role.js").Role>;
22
+ functions: {
23
+ graphqlStream: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function.js").Function>;
24
+ };
25
+ functionUrl: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/functionUrl.js").FunctionUrl>;
26
+ /** Origin domain for CloudFront, e.g. `abc123.lambda-url.eu-central-1.on.aws`. */
27
+ functionUrlDomain: pulumi.Output<string>;
28
+ }, GraphqlStreamParams>;
29
+ export {};
@@ -0,0 +1,58 @@
1
+ import path from "path";
2
+ import { createAppModule } from "@webiny/pulumi";
3
+ import { getCommonLambdaEnvVariables } from "../lambdaUtils.js";
4
+ import { VpcConfig } from "../index.js";
5
+ import { LAMBDA_RUNTIME } from "../../constants.js";
6
+ import { ApiGraphql } from "./ApiGraphql.js";
7
+ import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
8
+ import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
9
+ const ApiGraphqlStream = createAppModule({
10
+ name: "ApiGraphqlStream",
11
+ config (app, params) {
12
+ const { role } = app.getModule(ApiGraphql);
13
+ const graphqlStream = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.lambda.Function, {
14
+ name: "graphql-stream",
15
+ config: {
16
+ description: "Webiny's streaming HTTP routes",
17
+ runtime: LAMBDA_RUNTIME,
18
+ handler: "handler.streamHandler",
19
+ role: role.output.arn,
20
+ timeout: 300,
21
+ memorySize: 1024,
22
+ code: new __rspack_external__pulumi_pulumi_f3e773ed.asset.AssetArchive({
23
+ ".": new __rspack_external__pulumi_pulumi_f3e773ed.asset.FileArchive(path.join(app.paths.workspace, "graphql/build"))
24
+ }),
25
+ environment: {
26
+ variables: getCommonLambdaEnvVariables().apply((value)=>({
27
+ ...value,
28
+ ...params.env,
29
+ AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1"
30
+ }))
31
+ },
32
+ vpcConfig: app.getModule(VpcConfig).functionVpcConfig,
33
+ loggingConfig: {
34
+ logFormat: "JSON"
35
+ }
36
+ }
37
+ });
38
+ const functionUrl = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.lambda.FunctionUrl, {
39
+ name: "graphql-stream-url",
40
+ config: {
41
+ functionName: graphqlStream.output.name,
42
+ authorizationType: "AWS_IAM",
43
+ invokeMode: "RESPONSE_STREAM"
44
+ }
45
+ });
46
+ return {
47
+ role,
48
+ functions: {
49
+ graphqlStream
50
+ },
51
+ functionUrl,
52
+ functionUrlDomain: functionUrl.output.functionUrl.apply((url)=>new URL(url).hostname)
53
+ };
54
+ }
55
+ });
56
+ export { ApiGraphqlStream };
57
+
58
+ //# sourceMappingURL=ApiGraphqlStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulumi/apps/api/ApiGraphqlStream.js","sources":["../../../../src/pulumi/apps/api/ApiGraphqlStream.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport { getCommonLambdaEnvVariables } from \"../lambdaUtils.js\";\nimport { VpcConfig } from \"~/pulumi/apps/index.js\";\nimport { LAMBDA_RUNTIME } from \"~/pulumi/constants.js\";\nimport { ApiGraphql } from \"./ApiGraphql.js\";\n\ninterface GraphqlStreamParams {\n env: Record<string, any>;\n}\n\nexport type ApiGraphqlStream = PulumiAppModule<typeof ApiGraphqlStream>;\n\n/**\n * The response-streaming twin of {@link ApiGraphql}.\n *\n * Why a second Lambda function rather than a second route on the existing one: API Gateway buffers the\n * entire Lambda response no matter how it was produced, so it cannot stream at all. Streaming requires\n * a Lambda Function URL with `InvokeMode: RESPONSE_STREAM`, and the response has to be produced by an\n * `awslambda.streamifyResponse` handler — but a Lambda's handler entry point is fixed per function. So:\n * same code bundle, same IAM role, different entry point (`handler.streamHandler`), reached through a\n * Function URL instead of API Gateway.\n *\n * The Function URL is NOT public. It uses `AWS_IAM` authorization and is invoked only by CloudFront,\n * which signs each request using an Origin Access Control (see ApiCloudfront).\n */\nexport const ApiGraphqlStream = createAppModule({\n name: \"ApiGraphqlStream\",\n config(app: PulumiApp, params: GraphqlStreamParams) {\n // Reuse the buffered function's role and policy: identical permissions, and duplicating the\n // policy would mean two places to keep in sync.\n const { role } = app.getModule(ApiGraphql);\n\n const graphqlStream = app.addResource(aws.lambda.Function, {\n name: \"graphql-stream\",\n config: {\n description: \"Webiny's streaming HTTP routes\",\n runtime: LAMBDA_RUNTIME,\n // Second export of the SAME bundle that backs the `graphql` function.\n handler: \"handler.streamHandler\",\n role: role.output.arn,\n // Streaming exists for long-running work (AI token streams). API Gateway's hard 30s\n // cap doesn't apply to a Function URL, so allow well beyond the buffered function's 30s.\n timeout: 300,\n memorySize: 1024,\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"graphql/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\n ...params.env,\n AWS_NODEJS_CONNECTION_REUSE_ENABLED: \"1\"\n }))\n },\n vpcConfig: app.getModule(VpcConfig).functionVpcConfig,\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n const functionUrl = app.addResource(aws.lambda.FunctionUrl, {\n name: \"graphql-stream-url\",\n config: {\n functionName: graphqlStream.output.name,\n // Locked to signed CloudFront requests; see the OAC + invoke permission below.\n authorizationType: \"AWS_IAM\",\n // The whole point: without RESPONSE_STREAM the runtime buffers the response and\n // `streamifyResponse` has no effect.\n invokeMode: \"RESPONSE_STREAM\"\n }\n });\n\n return {\n role,\n functions: {\n graphqlStream\n },\n functionUrl,\n /** Origin domain for CloudFront, e.g. `abc123.lambda-url.eu-central-1.on.aws`. */\n functionUrlDomain: functionUrl.output.functionUrl.apply(\n (url: string) => new URL(url).hostname\n )\n };\n }\n});\n"],"names":["ApiGraphqlStream","createAppModule","app","params","role","ApiGraphql","graphqlStream","aws","LAMBDA_RUNTIME","pulumi","path","getCommonLambdaEnvVariables","value","VpcConfig","functionUrl","url","URL"],"mappings":";;;;;;;;AA6BO,MAAMA,mBAAmBC,gBAAgB;IAC5C,MAAM;IACN,QAAOC,GAAc,EAAEC,MAA2B;QAG9C,MAAM,EAAEC,IAAI,EAAE,GAAGF,IAAI,SAAS,CAACG;QAE/B,MAAMC,gBAAgBJ,IAAI,WAAW,CAACK,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YACvD,MAAM;YACN,QAAQ;gBACJ,aAAa;gBACb,SAASC;gBAET,SAAS;gBACT,MAAMJ,KAAK,MAAM,CAAC,GAAG;gBAGrB,SAAS;gBACT,YAAY;gBACZ,MAAM,IAAIK,0CAAAA,KAAAA,CAAAA,YAAyB,CAAC;oBAChC,KAAK,IAAIA,0CAAAA,KAAAA,CAAAA,WAAwB,CAC7BC,KAAK,IAAI,CAACR,IAAI,KAAK,CAAC,SAAS,EAAE;gBAEvC;gBACA,aAAa;oBACT,WAAWS,8BAA8B,KAAK,CAACC,CAAAA,QAAU;4BACrD,GAAGA,KAAK;4BACR,GAAGT,OAAO,GAAG;4BACb,qCAAqC;wBACzC;gBACJ;gBACA,WAAWD,IAAI,SAAS,CAACW,WAAW,iBAAiB;gBACrD,eAAe;oBACX,WAAW;gBACf;YACJ;QACJ;QAEA,MAAMC,cAAcZ,IAAI,WAAW,CAACK,uCAAAA,MAAAA,CAAAA,WAAsB,EAAE;YACxD,MAAM;YACN,QAAQ;gBACJ,cAAcD,cAAc,MAAM,CAAC,IAAI;gBAEvC,mBAAmB;gBAGnB,YAAY;YAChB;QACJ;QAEA,OAAO;YACHF;YACA,WAAW;gBACPE;YACJ;YACAQ;YAEA,mBAAmBA,YAAY,MAAM,CAAC,WAAW,CAAC,KAAK,CACnD,CAACC,MAAgB,IAAIC,IAAID,KAAK,QAAQ;QAE9C;IACJ;AACJ"}
@@ -15,6 +15,14 @@ export declare const createApiPulumiApp: () => PulumiApp<{
15
15
  };
16
16
  addRoute: (routeParams: import("~/pulumi/apps/index.js").AddRouteParams) => any;
17
17
  };
18
+ graphqlStream: {
19
+ role: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/iam/role.js").Role>;
20
+ functions: {
21
+ graphqlStream: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/function.js").Function>;
22
+ };
23
+ functionUrl: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/lambda/functionUrl.js").FunctionUrl>;
24
+ functionUrlDomain: import("@pulumi/pulumi").Output<string>;
25
+ };
18
26
  apiGateway: {
19
27
  api: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/api.js").Api>;
20
28
  stage: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/apigatewayv2/stage.js").Stage>;
@@ -1,5 +1,5 @@
1
1
  import { createPulumiApp, isResourceOfType } from "@webiny/pulumi";
2
- import { ApiBackgroundTask, ApiCloudfront, ApiFileManager, ApiGateway, ApiGraphql, ApiWebsocket, CoreOutput, VpcConfig } from "../index.js";
2
+ import { ApiBackgroundTask, ApiCloudfront, ApiFileManager, ApiGateway, ApiGraphql, ApiGraphqlStream, ApiWebsocket, CoreOutput, VpcConfig } from "../index.js";
3
3
  import { addDomainsUrlsOutputs, withCommonLambdaEnvVariables, withServiceManifest } from "../../utils/index.js";
4
4
  import { getEnvVariableAwsRegion } from "../../env/awsRegion.js";
5
5
  import { applyAwsResourceTags, getAwsAccountId } from "../awsUtils.js";
@@ -43,7 +43,7 @@ const createApiPulumiApp = ()=>{
43
43
  app.addHandler(async ()=>{
44
44
  const featureFlags = await sdk.getFeatureFlags();
45
45
  const usingAdvancedVpcParams = vpcExtensionsConfig && "boolean" != typeof vpcExtensionsConfig;
46
- if (featureFlags.isFileManagerThreatDetectionEnabled()) handleGuardDutyEvents(app);
46
+ if (featureFlags.isEnabled("fileManager.threatDetection")) handleGuardDutyEvents(app);
47
47
  if (usingAdvancedVpcParams) {
48
48
  const { onResource, addResource } = app;
49
49
  const { useExistingVpc } = vpcExtensionsConfig;
@@ -77,22 +77,26 @@ const createApiPulumiApp = ()=>{
77
77
  app.addModule(VpcConfig, {
78
78
  enabled: vpcEnabled
79
79
  });
80
+ const graphqlEnv = {
81
+ COGNITO_REGION: getEnvVariableAwsRegion(),
82
+ COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
83
+ DB_TABLE: core.primaryDynamodbTableName,
84
+ DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName,
85
+ DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName,
86
+ OPENSEARCH_ENDPOINT: core.opensearchDomainEndpoint,
87
+ OPENSEARCH_INDEX_PREFIX: process.env.OPENSEARCH_INDEX_PREFIX,
88
+ OPENSEARCH_SHARED_INDEXES: process.env.OPENSEARCH_SHARED_INDEXES,
89
+ OPENSEARCH_USERNAME: process.env.OPENSEARCH_USERNAME,
90
+ OPENSEARCH_PASSWORD: process.env.OPENSEARCH_PASSWORD,
91
+ S3_BUCKET: core.fileManagerBucketId,
92
+ EVENT_BUS: core.eventBusArn,
93
+ OKTA_ISSUER: process.env["OKTA_ISSUER"]
94
+ };
80
95
  const graphql = app.addModule(ApiGraphql, {
81
- env: {
82
- COGNITO_REGION: getEnvVariableAwsRegion(),
83
- COGNITO_USER_POOL_ID: core.cognitoUserPoolId,
84
- DB_TABLE: core.primaryDynamodbTableName,
85
- DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName,
86
- DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName,
87
- OPENSEARCH_ENDPOINT: core.opensearchDomainEndpoint,
88
- OPENSEARCH_INDEX_PREFIX: process.env.OPENSEARCH_INDEX_PREFIX,
89
- OPENSEARCH_SHARED_INDEXES: process.env.OPENSEARCH_SHARED_INDEXES,
90
- OPENSEARCH_USERNAME: process.env.OPENSEARCH_USERNAME,
91
- OPENSEARCH_PASSWORD: process.env.OPENSEARCH_PASSWORD,
92
- S3_BUCKET: core.fileManagerBucketId,
93
- EVENT_BUS: core.eventBusArn,
94
- OKTA_ISSUER: process.env["OKTA_ISSUER"]
95
- }
96
+ env: graphqlEnv
97
+ });
98
+ const graphqlStream = app.addModule(ApiGraphqlStream, {
99
+ env: graphqlEnv
96
100
  });
97
101
  const websocket = app.addModule(ApiWebsocket);
98
102
  const fileManager = app.addModule(ApiFileManager, {
@@ -171,6 +175,8 @@ const createApiPulumiApp = ()=>{
171
175
  graphqlLambdaName: graphql.functions.graphql.output.name,
172
176
  graphqlLambdaRole: graphql.role.output.arn,
173
177
  graphqlLambdaRoleName: graphql.role.output.name,
178
+ graphqlStreamLambdaName: graphqlStream.functions.graphqlStream.output.name,
179
+ graphqlStreamFunctionUrl: graphqlStream.functionUrl.output.functionUrl,
174
180
  backgroundTaskLambdaArn: backgroundTask.backgroundTask.output.arn,
175
181
  backgroundTaskStepFunctionArn: backgroundTask.stepFunction.output.arn,
176
182
  fileManagerDownloadLambdaArn: fileManager.functions.download.output.arn,
@@ -197,6 +203,7 @@ const createApiPulumiApp = ()=>{
197
203
  return {
198
204
  fileManager,
199
205
  graphql,
206
+ graphqlStream,
200
207
  apiGateway,
201
208
  websocket,
202
209
  cloudfront,
@@ -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 { createPulumiApp, isResourceOfType, type PulumiApp } from \"@webiny/pulumi\";\nimport {\n ApiBackgroundTask,\n ApiCloudfront,\n ApiFileManager,\n ApiGateway,\n ApiGraphql,\n ApiWebsocket,\n CoreOutput,\n VpcConfig\n} 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 type { WithServiceManifest } 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 { getOsConfigFromExtension } from \"~/pulumi/apps/extensions/getOsConfigFromExtension.js\";\nimport { handleGuardDutyEvents } from \"./handleGuardDutyEvents.js\";\nimport { ApiPulumi, SetApiCustomDomains } from \"~/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 \"~/pulumi/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\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.isFileManagerThreatDetectionEnabled()) {\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 =\n vpcExtensionsConfig === true ||\n typeof vpcExtensionsConfig === \"object\" ||\n isProduction;\n\n app.addModule(VpcConfig, { enabled: vpcEnabled });\n\n const graphql = app.addModule(ApiGraphql, {\n env: {\n COGNITO_REGION: getEnvVariableAwsRegion(),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName,\n DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName,\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 });\n\n const websocket = app.addModule(ApiWebsocket);\n\n const fileManager = app.addModule(ApiFileManager, {\n env: {\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName\n }\n });\n\n const apiGateway = app.addModule(ApiGateway, {\n \"graphql-post\": {\n path: \"/graphql\",\n method: \"POST\",\n function: graphql.functions.graphql.output.arn\n },\n \"graphql-options\": {\n path: \"/graphql\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"files-any\": {\n path: \"/files/{path+}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n },\n \"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 const cloudfront = app.addModule(ApiCloudfront);\n const backgroundTask = app.addModule(ApiBackgroundTask);\n const scheduler = app.addModule(ApiScheduler);\n\n const [apiCustomDomains] = projectConfig.extensionsByType(apiCustomDomainsExt);\n if (apiCustomDomains) {\n const { domains, sslMethod, certificateArn } = apiCustomDomains.params;\n applyCustomDomain(cloudfront, {\n domains,\n sslSupportMethod: sslMethod,\n acmCertificateArn: certificateArn\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 dynamoDbTable: core.primaryDynamodbTableName,\n auditLogsDynamoDbTable: core.auditLogsDynamodbTableName,\n graphqlLambdaName: graphql.functions.graphql.output.name,\n graphqlLambdaRole: graphql.role.output.arn,\n graphqlLambdaRoleName: graphql.role.output.name,\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 // 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 apiGateway,\n websocket,\n cloudfront,\n backgroundTask,\n scheduler\n };\n }\n });\n\n const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp));\n\n app.addHandler(() => {\n app.addServiceManifest({\n name: \"api\",\n manifest: {\n bgTaskSfn: baseApp.resources.backgroundTask.stepFunction.output.arn,\n cloudfront: {\n distributionId: baseApp.resources.cloudfront.output.id,\n domain: baseApp.resources.cloudfront.output.domainName.apply(\n v => `https://${v}`\n )\n }\n }\n });\n\n app.addServiceManifest({\n name: \"scheduler\",\n manifest: {\n lambdaArn: baseApp.resources.graphql.functions.graphql.output.arn,\n roleArn: baseApp.resources.scheduler.invokeRole.output.arn\n }\n });\n });\n\n return app;\n};\n"],"names":["createApiPulumiApp","baseApp","createPulumiApp","app","sdk","getAwsProjectSdk","projectConfig","pulumiResourceNamePrefix","vpcExtensionsConfig","getVpcConfigFromExtension","openSearchExtensionConfig","getOsConfigFromExtension","searchEngineParams","params","process","resource","featureFlags","usingAdvancedVpcParams","handleGuardDutyEvents","onResource","addResource","useExistingVpc","Error","isResourceOfType","aws","canUseVpc","apiPulumi","SetApiCustomDomains","DefaultSetApiCustomDomains","pulumiHandlers","ApiPulumi","isProduction","core","CoreOutput","vpcEnabled","VpcConfig","graphql","ApiGraphql","getEnvVariableAwsRegion","websocket","ApiWebsocket","fileManager","ApiFileManager","apiGateway","ApiGateway","cloudfront","ApiCloudfront","backgroundTask","ApiBackgroundTask","scheduler","ApiScheduler","apiCustomDomains","apiCustomDomainsExt","domains","sslMethod","certificateArn","applyCustomDomain","getAwsAccountId","addDomainsUrlsOutputs","applyAwsResourceTags","withServiceManifest","withCommonLambdaEnvVariables","v"],"mappings":";;;;;;;;;;;;;;;;AAkCO,MAAMA,qBAAqB;IAC9B,MAAMC,UAAUC,gBAAgB;QAC5B,MAAM;QACN,MAAM;QACN,SAAS,OAAOC;YACZ,MAAMC,MAAM,MAAMC;YAClB,MAAMC,gBAAgB,MAAMF,IAAI,gBAAgB;YAEhD,MAAMG,2BAA2B,MAAMH,IAAI,2BAA2B;YACtE,MAAMI,sBAAsBC,0BAA0BH;YACtD,MAAMI,4BAA4BC,yBAAyBL;YAE3D,IAAIM,qBAA8D;YAElE,IAAIF,2BACAE,qBAAqBF;YAGzB,IAAIE,oBAAoB;gBACpB,MAAMC,SAASD;gBACf,IAAI,AAAkB,YAAlB,OAAOC,QAAqB;oBAC5B,IAAIA,OAAO,QAAQ,EACfC,QAAQ,GAAG,CAAC,mBAAmB,GAAGD,OAAO,QAAQ;oBAGrD,IAAIA,OAAO,UAAU,EACjBC,QAAQ,GAAG,CAAC,kBAAkB,GAAGD,OAAO,UAAU;oBAGtD,IAAIA,OAAO,WAAW,EAClBC,QAAQ,GAAG,CAAC,uBAAuB,GAAGD,OAAO,WAAW;oBAG5D,IAAIA,OAAO,aAAa,EACpBC,QAAQ,GAAG,CAAC,yBAAyB,GAAG;oBAG5C,IAAID,OAAO,QAAQ,EACfC,QAAQ,GAAG,CAAC,mBA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oBC,6BAA6B5D;IAE7DE,IAAI,UAAU,CAAC;QACXA,IAAI,kBAAkB,CAAC;YACnB,MAAM;YACN,UAAU;gBACN,WAAWF,QAAQ,SAAS,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG;gBACnE,YAAY;oBACR,gBAAgBA,QAAQ,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;oBACtD,QAAQA,QAAQ,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CACxD6D,CAAAA,IAAK,CAAC,QAAQ,EAAEA,GAAG;gBAE3B;YACJ;QACJ;QAEA3D,IAAI,kBAAkB,CAAC;YACnB,MAAM;YACN,UAAU;gBACN,WAAWF,QAAQ,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;gBACjE,SAASA,QAAQ,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG;YAC9D;QACJ;IACJ;IAEA,OAAOE;AACX"}
1
+ {"version":3,"file":"pulumi/apps/api/createApiPulumiApp.js","sources":["../../../../src/pulumi/apps/api/createApiPulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\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 {\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 type { WithServiceManifest } 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 { getOsConfigFromExtension } from \"~/pulumi/apps/extensions/getOsConfigFromExtension.js\";\nimport { handleGuardDutyEvents } from \"./handleGuardDutyEvents.js\";\nimport { ApiPulumi, SetApiCustomDomains } from \"~/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 \"~/pulumi/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\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 =\n vpcExtensionsConfig === true ||\n typeof vpcExtensionsConfig === \"object\" ||\n isProduction;\n\n app.addModule(VpcConfig, { enabled: vpcEnabled });\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 graphqlEnv = {\n COGNITO_REGION: getEnvVariableAwsRegion(),\n COGNITO_USER_POOL_ID: core.cognitoUserPoolId,\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName,\n DB_TABLE_OPENSEARCH: core.opensearchDynamodbTableName,\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\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 const websocket = app.addModule(ApiWebsocket);\n\n const fileManager = app.addModule(ApiFileManager, {\n env: {\n DB_TABLE: core.primaryDynamodbTableName,\n DB_TABLE_AUDIT_LOGS: core.auditLogsDynamodbTableName\n }\n });\n\n const apiGateway = app.addModule(ApiGateway, {\n \"graphql-post\": {\n path: \"/graphql\",\n method: \"POST\",\n function: graphql.functions.graphql.output.arn\n },\n \"graphql-options\": {\n path: \"/graphql\",\n method: \"OPTIONS\",\n function: graphql.functions.graphql.output.arn\n },\n \"files-any\": {\n path: \"/files/{path+}\",\n method: \"ANY\",\n function: fileManager.functions.download.output.arn\n },\n \"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 const cloudfront = app.addModule(ApiCloudfront);\n const backgroundTask = app.addModule(ApiBackgroundTask);\n const scheduler = app.addModule(ApiScheduler);\n\n const [apiCustomDomains] = projectConfig.extensionsByType(apiCustomDomainsExt);\n if (apiCustomDomains) {\n const { domains, sslMethod, certificateArn } = apiCustomDomains.params;\n applyCustomDomain(cloudfront, {\n domains,\n sslSupportMethod: sslMethod,\n acmCertificateArn: certificateArn\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 dynamoDbTable: core.primaryDynamodbTableName,\n auditLogsDynamoDbTable: core.auditLogsDynamodbTableName,\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 // 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 apiGateway,\n websocket,\n cloudfront,\n backgroundTask,\n scheduler\n };\n }\n });\n\n const app = withServiceManifest(withCommonLambdaEnvVariables(baseApp));\n\n app.addHandler(() => {\n app.addServiceManifest({\n name: \"api\",\n manifest: {\n bgTaskSfn: baseApp.resources.backgroundTask.stepFunction.output.arn,\n cloudfront: {\n distributionId: baseApp.resources.cloudfront.output.id,\n domain: baseApp.resources.cloudfront.output.domainName.apply(\n v => `https://${v}`\n )\n }\n }\n });\n\n app.addServiceManifest({\n name: \"scheduler\",\n manifest: {\n lambdaArn: baseApp.resources.graphql.functions.graphql.output.arn,\n roleArn: baseApp.resources.scheduler.invokeRole.output.arn\n }\n });\n });\n\n return app;\n};\n"],"names":["createApiPulumiApp","baseApp","createPulumiApp","app","sdk","getAwsProjectSdk","projectConfig","pulumiResourceNamePrefix","vpcExtensionsConfig","getVpcConfigFromExtension","openSearchExtensionConfig","getOsConfigFromExtension","searchEngineParams","params","process","resource","featureFlags","usingAdvancedVpcParams","handleGuardDutyEvents","onResource","addResource","useExistingVpc","Error","isResourceOfType","aws","canUseVpc","apiPulumi","SetApiCustomDomains","DefaultSetApiCustomDomains","pulumiHandlers","ApiPulumi","isProduction","core","CoreOutput","vpcEnabled","VpcConfig","graphqlEnv","getEnvVariableAwsRegion","graphql","ApiGraphql","graphqlStream","ApiGraphqlStream","websocket","ApiWebsocket","fileManager","ApiFileManager","apiGateway","ApiGateway","cloudfront","ApiCloudfront","backgroundTask","ApiBackgroundTask","scheduler","ApiScheduler","apiCustomDomains","apiCustomDomainsExt","domains","sslMethod","certificateArn","applyCustomDomain","getAwsAccountId","addDomainsUrlsOutputs","applyAwsResourceTags","withServiceManifest","withCommonLambdaEnvVariables","v"],"mappings":";;;;;;;;;;;;;;;;AAmCO,MAAMA,qBAAqB;IAC9B,MAAMC,UAAUC,gBAAgB;QAC5B,MAAM;QACN,MAAM;QACN,SAAS,OAAOC;YACZ,MAAMC,MAAM,MAAMC;YAClB,MAAMC,gBAAgB,MAAMF,IAAI,gBAAgB;YAEhD,MAAMG,2BAA2B,MAAMH,IAAI,2BAA2B;YACtE,MAAMI,sBAAsBC,0BAA0BH;YACtD,MAAMI,4BAA4BC,yBAAyBL;YAE3D,IAA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MAAM,CAAC,GAAG;gBACjE,SAASA,QAAQ,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG;YAC9D;QACJ;IACJ;IAEA,OAAOE;AACX"}
@@ -3,6 +3,7 @@ export * from "./ApiCloudfront.js";
3
3
  export * from "./ApiFileManager.js";
4
4
  export * from "./ApiGateway.js";
5
5
  export * from "./ApiGraphql.js";
6
+ export * from "./ApiGraphqlStream.js";
6
7
  export * from "./createApiPulumiApp.js";
7
8
  export * from "./ApiOutput.js";
8
9
  export * from "./ApiWebsocket.js";
@@ -3,6 +3,7 @@ export * from "./ApiCloudfront.js";
3
3
  export * from "./ApiFileManager.js";
4
4
  export * from "./ApiGateway.js";
5
5
  export * from "./ApiGraphql.js";
6
+ export * from "./ApiGraphqlStream.js";
6
7
  export * from "./createApiPulumiApp.js";
7
8
  export * from "./ApiOutput.js";
8
9
  export * from "./ApiWebsocket.js";
@@ -1,5 +1,5 @@
1
1
  import { type PulumiApp } from "@webiny/pulumi";
2
2
  import { type AppName } from "@webiny/project";
3
3
  export declare function getAwsAccountId(app: PulumiApp): import("@pulumi/pulumi").Output<string>;
4
- export declare function getAwsRegion(app: PulumiApp): import("@pulumi/pulumi").Output<"af-south-1" | "ap-east-1" | "ap-east-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ap-south-1" | "ap-south-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-southeast-3" | "ap-southeast-4" | "ap-southeast-5" | "ap-southeast-7" | "ca-central-1" | "ca-west-1" | "cn-north-1" | "cn-northwest-1" | "eu-central-1" | "eu-central-2" | "eu-isoe-west-1" | "eu-north-1" | "eu-south-1" | "eu-south-2" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "il-central-1" | "me-central-1" | "me-south-1" | "mx-central-1" | "sa-east-1" | "us-east-1" | "us-east-2" | "us-gov-east-1" | "us-gov-west-1" | "us-iso-east-1" | "us-iso-west-1" | "us-isob-east-1" | "us-west-1" | "us-west-2">;
4
+ export declare function getAwsRegion(app: PulumiApp): import("@pulumi/pulumi").Output<"af-south-1" | "ap-east-1" | "ap-east-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ap-south-1" | "ap-south-2" | "ap-southeast-1" | "ap-southeast-2" | "ap-southeast-3" | "ap-southeast-4" | "ap-southeast-5" | "ap-southeast-6" | "ap-southeast-7" | "ca-central-1" | "ca-west-1" | "cn-north-1" | "cn-northwest-1" | "eu-central-1" | "eu-central-2" | "eu-isoe-west-1" | "eu-north-1" | "eu-south-1" | "eu-south-2" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eusc-de-east-1" | "il-central-1" | "me-central-1" | "me-south-1" | "mx-central-1" | "sa-east-1" | "us-east-1" | "us-east-2" | "us-gov-east-1" | "us-gov-west-1" | "us-iso-east-1" | "us-iso-west-1" | "us-isob-east-1" | "us-isob-west-1" | "us-isof-east-1" | "us-isof-south-1" | "us-west-1" | "us-west-2">;
5
5
  export declare function applyAwsResourceTags(appName: AppName): Promise<void>;
@@ -2,6 +2,7 @@ import { type PulumiAppModule } from "@webiny/pulumi";
2
2
  export interface CoreCognitoParams {
3
3
  protect: boolean;
4
4
  useEmailAsUsername: boolean;
5
+ mfa?: boolean;
5
6
  }
6
7
  export type CoreCognito = PulumiAppModule<typeof CoreCognito>;
7
8
  export declare const CoreCognito: import("@webiny/pulumi").PulumiAppModuleDefinition<{
@@ -30,7 +30,10 @@ const CoreCognito = createAppModule({
30
30
  "preferred_username"
31
31
  ],
32
32
  lambdaConfig: {},
33
- mfaConfiguration: "OFF",
33
+ mfaConfiguration: params.mfa ? "ON" : "OFF",
34
+ softwareTokenMfaConfiguration: params.mfa ? {
35
+ enabled: true
36
+ } : void 0,
34
37
  userPoolAddOns: {
35
38
  advancedSecurityMode: "OFF"
36
39
  },
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/apps/core/CoreCognito.js","sources":["../../../../src/pulumi/apps/core/CoreCognito.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { createAppModule, type PulumiApp, type PulumiAppModule } from \"@webiny/pulumi\";\n\nexport interface CoreCognitoParams {\n protect: boolean;\n useEmailAsUsername: boolean;\n}\n\nexport type CoreCognito = PulumiAppModule<typeof CoreCognito>;\n\nexport const CoreCognito = createAppModule({\n name: \"Cognito\",\n config(app: PulumiApp, params: CoreCognitoParams) {\n const userPool = app.addResource(aws.cognito.UserPool, {\n name: \"user-pool\",\n config: {\n passwordPolicy: {\n minimumLength: 8,\n requireLowercase: false,\n requireNumbers: false,\n requireSymbols: false,\n requireUppercase: false,\n temporaryPasswordValidityDays: 7\n },\n adminCreateUserConfig: {\n allowAdminCreateUserOnly: true\n },\n autoVerifiedAttributes: [\"email\"],\n emailConfiguration: {\n emailSendingAccount: \"COGNITO_DEFAULT\"\n },\n // In a legacy setup we use email as username.\n // We need to provide a way for users to have this setup,\n // because changing it would require whole cognito pool to be recreated.\n usernameAttributes: params.useEmailAsUsername ? [\"email\"] : undefined,\n aliasAttributes: params.useEmailAsUsername ? undefined : [\"preferred_username\"],\n lambdaConfig: {},\n mfaConfiguration: \"OFF\",\n userPoolAddOns: {\n advancedSecurityMode: \"OFF\" /* required */\n },\n verificationMessageTemplate: {\n defaultEmailOption: \"CONFIRM_WITH_CODE\"\n },\n accountRecoverySetting: {\n recoveryMechanisms: [{ name: \"verified_email\", priority: 1 }]\n },\n schemas: [\n {\n attributeDataType: \"String\",\n name: \"email\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"family_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"given_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"id\",\n required: false,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"36\",\n minLength: \"0\"\n }\n }\n ]\n },\n opts: {\n protect: params.protect\n }\n });\n\n const userPoolClient = app.addResource(aws.cognito.UserPoolClient, {\n name: \"user-pool-client\",\n config: {\n userPoolId: userPool.output.id,\n accessTokenValidity: 60,\n idTokenValidity: 60,\n refreshTokenValidity: 30,\n tokenValidityUnits: {\n accessToken: \"minutes\",\n idToken: \"minutes\",\n refreshToken: \"days\"\n }\n }\n });\n\n return {\n userPool,\n userPoolClient\n };\n }\n});\n"],"names":["CoreCognito","createAppModule","app","params","userPool","aws","undefined","userPoolClient"],"mappings":";;AAUO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAAyB;QAC5C,MAAMC,WAAWF,IAAI,WAAW,CAACG,uCAAAA,OAAAA,CAAAA,QAAoB,EAAE;YACnD,MAAM;YACN,QAAQ;gBACJ,gBAAgB;oBACZ,eAAe;oBACf,kBAAkB;oBAClB,gBAAgB;oBAChB,gBAAgB;oBAChB,kBAAkB;oBAClB,+BAA+B;gBACnC;gBACA,uBAAuB;oBACnB,0BAA0B;gBAC9B;gBACA,wBAAwB;oBAAC;iBAAQ;gBACjC,oBAAoB;oBAChB,qBAAqB;gBACzB;gBAIA,oBAAoBF,OAAO,kBAAkB,GAAG;oBAAC;iBAAQ,GAAGG;gBAC5D,iBAAiBH,OAAO,kBAAkB,GAAGG,SAAY;oBAAC;iBAAqB;gBAC/E,cAAc,CAAC;gBACf,kBAAkB;gBAClB,gBAAgB;oBACZ,sBAAsB;gBAC1B;gBACA,6BAA6B;oBACzB,oBAAoB;gBACxB;gBACA,wBAAwB;oBACpB,oBAAoB;wBAAC;4BAAE,MAAM;4BAAkB,UAAU;wBAAE;qBAAE;gBACjE;gBACA,SAAS;oBACL;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;oBACA;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;oBACA;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;oBACA;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;iBACH;YACL;YACA,MAAM;gBACF,SAASH,OAAO,OAAO;YAC3B;QACJ;QAEA,MAAMI,iBAAiBL,IAAI,WAAW,CAACG,uCAAAA,OAAAA,CAAAA,cAA0B,EAAE;YAC/D,MAAM;YACN,QAAQ;gBACJ,YAAYD,SAAS,MAAM,CAAC,EAAE;gBAC9B,qBAAqB;gBACrB,iBAAiB;gBACjB,sBAAsB;gBACtB,oBAAoB;oBAChB,aAAa;oBACb,SAAS;oBACT,cAAc;gBAClB;YACJ;QACJ;QAEA,OAAO;YACHA;YACAG;QACJ;IACJ;AACJ"}
1
+ {"version":3,"file":"pulumi/apps/core/CoreCognito.js","sources":["../../../../src/pulumi/apps/core/CoreCognito.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { createAppModule, type PulumiApp, type PulumiAppModule } from \"@webiny/pulumi\";\n\nexport interface CoreCognitoParams {\n protect: boolean;\n useEmailAsUsername: boolean;\n mfa?: boolean;\n}\n\nexport type CoreCognito = PulumiAppModule<typeof CoreCognito>;\n\nexport const CoreCognito = createAppModule({\n name: \"Cognito\",\n config(app: PulumiApp, params: CoreCognitoParams) {\n const userPool = app.addResource(aws.cognito.UserPool, {\n name: \"user-pool\",\n config: {\n passwordPolicy: {\n minimumLength: 8,\n requireLowercase: false,\n requireNumbers: false,\n requireSymbols: false,\n requireUppercase: false,\n temporaryPasswordValidityDays: 7\n },\n adminCreateUserConfig: {\n allowAdminCreateUserOnly: true\n },\n autoVerifiedAttributes: [\"email\"],\n emailConfiguration: {\n emailSendingAccount: \"COGNITO_DEFAULT\"\n },\n // In a legacy setup we use email as username.\n // We need to provide a way for users to have this setup,\n // because changing it would require whole cognito pool to be recreated.\n usernameAttributes: params.useEmailAsUsername ? [\"email\"] : undefined,\n aliasAttributes: params.useEmailAsUsername ? undefined : [\"preferred_username\"],\n lambdaConfig: {},\n mfaConfiguration: params.mfa ? \"ON\" : \"OFF\",\n softwareTokenMfaConfiguration: params.mfa ? { enabled: true } : undefined,\n userPoolAddOns: {\n advancedSecurityMode: \"OFF\" /* required */\n },\n verificationMessageTemplate: {\n defaultEmailOption: \"CONFIRM_WITH_CODE\"\n },\n accountRecoverySetting: {\n recoveryMechanisms: [{ name: \"verified_email\", priority: 1 }]\n },\n schemas: [\n {\n attributeDataType: \"String\",\n name: \"email\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"family_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"given_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"id\",\n required: false,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"36\",\n minLength: \"0\"\n }\n }\n ]\n },\n opts: {\n protect: params.protect\n }\n });\n\n const userPoolClient = app.addResource(aws.cognito.UserPoolClient, {\n name: \"user-pool-client\",\n config: {\n userPoolId: userPool.output.id,\n accessTokenValidity: 60,\n idTokenValidity: 60,\n refreshTokenValidity: 30,\n tokenValidityUnits: {\n accessToken: \"minutes\",\n idToken: \"minutes\",\n refreshToken: \"days\"\n }\n }\n });\n\n return {\n userPool,\n userPoolClient\n };\n }\n});\n"],"names":["CoreCognito","createAppModule","app","params","userPool","aws","undefined","userPoolClient"],"mappings":";;AAWO,MAAMA,cAAcC,gBAAgB;IACvC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAAyB;QAC5C,MAAMC,WAAWF,IAAI,WAAW,CAACG,uCAAAA,OAAAA,CAAAA,QAAoB,EAAE;YACnD,MAAM;YACN,QAAQ;gBACJ,gBAAgB;oBACZ,eAAe;oBACf,kBAAkB;oBAClB,gBAAgB;oBAChB,gBAAgB;oBAChB,kBAAkB;oBAClB,+BAA+B;gBACnC;gBACA,uBAAuB;oBACnB,0BAA0B;gBAC9B;gBACA,wBAAwB;oBAAC;iBAAQ;gBACjC,oBAAoB;oBAChB,qBAAqB;gBACzB;gBAIA,oBAAoBF,OAAO,kBAAkB,GAAG;oBAAC;iBAAQ,GAAGG;gBAC5D,iBAAiBH,OAAO,kBAAkB,GAAGG,SAAY;oBAAC;iBAAqB;gBAC/E,cAAc,CAAC;gBACf,kBAAkBH,OAAO,GAAG,GAAG,OAAO;gBACtC,+BAA+BA,OAAO,GAAG,GAAG;oBAAE,SAAS;gBAAK,IAAIG;gBAChE,gBAAgB;oBACZ,sBAAsB;gBAC1B;gBACA,6BAA6B;oBACzB,oBAAoB;gBACxB;gBACA,wBAAwB;oBACpB,oBAAoB;wBAAC;4BAAE,MAAM;4BAAkB,UAAU;wBAAE;qBAAE;gBACjE;gBACA,SAAS;oBACL;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;oBACA;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;oBACA;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;oBACA;wBACI,mBAAmB;wBACnB,MAAM;wBACN,UAAU;wBACV,wBAAwB;wBACxB,SAAS;wBACT,4BAA4B;4BACxB,WAAW;4BACX,WAAW;wBACf;oBACJ;iBACH;YACL;YACA,MAAM;gBACF,SAASH,OAAO,OAAO;YAC3B;QACJ;QAEA,MAAMI,iBAAiBL,IAAI,WAAW,CAACG,uCAAAA,OAAAA,CAAAA,cAA0B,EAAE;YAC/D,MAAM;YACN,QAAQ;gBACJ,YAAYD,SAAS,MAAM,CAAC,EAAE;gBAC9B,qBAAqB;gBACrB,iBAAiB;gBACjB,sBAAsB;gBACtB,oBAAoB;oBAChB,aAAa;oBACb,SAAS;oBACT,cAAc;gBAClB;YACJ;QACJ;QAEA,OAAO;YACHA;YACAG;QACJ;IACJ;AACJ"}
@@ -17,15 +17,23 @@ const configureAdminCognitoFederation = (app, config)=>{
17
17
  });
18
18
  app.addOutput("cognitoUserPoolDomain", __rspack_external__pulumi_pulumi_f3e773ed.interpolate`${userPoolDomain.output.domain}.auth.${region}.amazoncognito.com`);
19
19
  const idpConfigs = [];
20
+ const idpOutputs = [];
20
21
  for (const idp of config.identityProviders){
21
22
  const config = getIdpConfig(idp.type, userPool.output.id, idp);
22
23
  const name = config.providerName.toString().toLowerCase();
23
- app.addResource(__rspack_external__pulumi_aws_9e2bee2d.cognito.IdentityProvider, {
24
+ const idpResource = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.cognito.IdentityProvider, {
24
25
  name,
25
26
  config
26
27
  });
28
+ idpOutputs.push(idpResource.output);
27
29
  idpConfigs.push(config);
28
30
  }
31
+ appClient.opts.dependsOn = [
32
+ ...appClient.opts.dependsOn ? Array.isArray(appClient.opts.dependsOn) ? appClient.opts.dependsOn : [
33
+ appClient.opts.dependsOn
34
+ ] : [],
35
+ ...idpOutputs
36
+ ];
29
37
  appClient.config.supportedIdentityProviders([
30
38
  "COGNITO",
31
39
  ...idpConfigs.map((config)=>{
@@ -1 +1 @@
1
- {"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/configure.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/configure.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { type UserPoolDomainArgs } from \"@pulumi/aws/cognito/userPoolDomain.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport {\n type PulumiApp,\n type PulumiAppResource,\n type PulumiAppResourceConstructor\n} from \"@webiny/pulumi\";\nimport { getIdpConfig } from \"./getIdpConfig.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\n\nexport type IdentityAttributeMapping = {\n \"custom:id\": string;\n username: string;\n email: string;\n family_name: string;\n given_name: string;\n [key: string]: string;\n};\n\nexport interface CognitoIdentityProvidersConfig {\n domain:\n | string\n | {\n name: UserPoolDomainArgs[\"domain\"];\n certificateArn?: UserPoolDomainArgs[\"certificateArn\"];\n };\n identityProviders: CognitoIdentityProviderConfig[];\n callbackUrls: string[];\n logoutUrls?: string[];\n}\n\nexport interface CognitoIdentityProviderConfig {\n name?: string;\n type: \"google\" | \"facebook\" | \"amazon\" | \"apple\" | \"oidc\";\n providerDetails: IdentityProviderArgs[\"providerDetails\"];\n idpIdentifiers?: IdentityProviderArgs[\"idpIdentifiers\"];\n attributeMapping?: IdentityAttributeMapping;\n}\n\nconst isString = (value?: any): value is string => {\n return typeof value === \"string\";\n};\n\nexport const configureAdminCognitoFederation = (\n app: PulumiApp,\n config: CognitoIdentityProvidersConfig\n) => {\n const region = getEnvVariableAwsRegion();\n\n const userPool = app.resources.userPool as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPool>\n >;\n\n const appClient = app.resources.userPoolClient as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPoolClient>\n >;\n\n /**\n * We need to create a user pool domain, which is used to interact with the federated identity providers.\n */\n const userPoolDomain = app.addResource(aws.cognito.UserPoolDomain, {\n name: \"cognitoUserPoolDomain\",\n config: {\n domain: isString(config.domain) ? config.domain : config.domain.name,\n certificateArn: isString(config.domain) ? undefined : config.domain.certificateArn,\n userPoolId: userPool.output.id\n }\n });\n\n app.addOutput(\n \"cognitoUserPoolDomain\",\n pulumi.interpolate`${userPoolDomain.output.domain}.auth.${region}.amazoncognito.com`\n );\n\n const idpConfigs: aws.cognito.IdentityProviderArgs[] = [];\n\n for (const idp of config.identityProviders) {\n const config = getIdpConfig(idp.type, userPool.output.id, idp);\n\n // The idea to lowercase the provider name emerged while working on backwards compatibility issue.\n // Basically, in cases where a user used the OIDC provider and did not specify a name, instead of\n // using `OIDC` as the name, we wanted to ensure `oidc` is used. But, what I soon realized is that\n // by simply lowercasing the name, we can avoid the need to check for the provider type and name.\n // And although this will now happen for all providers, it's not a problem since Pulumi requires\n // names to be all lowercase anyway.\n const name = config.providerName.toString().toLowerCase();\n\n app.addResource(aws.cognito.IdentityProvider, { name, config });\n\n idpConfigs.push(config);\n }\n\n appClient.config.supportedIdentityProviders([\n \"COGNITO\",\n ...idpConfigs.map(config => {\n // For built-in identity providers, we use the type as the name. Only for OIDC,\n // we allow the user to provide a custom name, and we only use the type as a fallback.\n if (config.providerType === \"OIDC\") {\n return config.providerName;\n }\n return config.providerType;\n })\n ]);\n\n appClient.config.allowedOauthScopes([\"profile\", \"email\", \"openid\"]);\n appClient.config.allowedOauthFlows([\"implicit\", \"code\"]);\n appClient.config.allowedOauthFlowsUserPoolClient(true);\n appClient.config.callbackUrls(config.callbackUrls);\n appClient.config.logoutUrls(config.logoutUrls ?? config.callbackUrls);\n};\n"],"names":["isString","value","configureAdminCognitoFederation","app","config","region","getEnvVariableAwsRegion","userPool","appClient","userPoolDomain","aws","undefined","pulumi","idpConf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QAAS;KAAS;IAClEA,UAAU,MAAM,CAAC,iBAAiB,CAAC;QAAC;QAAY;KAAO;IACvDA,UAAU,MAAM,CAAC,+BAA+B,CAAC;IACjDA,UAAU,MAAM,CAAC,YAAY,CAACJ,OAAO,YAAY;IACjDI,UAAU,MAAM,CAAC,UAAU,CAACJ,OAAO,UAAU,IAAIA,OAAO,YAAY;AACxE"}
1
+ {"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/configure.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/configure.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { type UserPoolDomainArgs } from \"@pulumi/aws/cognito/userPoolDomain.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport {\n type PulumiApp,\n type PulumiAppResource,\n type PulumiAppResourceConstructor\n} from \"@webiny/pulumi\";\nimport { getIdpConfig } from \"./getIdpConfig.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\n\nexport type IdentityAttributeMapping = {\n \"custom:id\": string;\n username: string;\n email: string;\n family_name: string;\n given_name: string;\n [key: string]: string;\n};\n\nexport interface CognitoIdentityProvidersConfig {\n domain:\n | string\n | {\n name: UserPoolDomainArgs[\"domain\"];\n certificateArn?: UserPoolDomainArgs[\"certificateArn\"];\n };\n identityProviders: CognitoIdentityProviderConfig[];\n callbackUrls: string[];\n logoutUrls?: string[];\n}\n\nexport interface CognitoIdentityProviderConfig {\n name?: string;\n type: \"google\" | \"facebook\" | \"amazon\" | \"apple\" | \"oidc\";\n providerDetails: IdentityProviderArgs[\"providerDetails\"];\n idpIdentifiers?: IdentityProviderArgs[\"idpIdentifiers\"];\n attributeMapping?: IdentityAttributeMapping;\n}\n\nconst isString = (value?: any): value is string => {\n return typeof value === \"string\";\n};\n\nexport const configureAdminCognitoFederation = (\n app: PulumiApp,\n config: CognitoIdentityProvidersConfig\n) => {\n const region = getEnvVariableAwsRegion();\n\n const userPool = app.resources.userPool as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPool>\n >;\n\n const appClient = app.resources.userPoolClient as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPoolClient>\n >;\n\n /**\n * We need to create a user pool domain, which is used to interact with the federated identity providers.\n */\n const userPoolDomain = app.addResource(aws.cognito.UserPoolDomain, {\n name: \"cognitoUserPoolDomain\",\n config: {\n domain: isString(config.domain) ? config.domain : config.domain.name,\n certificateArn: isString(config.domain) ? undefined : config.domain.certificateArn,\n userPoolId: userPool.output.id\n }\n });\n\n app.addOutput(\n \"cognitoUserPoolDomain\",\n pulumi.interpolate`${userPoolDomain.output.domain}.auth.${region}.amazoncognito.com`\n );\n\n const idpConfigs: aws.cognito.IdentityProviderArgs[] = [];\n const idpOutputs: pulumi.Output<aws.cognito.IdentityProvider>[] = [];\n\n for (const idp of config.identityProviders) {\n const config = getIdpConfig(idp.type, userPool.output.id, idp);\n\n // The idea to lowercase the provider name emerged while working on backwards compatibility issue.\n // Basically, in cases where a user used the OIDC provider and did not specify a name, instead of\n // using `OIDC` as the name, we wanted to ensure `oidc` is used. But, what I soon realized is that\n // by simply lowercasing the name, we can avoid the need to check for the provider type and name.\n // And although this will now happen for all providers, it's not a problem since Pulumi requires\n // names to be all lowercase anyway.\n const name = config.providerName.toString().toLowerCase();\n\n const idpResource = app.addResource(aws.cognito.IdentityProvider, { name, config });\n idpOutputs.push(idpResource.output);\n\n idpConfigs.push(config);\n }\n\n appClient.opts.dependsOn = [\n ...(appClient.opts.dependsOn\n ? Array.isArray(appClient.opts.dependsOn)\n ? appClient.opts.dependsOn\n : [appClient.opts.dependsOn]\n : []),\n ...idpOutputs\n ] as pulumi.Input<pulumi.Resource>[];\n\n appClient.config.supportedIdentityProviders([\n \"COGNITO\",\n ...idpConfigs.map(config => {\n // For built-in identity providers, we use the type as the name. Only for OIDC,\n // we allow the user to provide a custom name, and we only use the type as a fallback.\n if (config.providerType === \"OIDC\") {\n return config.providerName;\n }\n return config.providerType;\n })\n ]);\n\n appClient.config.allowedOauthScopes([\"profile\", \"email\", \"openid\"]);\n appClient.config.allowedOauthFlows([\"implicit\", \"code\"]);\n appClient.config.allowedOauthFlowsUserPoolClient(true);\n appClient.config.callbackUrls(config.callbackUrls);\n appClient.config.logoutUrls(config.logoutUrls ?? config.callbackUrls);\n};\n"],"names":["isString","value","configureAdminCognitoFederation","app","config","region","getEnvVariableAwsRegion","userPool","appClient","userPoolDomain","aws","undefined","pulumi","idpConfigs","idpOutputs","idp","getIdpConfig","name","idpResource","Array"],"mappings":";;;;AAyCA,MAAMA,WAAW,CAACC,QACP,AAAiB,YAAjB,OAAOA;AAGX,MAAMC,kCAAkC,CAC3CC,KACAC;IAEA,MAAMC,SAASC;IAEf,MAAMC,WAAWJ,IAAI,SAAS,CAAC,QAAQ;IAIvC,MAAMK,YAAYL,IAAI,SAAS,CAAC,cAAc;IAO9C,MAAMM,iBAAiBN,IAAI,WAAW,CAACO,uCAAAA,OAAAA,CAAAA,cAA0B,EAAE;QAC/D,MAAM;QACN,QAAQ;YACJ,QAAQV,SAASI,OAAO,MAAM,IAAIA,OAAO,MAAM,GAAGA,OAAO,MAAM,CAAC,IAAI;YACpE,gBAAgBJ,SAASI,OAAO,MAAM,IAAIO,SAAYP,OAAO,MAAM,CAAC,cAAc;YAClF,YAAYG,SAAS,MAAM,CAAC,EAAE;QAClC;IACJ;IAEAJ,IAAI,SAAS,CACT,yBACAS,0CAAAA,WAAkB,CAAC,EAAEH,eAAe,MAAM,CAAC,MAAM,CAAC,MAAM,EAAEJ,OAAO,kBAAkB,CAAC;IAGxF,MAAMQ,aAAiD,EAAE;IACzD,MAAMC,aAA4D,EAAE;IAEpE,KAAK,MAAMC,OAAOX,OAAO,iBAAiB,CAAE;QACxC,MAAMA,SAASY,aAAaD,IAAI,IAAI,EAAER,SAAS,MAAM,CAAC,EAAE,EAAEQ;QAQ1D,MAAME,OAAOb,OAAO,YAAY,CAAC,QAAQ,GAAG,WAAW;QAEvD,MAAMc,cAAcf,IAAI,WAAW,CAACO,uCAAAA,OAAAA,CAAAA,gBAA4B,EAAE;YAAEO;YAAMb;QAAO;QACjFU,WAAW,IAAI,CAACI,YAAY,MAAM;QAElCL,WAAW,IAAI,CAACT;IACpB;IAEAI,UAAU,IAAI,CAAC,SAAS,GAAG;WACnBA,UAAU,IAAI,CAAC,SAAS,GACtBW,MAAM,OAAO,CAACX,UAAU,IAAI,CAAC,SAAS,IAClCA,UAAU,IAAI,CAAC,SAAS,GACxB;YAACA,UAAU,IAAI,CAAC,SAAS;SAAC,GAC9B,EAAE;WACLM;KACN;IAEDN,UAAU,MAAM,CAAC,0BAA0B,CAAC;QACxC;WACGK,WAAW,GAAG,CAACT,CAAAA;YAGd,IAAIA,AAAwB,WAAxBA,OAAO,YAAY,EACnB,OAAOA,OAAO,YAAY;YAE9B,OAAOA,OAAO,YAAY;QAC9B;KACH;IAEDI,UAAU,MAAM,CAAC,kBAAkB,CAAC;QAAC;QAAW;QAAS;KAAS;IAClEA,UAAU,MAAM,CAAC,iBAAiB,CAAC;QAAC;QAAY;KAAO;IACvDA,UAAU,MAAM,CAAC,+BAA+B,CAAC;IACjDA,UAAU,MAAM,CAAC,YAAY,CAACJ,OAAO,YAAY;IACjDI,UAAU,MAAM,CAAC,UAAU,CAACJ,OAAO,UAAU,IAAIA,OAAO,YAAY;AACxE"}
@@ -56,7 +56,7 @@ function createCorePulumiApp() {
56
56
  app.addHandler(async ()=>{
57
57
  const usingAdvancedVpcParams = vpcExtensionsConfig && "boolean" != typeof vpcExtensionsConfig;
58
58
  const featureFlags = await sdk.getFeatureFlags();
59
- if (featureFlags.isFileManagerThreatDetectionEnabled()) configureS3BucketMalwareProtection(app);
59
+ if (featureFlags.isEnabled("fileManager.threatDetection")) configureS3BucketMalwareProtection(app);
60
60
  if (!usingAdvancedVpcParams) return;
61
61
  const { resources, addResource, onResource } = app;
62
62
  const { useExistingVpc, useVpcEndpoints } = vpcExtensionsConfig;
@@ -158,8 +158,24 @@ function createCorePulumiApp() {
158
158
  const vpc = vpcEnabled ? app.addModule(CoreVpc) : null;
159
159
  const cognito = app.addModule(CoreCognito, {
160
160
  protect,
161
- useEmailAsUsername: false
161
+ useEmailAsUsername: false,
162
+ mfa: "true" === process.env.COGNITO_MFA
162
163
  });
164
+ const isNewDeployment = !coreStackOutput || 0 === Object.keys(coreStackOutput).length;
165
+ if (isNewDeployment) cognito.userPool.config.schemas((schemas)=>schemas?.map((schema)=>{
166
+ if ("id" === schema.name) return {
167
+ ...schema,
168
+ stringAttributeConstraints: {
169
+ ...schema.stringAttributeConstraints,
170
+ maxLength: "256"
171
+ }
172
+ };
173
+ return schema;
174
+ }));
175
+ else cognito.userPool.opts.ignoreChanges = [
176
+ ...cognito.userPool.opts.ignoreChanges || [],
177
+ "schemas"
178
+ ];
163
179
  const eventBus = app.addModule(CoreEventBus);
164
180
  const { bucket: fileManagerBucket } = app.addModule(CoreFileManger, {
165
181
  protect