@webiny/project-aws 6.5.4-beta.1 → 6.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/createAdminAppConfig.js.map +1 -1
- package/extensions/ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.js.map +1 -1
- package/extensions/ProjectAws/BuildAppWorkspace.js.map +1 -1
- package/extensions/ProjectAws/UploadAdminAppToS3.js.map +1 -1
- package/package.json +12 -12
- package/pulumi/apps/api/ApiFileManager.js.map +1 -1
- package/pulumi/apps/api/ApiGraphql.js.map +1 -1
- package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
- package/pulumi/apps/api/handleGuardDutyEvents.js.map +1 -1
- package/pulumi/apps/blueGreen/validation/validateDeployments.js.map +1 -1
- package/pulumi/apps/core/CoreCognito.js.map +1 -1
- package/pulumi/apps/core/cognitoIdentityProviders/amazon.js.map +1 -1
- package/pulumi/apps/core/cognitoIdentityProviders/apple.js.map +1 -1
- package/pulumi/apps/core/cognitoIdentityProviders/facebook.js.map +1 -1
- package/pulumi/apps/core/cognitoIdentityProviders/google.js.map +1 -1
- package/pulumi/apps/core/cognitoIdentityProviders/oidc.js.map +1 -1
- package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
- package/pulumi/apps/syncSystem/SyncSystemLambda.js.map +1 -1
- package/pulumi/apps/syncSystem/createSyncSystemPulumiApp.js.map +1 -1
- package/pulumi/utils/dynamodb.js.map +1 -1
- package/pulumi/utils/uploadFolderToS3.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps/createAdminAppConfig.js","sources":["../../src/apps/createAdminAppConfig.ts"],"sourcesContent":["import { createReactAppConfig, type ReactAppConfigModifier } from \"./createReactAppConfig.js\";\n\nexport const createAdminAppConfig = (modifier?: ReactAppConfigModifier) => {\n return createReactAppConfig(baseParams => {\n const { config, options } = baseParams;\n\n config.customEnv(env => ({\n ...env,\n PORT: process.env.PORT || 3001,\n WEBINY_ADMIN_DEBUG: process.env.DEBUG,\n WEBINY_ADMIN_ENV: options.env,\n WEBINY_ADMIN_TRASH_BIN_RETENTION_PERIOD_DAYS: process.env\n .WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS as string\n }));\n\n if (modifier) {\n modifier(baseParams);\n }\n });\n};\n"],"names":["createAdminAppConfig","modifier","createReactAppConfig","baseParams","config","options","env","process"],"mappings":";AAEO,MAAMA,uBAAuB,CAACC,WAC1BC,qBAAqBC,CAAAA;QACxB,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5BC,OAAO,SAAS,CAACE,CAAAA,MAAQ;gBACrB,GAAGA,GAAG;gBACN,MAAMC,QAAQ,GAAG,CAAC,IAAI,IAAI;gBAC1B,oBAAoBA,QAAQ,GAAG,CAAC,KAAK;gBACrC,kBAAkBF,QAAQ,GAAG;gBAC7B,8CAA8CE,QAAQ,GAAG,CACpD,sCAAsC;YAC/C;
|
|
1
|
+
{"version":3,"file":"apps/createAdminAppConfig.js","sources":["../../src/apps/createAdminAppConfig.ts"],"sourcesContent":["import { createReactAppConfig, type ReactAppConfigModifier } from \"./createReactAppConfig.js\";\n\nexport const createAdminAppConfig = (modifier?: ReactAppConfigModifier) => {\n return createReactAppConfig(baseParams => {\n const { config, options } = baseParams;\n\n config.customEnv(env => ({\n ...env,\n PORT: process.env.PORT || 3001,\n WEBINY_ADMIN_DEBUG: process.env.DEBUG,\n WEBINY_ADMIN_ENV: options.env,\n WEBINY_ADMIN_TRASH_BIN_RETENTION_PERIOD_DAYS: process.env\n .WEBINY_TRASH_BIN_RETENTION_PERIOD_DAYS as string\n }));\n\n if (modifier) {\n modifier(baseParams);\n }\n });\n};\n"],"names":["createAdminAppConfig","modifier","createReactAppConfig","baseParams","config","options","env","process"],"mappings":";AAEO,MAAMA,uBAAuB,CAACC,WAC1BC,qBAAqBC,CAAAA;QACxB,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAE5BC,OAAO,SAAS,CAACE,CAAAA,MAAQ;gBACrB,GAAGA,GAAG;gBACN,MAAMC,QAAQ,GAAG,CAAC,IAAI,IAAI;gBAC1B,oBAAoBA,QAAQ,GAAG,CAAC,KAAK;gBACrC,kBAAkBF,QAAQ,GAAG;gBAC7B,8CAA8CE,QAAQ,GAAG,CACpD,sCAAsC;YAC/C,CAAC;QAED,IAAIN,UACAA,SAASE;IAEjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.js","sources":["../../../../src/extensions/ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.ts"],"sourcesContent":["import {\n AfterDeploy,\n GetAppStackOutput,\n ProjectSdkParamsService,\n UiService\n} from \"@webiny/project/abstractions/index.js\";\nimport { IBlueGreenStackOutput } from \"~/pulumi/apps/blueGreen/types.js\";\nimport chalk from \"chalk\";\n\nexport interface IEnvironment {\n name: string;\n env: string;\n variant: string | undefined;\n domains: {\n [key: string]: string;\n };\n}\n\nclass PrintDeploymentInfoAfterDeployImpl implements AfterDeploy.Interface {\n constructor(\n private ui: UiService.Interface,\n private getAppStackOutput: GetAppStackOutput.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface\n ) {}\n\n async execute(params: AfterDeploy.Params) {\n if (params.app !== \"blueGreen\") {\n return;\n }\n\n const { blue, green } = chalk;\n\n const bg = await this.getAppStackOutput.execute<IBlueGreenStackOutput>(\"blueGreen\");\n\n if (!bg) {\n this.ui.info(\n \"Blue / Green deployment info could not be printed because the Blue / Green app is not deployed.\"\n );\n return;\n }\n\n const sdkParams = this.projectSdkParamsService.get();\n\n const domains = Array.isArray(bg.domains) ? bg.domains : [];\n\n const environments = (bg.environments || []).reduce<IEnvironment[]>((items, item) => {\n const index = items.findIndex(i => i.name === item.name);\n if (index >= 0) {\n items[index].domains[item.type] = item.target;\n\n return items;\n }\n\n items.push({\n name: item.name,\n env: item.env,\n variant: item.variant,\n domains: {\n [item.type]: item.target\n }\n });\n\n return items;\n }, []);\n\n const output = [\n \"\",\n green(`Blue / Green Router`),\n `‣ Environment name: ${blue(sdkParams.env)}`,\n `‣ CloudFront domain: ${bg.distributionDomain}`,\n `‣ CloudFront URL: ${bg.distributionUrl}`,\n \"\",\n `‣ Domains attached: `,\n ...domains.map(domain => ` - https://${domain}`),\n \"\",\n `‣ Environments: `,\n ...environments.map(item => {\n const envVariant = `env: ${item.env}${\n item.variant ? ` / variant: ${item.variant}` : \"\"\n }`;\n return [\n ` - ${blue(item.name)} (${envVariant})`,\n ...Object.keys(item.domains).map(type => {\n return ` - ${type}: https://${item.domains[type]}`;\n })\n ].join(\"\\n\");\n }),\n \"\"\n ];\n console.log(output.join(\"\\n\"));\n }\n}\n\nexport const PrintDeploymentInfoAfterDeploy = AfterDeploy.createImplementation({\n implementation: PrintDeploymentInfoAfterDeployImpl,\n dependencies: [UiService, GetAppStackOutput, ProjectSdkParamsService]\n});\n"],"names":["PrintDeploymentInfoAfterDeployImpl","ui","getAppStackOutput","projectSdkParamsService","params","blue","green","chalk","bg","sdkParams","domains","Array","environments","items","item","index","i","output","domain","envVariant","Object","type","console","PrintDeploymentInfoAfterDeploy","AfterDeploy","UiService","GetAppStackOutput","ProjectSdkParamsService"],"mappings":";;AAkBA,MAAMA;IACF,YACYC,EAAuB,EACvBC,iBAA8C,EAC9CC,uBAA0D,CACpE;aAHUF,EAAE,GAAFA;aACAC,iBAAiB,GAAjBA;aACAC,uBAAuB,GAAvBA;IACT;IAEH,MAAM,QAAQC,MAA0B,EAAE;QACtC,IAAIA,AAAe,gBAAfA,OAAO,GAAG,EACV;QAGJ,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGC;QAExB,MAAMC,KAAK,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAwB;QAEvE,IAAI,CAACA,IAAI,YACL,IAAI,CAAC,EAAE,CAAC,IAAI,CACR;QAKR,MAAMC,YAAY,IAAI,CAAC,uBAAuB,CAAC,GAAG;QAElD,MAAMC,UAAUC,MAAM,OAAO,CAACH,GAAG,OAAO,IAAIA,GAAG,OAAO,GAAG,EAAE;QAE3D,MAAMI,eAAgBJ,AAAAA,CAAAA,GAAG,YAAY,IAAI,
|
|
1
|
+
{"version":3,"file":"extensions/ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.js","sources":["../../../../src/extensions/ProjectAws/BlueGreenDeployments/PrintDeploymentInfoAfterDeploy.ts"],"sourcesContent":["import {\n AfterDeploy,\n GetAppStackOutput,\n ProjectSdkParamsService,\n UiService\n} from \"@webiny/project/abstractions/index.js\";\nimport { IBlueGreenStackOutput } from \"~/pulumi/apps/blueGreen/types.js\";\nimport chalk from \"chalk\";\n\nexport interface IEnvironment {\n name: string;\n env: string;\n variant: string | undefined;\n domains: {\n [key: string]: string;\n };\n}\n\nclass PrintDeploymentInfoAfterDeployImpl implements AfterDeploy.Interface {\n constructor(\n private ui: UiService.Interface,\n private getAppStackOutput: GetAppStackOutput.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface\n ) {}\n\n async execute(params: AfterDeploy.Params) {\n if (params.app !== \"blueGreen\") {\n return;\n }\n\n const { blue, green } = chalk;\n\n const bg = await this.getAppStackOutput.execute<IBlueGreenStackOutput>(\"blueGreen\");\n\n if (!bg) {\n this.ui.info(\n \"Blue / Green deployment info could not be printed because the Blue / Green app is not deployed.\"\n );\n return;\n }\n\n const sdkParams = this.projectSdkParamsService.get();\n\n const domains = Array.isArray(bg.domains) ? bg.domains : [];\n\n const environments = (bg.environments || []).reduce<IEnvironment[]>((items, item) => {\n const index = items.findIndex(i => i.name === item.name);\n if (index >= 0) {\n items[index].domains[item.type] = item.target;\n\n return items;\n }\n\n items.push({\n name: item.name,\n env: item.env,\n variant: item.variant,\n domains: {\n [item.type]: item.target\n }\n });\n\n return items;\n }, []);\n\n const output = [\n \"\",\n green(`Blue / Green Router`),\n `‣ Environment name: ${blue(sdkParams.env)}`,\n `‣ CloudFront domain: ${bg.distributionDomain}`,\n `‣ CloudFront URL: ${bg.distributionUrl}`,\n \"\",\n `‣ Domains attached: `,\n ...domains.map(domain => ` - https://${domain}`),\n \"\",\n `‣ Environments: `,\n ...environments.map(item => {\n const envVariant = `env: ${item.env}${\n item.variant ? ` / variant: ${item.variant}` : \"\"\n }`;\n return [\n ` - ${blue(item.name)} (${envVariant})`,\n ...Object.keys(item.domains).map(type => {\n return ` - ${type}: https://${item.domains[type]}`;\n })\n ].join(\"\\n\");\n }),\n \"\"\n ];\n console.log(output.join(\"\\n\"));\n }\n}\n\nexport const PrintDeploymentInfoAfterDeploy = AfterDeploy.createImplementation({\n implementation: PrintDeploymentInfoAfterDeployImpl,\n dependencies: [UiService, GetAppStackOutput, ProjectSdkParamsService]\n});\n"],"names":["PrintDeploymentInfoAfterDeployImpl","ui","getAppStackOutput","projectSdkParamsService","params","blue","green","chalk","bg","sdkParams","domains","Array","environments","items","item","index","i","output","domain","envVariant","Object","type","console","PrintDeploymentInfoAfterDeploy","AfterDeploy","UiService","GetAppStackOutput","ProjectSdkParamsService"],"mappings":";;AAkBA,MAAMA;IACF,YACYC,EAAuB,EACvBC,iBAA8C,EAC9CC,uBAA0D,CACpE;aAHUF,EAAE,GAAFA;aACAC,iBAAiB,GAAjBA;aACAC,uBAAuB,GAAvBA;IACT;IAEH,MAAM,QAAQC,MAA0B,EAAE;QACtC,IAAIA,AAAe,gBAAfA,OAAO,GAAG,EACV;QAGJ,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGC;QAExB,MAAMC,KAAK,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAwB;QAEvE,IAAI,CAACA,IAAI,YACL,IAAI,CAAC,EAAE,CAAC,IAAI,CACR;QAKR,MAAMC,YAAY,IAAI,CAAC,uBAAuB,CAAC,GAAG;QAElD,MAAMC,UAAUC,MAAM,OAAO,CAACH,GAAG,OAAO,IAAIA,GAAG,OAAO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QAAQ,GAAG,CAACL,OAAO,IAAI,CAAC;IAC5B;AACJ;AAEO,MAAMM,iCAAiCC,YAAY,oBAAoB,CAAC;IAC3E,gBAAgBxB;IAChB,cAAc;QAACyB;QAAWC;QAAmBC;KAAwB;AACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/ProjectAws/BuildAppWorkspace.js","sources":["../../../src/extensions/ProjectAws/BuildAppWorkspace.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { replaceInPath } from \"replace-in-path\";\nimport {\n BuildAppWorkspaceService,\n GetApp,\n LoggerService\n} from \"@webiny/project/abstractions/index.js\";\nimport { getTemplatesFolderPath } from \"~/utils/index.js\";\n\nconst wait = () => new Promise(resolve => setTimeout(resolve, 10));\n\nclass BuildAppWorkspaceImpl implements BuildAppWorkspaceService.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private decoratee: BuildAppWorkspaceService.Interface\n ) {}\n\n async execute(appName: GetApp.AppName, options: BuildAppWorkspaceService.Options = {}) {\n await this.decoratee.execute(appName, options);\n\n const app = this.getApp.execute(appName);\n\n if (app.paths.workspaceFolder.existsSync()) {\n if (options.forceRebuild !== true) {\n this.logger.debug(\n { appName },\n \"App workspace already exists, skipping rebuild (project-aws).\"\n );\n return;\n }\n }\n\n this.logger.info({ appName, options }, \"Building app workspace (project-aws)...\");\n\n const templatesFolderPath = getTemplatesFolderPath();\n const appWorkspaceFolderPath = app.paths.workspaceFolder.toString();\n const appTemplateFolderPath = path.join(templatesFolderPath, \"appTemplates\", app.name);\n\n // Create app.\n fs.cpSync(appTemplateFolderPath, appWorkspaceFolderPath, { recursive: true });\n\n // Copy `public` folder into `admin` app workspace folder.\n if (appName === \"admin\") {\n const publicFolder = path.join(process.cwd(), \"public\");\n fs.cpSync(publicFolder, path.join(appWorkspaceFolderPath, \"public\"), {\n recursive: true\n });\n\n await wait();\n\n const indexTsx = app.paths.workspaceFolder.join(\"src\", \"index.tsx\").toString();\n const globalCssPath = path.join(publicFolder, \"global.css\");\n\n let globalCss = \"\";\n\n if (fs.existsSync(globalCssPath)) {\n const relativePath = path\n .relative(path.dirname(indexTsx), globalCssPath)\n .replace(/\\\\/g, \"/\");\n globalCss = `import \"${relativePath}\";`;\n } else {\n console.log(\"globalCssPath does not exist\");\n }\n\n replaceInPath(indexTsx, {\n find: \"{GLOBAL_CSS}\",\n replaceWith: globalCss\n });\n }\n\n this.logger.info(\"App workspace built successfully (project-aws).\");\n }\n}\n\nexport const BuildAppWorkspace = BuildAppWorkspaceService.createDecorator({\n decorator: BuildAppWorkspaceImpl,\n dependencies: [GetApp, LoggerService]\n});\n"],"names":["wait","Promise","resolve","setTimeout","BuildAppWorkspaceImpl","getApp","logger","decoratee","appName","options","app","templatesFolderPath","getTemplatesFolderPath","appWorkspaceFolderPath","appTemplateFolderPath","path","fs","publicFolder","process","indexTsx","globalCssPath","globalCss","relativePath","console","replaceInPath","BuildAppWorkspace","BuildAppWorkspaceService","GetApp","LoggerService"],"mappings":";;;;;AAUA,MAAMA,OAAO,IAAM,IAAIC,QAAQC,CAAAA,UAAWC,WAAWD,SAAS;AAE9D,MAAME;IACF,YACYC,MAAwB,EACxBC,MAA+B,EAC/BC,SAA6C,CACvD;aAHUF,MAAM,GAANA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,OAAuB,EAAEC,UAA4C,CAAC,CAAC,EAAE;QACnF,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACD,SAASC;QAEtC,MAAMC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACF;QAEhC,IAAIE,IAAI,KAAK,CAAC,eAAe,CAAC,UAAU,IACpC;YAAA,IAAID,AAAyB,SAAzBA,QAAQ,YAAY,EAAW,YAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;gBAAED;YAAQ,GACV;
|
|
1
|
+
{"version":3,"file":"extensions/ProjectAws/BuildAppWorkspace.js","sources":["../../../src/extensions/ProjectAws/BuildAppWorkspace.ts"],"sourcesContent":["import path from \"path\";\nimport fs from \"fs\";\nimport { replaceInPath } from \"replace-in-path\";\nimport {\n BuildAppWorkspaceService,\n GetApp,\n LoggerService\n} from \"@webiny/project/abstractions/index.js\";\nimport { getTemplatesFolderPath } from \"~/utils/index.js\";\n\nconst wait = () => new Promise(resolve => setTimeout(resolve, 10));\n\nclass BuildAppWorkspaceImpl implements BuildAppWorkspaceService.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private decoratee: BuildAppWorkspaceService.Interface\n ) {}\n\n async execute(appName: GetApp.AppName, options: BuildAppWorkspaceService.Options = {}) {\n await this.decoratee.execute(appName, options);\n\n const app = this.getApp.execute(appName);\n\n if (app.paths.workspaceFolder.existsSync()) {\n if (options.forceRebuild !== true) {\n this.logger.debug(\n { appName },\n \"App workspace already exists, skipping rebuild (project-aws).\"\n );\n return;\n }\n }\n\n this.logger.info({ appName, options }, \"Building app workspace (project-aws)...\");\n\n const templatesFolderPath = getTemplatesFolderPath();\n const appWorkspaceFolderPath = app.paths.workspaceFolder.toString();\n const appTemplateFolderPath = path.join(templatesFolderPath, \"appTemplates\", app.name);\n\n // Create app.\n fs.cpSync(appTemplateFolderPath, appWorkspaceFolderPath, { recursive: true });\n\n // Copy `public` folder into `admin` app workspace folder.\n if (appName === \"admin\") {\n const publicFolder = path.join(process.cwd(), \"public\");\n fs.cpSync(publicFolder, path.join(appWorkspaceFolderPath, \"public\"), {\n recursive: true\n });\n\n await wait();\n\n const indexTsx = app.paths.workspaceFolder.join(\"src\", \"index.tsx\").toString();\n const globalCssPath = path.join(publicFolder, \"global.css\");\n\n let globalCss = \"\";\n\n if (fs.existsSync(globalCssPath)) {\n const relativePath = path\n .relative(path.dirname(indexTsx), globalCssPath)\n .replace(/\\\\/g, \"/\");\n globalCss = `import \"${relativePath}\";`;\n } else {\n console.log(\"globalCssPath does not exist\");\n }\n\n replaceInPath(indexTsx, {\n find: \"{GLOBAL_CSS}\",\n replaceWith: globalCss\n });\n }\n\n this.logger.info(\"App workspace built successfully (project-aws).\");\n }\n}\n\nexport const BuildAppWorkspace = BuildAppWorkspaceService.createDecorator({\n decorator: BuildAppWorkspaceImpl,\n dependencies: [GetApp, LoggerService]\n});\n"],"names":["wait","Promise","resolve","setTimeout","BuildAppWorkspaceImpl","getApp","logger","decoratee","appName","options","app","templatesFolderPath","getTemplatesFolderPath","appWorkspaceFolderPath","appTemplateFolderPath","path","fs","publicFolder","process","indexTsx","globalCssPath","globalCss","relativePath","console","replaceInPath","BuildAppWorkspace","BuildAppWorkspaceService","GetApp","LoggerService"],"mappings":";;;;;AAUA,MAAMA,OAAO,IAAM,IAAIC,QAAQC,CAAAA,UAAWC,WAAWD,SAAS;AAE9D,MAAME;IACF,YACYC,MAAwB,EACxBC,MAA+B,EAC/BC,SAA6C,CACvD;aAHUF,MAAM,GAANA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QAAQC,OAAuB,EAAEC,UAA4C,CAAC,CAAC,EAAE;QACnF,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACD,SAASC;QAEtC,MAAMC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACF;QAEhC,IAAIE,IAAI,KAAK,CAAC,eAAe,CAAC,UAAU,IACpC;YAAA,IAAID,AAAyB,SAAzBA,QAAQ,YAAY,EAAW,YAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;gBAAED;YAAQ,GACV;QAGP;QAGL,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAAEA;YAASC;QAAQ,GAAG;QAEvC,MAAME,sBAAsBC;QAC5B,MAAMC,yBAAyBH,IAAI,KAAK,CAAC,eAAe,CAAC,QAAQ;QACjE,MAAMI,wBAAwBC,KAAK,IAAI,CAACJ,qBAAqB,gBAAgBD,IAAI,IAAI;QAGrFM,GAAG,MAAM,CAACF,uBAAuBD,wBAAwB;YAAE,WAAW;QAAK;QAG3E,IAAIL,AAAY,YAAZA,SAAqB;YACrB,MAAMS,eAAeF,KAAK,IAAI,CAACG,QAAQ,GAAG,IAAI;YAC9CF,GAAG,MAAM,CAACC,cAAcF,KAAK,IAAI,CAACF,wBAAwB,WAAW;gBACjE,WAAW;YACf;YAEA,MAAMb;YAEN,MAAMmB,WAAWT,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,aAAa,QAAQ;YAC5E,MAAMU,gBAAgBL,KAAK,IAAI,CAACE,cAAc;YAE9C,IAAII,YAAY;YAEhB,IAAIL,GAAG,UAAU,CAACI,gBAAgB;gBAC9B,MAAME,eAAeP,KAAAA,QACR,CAACA,KAAK,OAAO,CAACI,WAAWC,eACjC,OAAO,CAAC,OAAO;gBACpBC,YAAY,CAAC,QAAQ,EAAEC,aAAa,EAAE,CAAC;YAC3C,OACIC,QAAQ,GAAG,CAAC;YAGhBC,cAAcL,UAAU;gBACpB,MAAM;gBACN,aAAaE;YACjB;QACJ;QAEA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IACrB;AACJ;AAEO,MAAMI,oBAAoBC,yBAAyB,eAAe,CAAC;IACtE,WAAWtB;IACX,cAAc;QAACuB;QAAQC;KAAc;AACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions/ProjectAws/UploadAdminAppToS3.js","sources":["../../../src/extensions/ProjectAws/UploadAdminAppToS3.ts"],"sourcesContent":["import { AdminAfterDeploy, GetApp, UiService } from \"@webiny/project/abstractions/index.js\";\nimport fs from \"fs\";\nimport { uploadFolderToS3 } from \"~/pulumi/index.js\";\nimport { type IDefaultStackOutput } from \"~/pulumi/types.js\";\nimport { AdminStackOutputService } from \"~/abstractions/index.js\";\n\nclass UploadAdminAppToS3Impl implements AdminAfterDeploy.Interface {\n constructor(\n private ui: UiService.Interface,\n private getApp: GetApp.Interface,\n private adminStackOutputService: AdminStackOutputService.Interface\n ) {}\n\n async execute(params: AdminAfterDeploy.Params) {\n // No need to upload the app if we're doing a preview.\n if (params.preview) {\n return;\n }\n\n const ui = this.ui;\n ui.info(\"Uploading React application...\");\n\n const app = this.getApp.execute(params.app);\n\n const buildFolderPath = app.paths.workspaceFolder.join(\"build\").toString();\n if (!fs.existsSync(buildFolderPath)) {\n throw new Error(\"Cannot continue, build folder not found.\");\n }\n\n const start = new Date().getTime();\n const appOutput = await this.adminStackOutputService.execute<IDefaultStackOutput>();\n if (!appOutput) {\n throw new Error(\"Missing app stack output.\");\n }\n\n await uploadFolderToS3({\n path: buildFolderPath,\n bucket: appOutput.appStorage,\n acl: \"private\",\n cacheControl: [\n {\n pattern: /index\\.html/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /robots\\.txt/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /.*/,\n value: \"max-age=31536000\"\n }\n ],\n onFileUploadSuccess: ({ paths }) => {\n ui.success(paths.relative);\n },\n onFileUploadError: ({ paths, error }) => {\n ui.error(\"Failed to upload %s\", paths.relative);\n ui.text(error.message);\n },\n onFileUploadSkip: ({ paths }) => {\n ui.info(`Skipping %s, already exists.`, paths.relative);\n }\n });\n\n const duration = (new Date().getTime() - start) / 1000;\n\n ui.success(`React application successfully uploaded in %ss.`, duration);\n }\n}\n\nexport const UploadAdminAppToS3 = AdminAfterDeploy.createImplementation({\n implementation: UploadAdminAppToS3Impl,\n dependencies: [UiService, GetApp, AdminStackOutputService]\n});\n"],"names":["UploadAdminAppToS3Impl","ui","getApp","adminStackOutputService","params","app","buildFolderPath","fs","Error","start","Date","appOutput","uploadFolderToS3","paths","error","duration","UploadAdminAppToS3","AdminAfterDeploy","UiService","GetApp","AdminStackOutputService"],"mappings":";;;;AAMA,MAAMA;IACF,YACYC,EAAuB,EACvBC,MAAwB,EACxBC,uBAA0D,CACpE;aAHUF,EAAE,GAAFA;aACAC,MAAM,GAANA;aACAC,uBAAuB,GAAvBA;IACT;IAEH,MAAM,QAAQC,MAA+B,EAAE;QAE3C,IAAIA,OAAO,OAAO,EACd;QAGJ,MAAMH,KAAK,IAAI,CAAC,EAAE;QAClBA,GAAG,IAAI,CAAC;QAER,MAAMI,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACD,OAAO,GAAG;QAE1C,MAAME,kBAAkBD,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,QAAQ;QACxE,IAAI,CAACE,GAAG,UAAU,CAACD,kBACf,MAAM,IAAIE,MAAM;QAGpB,MAAMC,QAAQ,IAAIC,OAAO,OAAO;QAChC,MAAMC,YAAY,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO;QAC5D,IAAI,CAACA,WACD,MAAM,IAAIH,MAAM;QAGpB,MAAMI,iBAAiB;YACnB,MAAMN;YACN,QAAQK,UAAU,UAAU;YAC5B,KAAK;YACL,cAAc;gBACV;oBACI,SAAS;oBACT,OAAO;gBACX;gBACA;oBACI,SAAS;oBACT,OAAO;gBACX;gBACA;oBACI,SAAS;oBACT,OAAO;gBACX;aACH;YACD,qBAAqB,CAAC,EAAEE,KAAK,EAAE;gBAC3BZ,GAAG,OAAO,CAACY,MAAM,QAAQ;YAC7B;YACA,mBAAmB,CAAC,EAAEA,KAAK,EAAEC,KAAK,EAAE;gBAChCb,GAAG,KAAK,CAAC,uBAAuBY,MAAM,QAAQ;gBAC9CZ,GAAG,IAAI,CAACa,MAAM,OAAO;YACzB;YACA,kBAAkB,CAAC,EAAED,KAAK,EAAE;gBACxBZ,GAAG,IAAI,CAAC,gCAAgCY,MAAM,QAAQ;YAC1D;QACJ;QAEA,MAAME,WAAY,KAAIL,OAAO,OAAO,KAAKD,
|
|
1
|
+
{"version":3,"file":"extensions/ProjectAws/UploadAdminAppToS3.js","sources":["../../../src/extensions/ProjectAws/UploadAdminAppToS3.ts"],"sourcesContent":["import { AdminAfterDeploy, GetApp, UiService } from \"@webiny/project/abstractions/index.js\";\nimport fs from \"fs\";\nimport { uploadFolderToS3 } from \"~/pulumi/index.js\";\nimport { type IDefaultStackOutput } from \"~/pulumi/types.js\";\nimport { AdminStackOutputService } from \"~/abstractions/index.js\";\n\nclass UploadAdminAppToS3Impl implements AdminAfterDeploy.Interface {\n constructor(\n private ui: UiService.Interface,\n private getApp: GetApp.Interface,\n private adminStackOutputService: AdminStackOutputService.Interface\n ) {}\n\n async execute(params: AdminAfterDeploy.Params) {\n // No need to upload the app if we're doing a preview.\n if (params.preview) {\n return;\n }\n\n const ui = this.ui;\n ui.info(\"Uploading React application...\");\n\n const app = this.getApp.execute(params.app);\n\n const buildFolderPath = app.paths.workspaceFolder.join(\"build\").toString();\n if (!fs.existsSync(buildFolderPath)) {\n throw new Error(\"Cannot continue, build folder not found.\");\n }\n\n const start = new Date().getTime();\n const appOutput = await this.adminStackOutputService.execute<IDefaultStackOutput>();\n if (!appOutput) {\n throw new Error(\"Missing app stack output.\");\n }\n\n await uploadFolderToS3({\n path: buildFolderPath,\n bucket: appOutput.appStorage,\n acl: \"private\",\n cacheControl: [\n {\n pattern: /index\\.html/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /robots\\.txt/,\n value: \"no-cache, no-store, must-revalidate\"\n },\n {\n pattern: /.*/,\n value: \"max-age=31536000\"\n }\n ],\n onFileUploadSuccess: ({ paths }) => {\n ui.success(paths.relative);\n },\n onFileUploadError: ({ paths, error }) => {\n ui.error(\"Failed to upload %s\", paths.relative);\n ui.text(error.message);\n },\n onFileUploadSkip: ({ paths }) => {\n ui.info(`Skipping %s, already exists.`, paths.relative);\n }\n });\n\n const duration = (new Date().getTime() - start) / 1000;\n\n ui.success(`React application successfully uploaded in %ss.`, duration);\n }\n}\n\nexport const UploadAdminAppToS3 = AdminAfterDeploy.createImplementation({\n implementation: UploadAdminAppToS3Impl,\n dependencies: [UiService, GetApp, AdminStackOutputService]\n});\n"],"names":["UploadAdminAppToS3Impl","ui","getApp","adminStackOutputService","params","app","buildFolderPath","fs","Error","start","Date","appOutput","uploadFolderToS3","paths","error","duration","UploadAdminAppToS3","AdminAfterDeploy","UiService","GetApp","AdminStackOutputService"],"mappings":";;;;AAMA,MAAMA;IACF,YACYC,EAAuB,EACvBC,MAAwB,EACxBC,uBAA0D,CACpE;aAHUF,EAAE,GAAFA;aACAC,MAAM,GAANA;aACAC,uBAAuB,GAAvBA;IACT;IAEH,MAAM,QAAQC,MAA+B,EAAE;QAE3C,IAAIA,OAAO,OAAO,EACd;QAGJ,MAAMH,KAAK,IAAI,CAAC,EAAE;QAClBA,GAAG,IAAI,CAAC;QAER,MAAMI,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACD,OAAO,GAAG;QAE1C,MAAME,kBAAkBD,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,QAAQ;QACxE,IAAI,CAACE,GAAG,UAAU,CAACD,kBACf,MAAM,IAAIE,MAAM;QAGpB,MAAMC,QAAQ,IAAIC,OAAO,OAAO;QAChC,MAAMC,YAAY,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO;QAC5D,IAAI,CAACA,WACD,MAAM,IAAIH,MAAM;QAGpB,MAAMI,iBAAiB;YACnB,MAAMN;YACN,QAAQK,UAAU,UAAU;YAC5B,KAAK;YACL,cAAc;gBACV;oBACI,SAAS;oBACT,OAAO;gBACX;gBACA;oBACI,SAAS;oBACT,OAAO;gBACX;gBACA;oBACI,SAAS;oBACT,OAAO;gBACX;aACH;YACD,qBAAqB,CAAC,EAAEE,KAAK,EAAE;gBAC3BZ,GAAG,OAAO,CAACY,MAAM,QAAQ;YAC7B;YACA,mBAAmB,CAAC,EAAEA,KAAK,EAAEC,KAAK,EAAE;gBAChCb,GAAG,KAAK,CAAC,uBAAuBY,MAAM,QAAQ;gBAC9CZ,GAAG,IAAI,CAACa,MAAM,OAAO;YACzB;YACA,kBAAkB,CAAC,EAAED,KAAK,EAAE;gBACxBZ,GAAG,IAAI,CAAC,gCAAgCY,MAAM,QAAQ;YAC1D;QACJ;QAEA,MAAME,WAAY,KAAIL,OAAO,OAAO,KAAKD,KAAK,IAAI;QAElDR,GAAG,OAAO,CAAC,mDAAmDc;IAClE;AACJ;AAEO,MAAMC,qBAAqBC,iBAAiB,oBAAoB,CAAC;IACpE,gBAAgBjB;IAChB,cAAc;QAACkB;QAAWC;QAAQC;KAAwB;AAC9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/project-aws",
|
|
3
|
-
"version": "6.5.4
|
|
3
|
+
"version": "6.5.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@pulumi/aws": "^7.55.0",
|
|
21
|
-
"@pulumi/pulumi": "^3.
|
|
21
|
+
"@pulumi/pulumi": "^3.278.0",
|
|
22
22
|
"@pulumi/random": "4.21.6",
|
|
23
|
-
"@webiny/api-headless-cms": "6.5.4
|
|
24
|
-
"@webiny/aws-layers": "6.5.4
|
|
25
|
-
"@webiny/aws-sdk": "6.5.4
|
|
26
|
-
"@webiny/cli-core": "6.5.4
|
|
23
|
+
"@webiny/api-headless-cms": "6.5.4",
|
|
24
|
+
"@webiny/aws-layers": "6.5.4",
|
|
25
|
+
"@webiny/aws-sdk": "6.5.4",
|
|
26
|
+
"@webiny/cli-core": "6.5.4",
|
|
27
27
|
"@webiny/di": "1.1.0",
|
|
28
|
-
"@webiny/project": "6.5.4
|
|
29
|
-
"@webiny/pulumi": "6.5.4
|
|
30
|
-
"@webiny/utils": "6.5.4
|
|
28
|
+
"@webiny/project": "6.5.4",
|
|
29
|
+
"@webiny/pulumi": "6.5.4",
|
|
30
|
+
"@webiny/utils": "6.5.4",
|
|
31
31
|
"chalk": "6.0.1",
|
|
32
32
|
"email-addresses": "5.0.0",
|
|
33
33
|
"find-up": "8.0.0",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"zod": "4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/lodash": "4.17.
|
|
43
|
+
"@types/lodash": "4.17.28",
|
|
44
44
|
"@types/ncp": "2.0.8",
|
|
45
|
-
"@webiny/build-tools": "6.5.4
|
|
45
|
+
"@webiny/build-tools": "6.5.4",
|
|
46
46
|
"typescript": "7.0.2",
|
|
47
|
-
"vitest": "5.1.
|
|
47
|
+
"vitest": "5.1.2"
|
|
48
48
|
},
|
|
49
49
|
"adio": {
|
|
50
50
|
"ignoreDirs": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/ApiFileManager.js","sources":["../../../../src/pulumi/apps/api/ApiFileManager.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { getLayerArn } from \"@webiny/aws-layers\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\n\nimport { ApiGraphql } from \"~/pulumi/apps/index.js\";\n\nexport type ApiFileManager = PulumiAppModule<typeof ApiFileManager>;\n\ninterface ApiFileManagerConfig {\n env: Record<string, any>;\n}\n\nexport const ApiFileManager = createAppModule({\n name: \"ApiFileManager\",\n config(app: PulumiApp, config: ApiFileManagerConfig) {\n const graphql = app.getModule(ApiGraphql);\n\n const baseConfig = graphql.functions.graphql.config.clone();\n\n const download = app.addResource(aws.lambda.Function, {\n name: \"fm-download\",\n config: {\n ...baseConfig,\n memorySize: 1600,\n description: \"Serves previously uploaded files.\",\n layers: [getLayerArn(\"sharp\")],\n environment: {\n variables: graphql.functions.graphql.output.environment.apply(env => {\n return {\n WEBINY_FUNCTION_TYPE: \"asset-delivery\",\n ...env?.variables,\n ...config.env\n };\n })\n },\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n return {\n functions: {\n download\n }\n };\n }\n});\n"],"names":["ApiFileManager","createAppModule","app","config","graphql","ApiGraphql","baseConfig","download","aws","getLayerArn","env"],"mappings":";;;;AAaO,MAAMA,iBAAiBC,gBAAgB;IAC1C,MAAM;IACN,QAAOC,GAAc,EAAEC,MAA4B;QAC/C,MAAMC,UAAUF,IAAI,SAAS,CAACG;QAE9B,MAAMC,aAAaF,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAEzD,MAAMG,WAAWL,IAAI,WAAW,CAACM,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YAClD,MAAM;YACN,QAAQ;gBACJ,GAAGF,UAAU;gBACb,YAAY;gBACZ,aAAa;gBACb,QAAQ;oBAACG,YAAY;iBAAS;gBAC9B,aAAa;oBACT,WAAWL,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAACM,CAAAA,MACnD;4BACH,sBAAsB;4BACtB,GAAGA,KAAK,SAAS;4BACjB,GAAGP,OAAO,GAAG;wBACjB;
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/ApiFileManager.js","sources":["../../../../src/pulumi/apps/api/ApiFileManager.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { getLayerArn } from \"@webiny/aws-layers\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\n\nimport { ApiGraphql } from \"~/pulumi/apps/index.js\";\n\nexport type ApiFileManager = PulumiAppModule<typeof ApiFileManager>;\n\ninterface ApiFileManagerConfig {\n env: Record<string, any>;\n}\n\nexport const ApiFileManager = createAppModule({\n name: \"ApiFileManager\",\n config(app: PulumiApp, config: ApiFileManagerConfig) {\n const graphql = app.getModule(ApiGraphql);\n\n const baseConfig = graphql.functions.graphql.config.clone();\n\n const download = app.addResource(aws.lambda.Function, {\n name: \"fm-download\",\n config: {\n ...baseConfig,\n memorySize: 1600,\n description: \"Serves previously uploaded files.\",\n layers: [getLayerArn(\"sharp\")],\n environment: {\n variables: graphql.functions.graphql.output.environment.apply(env => {\n return {\n WEBINY_FUNCTION_TYPE: \"asset-delivery\",\n ...env?.variables,\n ...config.env\n };\n })\n },\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n return {\n functions: {\n download\n }\n };\n }\n});\n"],"names":["ApiFileManager","createAppModule","app","config","graphql","ApiGraphql","baseConfig","download","aws","getLayerArn","env"],"mappings":";;;;AAaO,MAAMA,iBAAiBC,gBAAgB;IAC1C,MAAM;IACN,QAAOC,GAAc,EAAEC,MAA4B;QAC/C,MAAMC,UAAUF,IAAI,SAAS,CAACG;QAE9B,MAAMC,aAAaF,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAEzD,MAAMG,WAAWL,IAAI,WAAW,CAACM,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YAClD,MAAM;YACN,QAAQ;gBACJ,GAAGF,UAAU;gBACb,YAAY;gBACZ,aAAa;gBACb,QAAQ;oBAACG,YAAY;iBAAS;gBAC9B,aAAa;oBACT,WAAWL,QAAQ,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAACM,CAAAA,MACnD;4BACH,sBAAsB;4BACtB,GAAGA,KAAK,SAAS;4BACjB,GAAGP,OAAO,GAAG;wBACjB,CAAC;gBAET;gBACA,eAAe;oBACX,WAAW;gBACf;YACJ;QACJ;QAEA,OAAO;YACH,WAAW;gBACPI;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/ApiGraphql.js","sources":["../../../../src/pulumi/apps/api/ApiGraphql.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport toKebabCase from \"lodash/kebabCase.js\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils.js\";\nimport { CoreOutput, VpcConfig } from \"~/pulumi/apps/index.js\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils.js\";\nimport { LAMBDA_RUNTIME } from \"~/pulumi/constants.js\";\n\ninterface GraphqlParams {\n env: Record<string, any>;\n}\n\nexport interface AddRouteParams {\n /**\n * Must be in kebab case (a-z and -)\n */\n name: string;\n path: `/${string}`;\n method: \"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\" | \"OPTIONS\" | \"ANY\";\n}\n\nconst EMPTY_TRASH_BIN_EVENT_RULE_NAME = `empty-trash-bin-event-rule`;\nconst EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME = `empty-trash-bin-event-target-permission`;\nconst EMPTY_TRASH_BIN_EVENT_RULE_TARGET = `empty-trash-bin-event-rule-target`;\n\nexport type ApiGraphql = PulumiAppModule<typeof ApiGraphql>;\n\nexport const ApiGraphql = createAppModule({\n name: \"ApiGraphql\",\n config(app: PulumiApp, params: GraphqlParams) {\n const policy = createGraphqlLambdaPolicy(app);\n const role = createLambdaRole(app, {\n name: \"api-lambda-role\",\n policy: policy.output\n });\n\n const graphql = app.addResource(aws.lambda.Function, {\n name: \"graphql\",\n config: {\n description: \"Webiny's GraphQL APIs\",\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n role: role.output.arn,\n timeout: 30,\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 // Create event rule.\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_NAME,\n config: {\n description: \"Enable us to empty the trash-bin ever day\",\n scheduleExpression: \"cron(0 3 * * ? *)\"\n }\n });\n\n // Add required permission to the target lambda.\n app.addResource(aws.lambda.Permission, {\n name: EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME,\n config: {\n action: \"lambda:InvokeFunction\",\n function: graphql.output.arn,\n principal: \"events.amazonaws.com\",\n statementId: \"allow-rule-invoke-\" + EMPTY_TRASH_BIN_EVENT_RULE_NAME\n }\n });\n\n // Target the main graphql lambda.\n app.addResource(aws.cloudwatch.EventTarget, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_TARGET,\n config: {\n rule: eventRule.output.name,\n arn: graphql.output.arn,\n input: JSON.stringify({\n source: \"webiny.events\",\n \"detail-type\": \"WebinyEmptyTrashBin\"\n })\n }\n });\n\n return {\n role,\n policy,\n functions: {\n graphql\n },\n addRoute: (routeParams: AddRouteParams) => {\n const apiGateway: any = app.resources.apiGateway;\n if (!apiGateway) {\n console.log(\n \"Could not add route because there is no apiGateway in the resources.\"\n );\n return;\n }\n const kebabName = toKebabCase(routeParams.name);\n if (kebabName !== routeParams.name) {\n console.log(`Route name is not allowed: \"${routeParams.name}\".`);\n return;\n }\n return apiGateway.addRoute(routeParams.name, {\n path: routeParams.path,\n method: routeParams.method,\n function: graphql.output.arn\n });\n }\n };\n }\n});\n\nfunction createGraphqlLambdaPolicy(app: PulumiApp) {\n const coreOutput = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ApiGraphqlLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb, S3, Lambda and Cognito IDP\",\n // Core is pulumi.Output, so we need to run apply() to resolve policy based on it\n policy: pulumi.all([coreOutput]).apply(([core]) => {\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:ConditionCheckItem\",\n \"dynamodb:CreateBackup\",\n \"dynamodb:CreateTable\",\n \"dynamodb:CreateTableReplica\",\n \"dynamodb:DeleteBackup\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DeleteTableReplica\",\n \"dynamodb:DescribeBackup\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeContributorInsights\",\n \"dynamodb:DescribeExport\",\n \"dynamodb:DescribeKinesisStreamingDestination\",\n \"dynamodb:DescribeLimits\",\n \"dynamodb:DescribeReservedCapacity\",\n \"dynamodb:DescribeReservedCapacityOfferings\",\n \"dynamodb:DescribeStream\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTableReplicaAutoScaling\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:DisableKinesisStreamingDestination\",\n \"dynamodb:EnableKinesisStreamingDestination\",\n \"dynamodb:ExportTableToPointInTime\",\n \"dynamodb:GetItem\",\n \"dynamodb:GetRecords\",\n \"dynamodb:GetShardIterator\",\n \"dynamodb:ListBackups\",\n \"dynamodb:ListContributorInsights\",\n \"dynamodb:ListExports\",\n \"dynamodb:ListStreams\",\n \"dynamodb:ListTables\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:PartiQLDelete\",\n \"dynamodb:PartiQLInsert\",\n \"dynamodb:PartiQLSelect\",\n \"dynamodb:PartiQLUpdate\",\n \"dynamodb:PurchaseReservedCapacityOfferings\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:RestoreTableFromBackup\",\n \"dynamodb:RestoreTableToPointInTime\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateContinuousBackups\",\n \"dynamodb:UpdateContributorInsights\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTableReplicaAutoScaling\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n Resource: [\n `${core.primaryDynamodbTableArn}`,\n `${core.primaryDynamodbTableArn}/*`,\n `${core.auditLogsDynamodbTableArn}`,\n `${core.auditLogsDynamodbTableArn}/*`,\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n ...(core.opensearchDynamodbTableArn\n ? [\n `${core.opensearchDynamodbTableArn}`,\n `${core.opensearchDynamodbTableArn}/*`\n ]\n : [])\n ]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:ListBucket\",\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}/*`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n },\n {\n Sid: \"PermissionForCognitoIdp\",\n Effect: \"Allow\",\n Action: \"cognito-idp:*\",\n Resource: `${core.cognitoUserPoolArn}`\n },\n {\n Sid: \"PermissionForEventBus\",\n Effect: \"Allow\",\n Action: \"events:PutEvents\",\n Resource: core.eventBusArn\n },\n {\n Sid: \"PermissionForCloudfront\",\n Effect: \"Allow\",\n Action: \"cloudfront:CreateInvalidation\",\n Resource: pulumi.interpolate`arn:aws:cloudfront::${awsAccountId}:distribution/*`\n },\n // Attach permissions for elastic search domain as well (if ES is enabled).\n ...(core.opensearchDomainArn\n ? [\n {\n Sid: \"PermissionForOS\",\n Effect: \"Allow\" as const,\n Action: \"es:*\",\n Resource: [\n `${core.opensearchDomainArn}`,\n `${core.opensearchDomainArn}/*`\n ]\n }\n ]\n : [])\n ]\n };\n\n return policy;\n })\n }\n });\n}\n"],"names":["EMPTY_TRASH_BIN_EVENT_RULE_NAME","EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME","EMPTY_TRASH_BIN_EVENT_RULE_TARGET","ApiGraphql","createAppModule","app","params","policy","createGraphqlLambdaPolicy","role","createLambdaRole","graphql","aws","LAMBDA_RUNTIME","pulumi","path","getCommonLambdaEnvVariables","value","VpcConfig","eventRule","JSON","routeParams","apiGateway","console","kebabName","toKebabCase","coreOutput","CoreOutput","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","core"],"mappings":";;;;;;;;;AAwBA,MAAMA,kCAAkC;AACxC,MAAMC,wCAAwC;AAC9C,MAAMC,oCAAoC;AAInC,MAAMC,aAAaC,gBAAgB;IACtC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAAqB;QACxC,MAAMC,SAASC,0BAA0BH;QACzC,MAAMI,OAAOC,iBAAiBL,KAAK;YAC/B,MAAM;YACN,QAAQE,OAAO,MAAM;QACzB;QAEA,MAAMI,UAAUN,IAAI,WAAW,CAACO,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YACjD,MAAM;YACN,QAAQ;gBACJ,aAAa;gBACb,SAASC;gBACT,SAAS;gBACT,MAAMJ,KAAK,MAAM,CAAC,GAAG;gBACrB,SAAS;gBACT,YAAY;gBACZ,MAAM,IAAIK,0CAAAA,KAAAA,CAAAA,YAAyB,CAAC;oBAChC,KAAK,IAAIA,0CAAAA,KAAAA,CAAAA,WAAwB,CAC7BC,KAAK,IAAI,CAACV,IAAI,KAAK,CAAC,SAAS,EAAE;gBAEvC;gBACA,aAAa;oBACT,WAAWW,8BAA8B,KAAK,CAACC,CAAAA,QAAU;4BACrD,GAAGA,KAAK;4BACR,GAAGX,OAAO,GAAG;4BACb,qCAAqC;wBACzC;gBACJ;gBACA,WAAWD,IAAI,SAAS,CAACa,WAAW,iBAAiB;gBACrD,eAAe;oBACX,WAAW;gBACf;YACJ;QACJ;QAGA,MAAMC,YAAYd,IAAI,WAAW,CAACO,uCAAAA,UAAAA,CAAAA,SAAwB,EAAE;YACxD,MAAMZ;YACN,QAAQ;gBACJ,aAAa;gBACb,oBAAoB;YACxB;QACJ;QAGAK,IA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E;wBAC1C;wBACA;4BACI,KAAK;4BACL,QAAQ;4BACR,QAAQ;4BACR,UAAUA,KAAK,WAAW;wBAC9B;wBACA;4BACI,KAAK;4BACL,QAAQ;4BACR,QAAQ;4BACR,UAAUlB,0CAAAA,WAAkB,CAAC,oBAAoB,EAAEc,aAAa,eAAe,CAAC;wBACpF;2BAEII,KAAK,mBAAmB,GACtB;4BACI;gCACI,KAAK;gCACL,QAAQ;gCACR,QAAQ;gCACR,UAAU;oCACN,GAAGA,KAAK,mBAAmB,EAAE;oCAC7B,GAAGA,KAAK,mBAAmB,CAAC,EAAE,CAAC;iCAClC;4BACL;yBACH,GACD,EAAE;qBACX;gBACL;gBAEA,OAAOzB;YACX;QACJ;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/ApiGraphql.js","sources":["../../../../src/pulumi/apps/api/ApiGraphql.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport toKebabCase from \"lodash/kebabCase.js\";\nimport type { PulumiApp, PulumiAppModule } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils.js\";\nimport { CoreOutput, VpcConfig } from \"~/pulumi/apps/index.js\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils.js\";\nimport { LAMBDA_RUNTIME } from \"~/pulumi/constants.js\";\n\ninterface GraphqlParams {\n env: Record<string, any>;\n}\n\nexport interface AddRouteParams {\n /**\n * Must be in kebab case (a-z and -)\n */\n name: string;\n path: `/${string}`;\n method: \"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\" | \"OPTIONS\" | \"ANY\";\n}\n\nconst EMPTY_TRASH_BIN_EVENT_RULE_NAME = `empty-trash-bin-event-rule`;\nconst EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME = `empty-trash-bin-event-target-permission`;\nconst EMPTY_TRASH_BIN_EVENT_RULE_TARGET = `empty-trash-bin-event-rule-target`;\n\nexport type ApiGraphql = PulumiAppModule<typeof ApiGraphql>;\n\nexport const ApiGraphql = createAppModule({\n name: \"ApiGraphql\",\n config(app: PulumiApp, params: GraphqlParams) {\n const policy = createGraphqlLambdaPolicy(app);\n const role = createLambdaRole(app, {\n name: \"api-lambda-role\",\n policy: policy.output\n });\n\n const graphql = app.addResource(aws.lambda.Function, {\n name: \"graphql\",\n config: {\n description: \"Webiny's GraphQL APIs\",\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n role: role.output.arn,\n timeout: 30,\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 // Create event rule.\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_NAME,\n config: {\n description: \"Enable us to empty the trash-bin ever day\",\n scheduleExpression: \"cron(0 3 * * ? *)\"\n }\n });\n\n // Add required permission to the target lambda.\n app.addResource(aws.lambda.Permission, {\n name: EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME,\n config: {\n action: \"lambda:InvokeFunction\",\n function: graphql.output.arn,\n principal: \"events.amazonaws.com\",\n statementId: \"allow-rule-invoke-\" + EMPTY_TRASH_BIN_EVENT_RULE_NAME\n }\n });\n\n // Target the main graphql lambda.\n app.addResource(aws.cloudwatch.EventTarget, {\n name: EMPTY_TRASH_BIN_EVENT_RULE_TARGET,\n config: {\n rule: eventRule.output.name,\n arn: graphql.output.arn,\n input: JSON.stringify({\n source: \"webiny.events\",\n \"detail-type\": \"WebinyEmptyTrashBin\"\n })\n }\n });\n\n return {\n role,\n policy,\n functions: {\n graphql\n },\n addRoute: (routeParams: AddRouteParams) => {\n const apiGateway: any = app.resources.apiGateway;\n if (!apiGateway) {\n console.log(\n \"Could not add route because there is no apiGateway in the resources.\"\n );\n return;\n }\n const kebabName = toKebabCase(routeParams.name);\n if (kebabName !== routeParams.name) {\n console.log(`Route name is not allowed: \"${routeParams.name}\".`);\n return;\n }\n return apiGateway.addRoute(routeParams.name, {\n path: routeParams.path,\n method: routeParams.method,\n function: graphql.output.arn\n });\n }\n };\n }\n});\n\nfunction createGraphqlLambdaPolicy(app: PulumiApp) {\n const coreOutput = app.getModule(CoreOutput);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n return app.addResource(aws.iam.Policy, {\n name: \"ApiGraphqlLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb, S3, Lambda and Cognito IDP\",\n // Core is pulumi.Output, so we need to run apply() to resolve policy based on it\n policy: pulumi.all([coreOutput]).apply(([core]) => {\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:ConditionCheckItem\",\n \"dynamodb:CreateBackup\",\n \"dynamodb:CreateTable\",\n \"dynamodb:CreateTableReplica\",\n \"dynamodb:DeleteBackup\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DeleteTableReplica\",\n \"dynamodb:DescribeBackup\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeContributorInsights\",\n \"dynamodb:DescribeExport\",\n \"dynamodb:DescribeKinesisStreamingDestination\",\n \"dynamodb:DescribeLimits\",\n \"dynamodb:DescribeReservedCapacity\",\n \"dynamodb:DescribeReservedCapacityOfferings\",\n \"dynamodb:DescribeStream\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTableReplicaAutoScaling\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:DisableKinesisStreamingDestination\",\n \"dynamodb:EnableKinesisStreamingDestination\",\n \"dynamodb:ExportTableToPointInTime\",\n \"dynamodb:GetItem\",\n \"dynamodb:GetRecords\",\n \"dynamodb:GetShardIterator\",\n \"dynamodb:ListBackups\",\n \"dynamodb:ListContributorInsights\",\n \"dynamodb:ListExports\",\n \"dynamodb:ListStreams\",\n \"dynamodb:ListTables\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:PartiQLDelete\",\n \"dynamodb:PartiQLInsert\",\n \"dynamodb:PartiQLSelect\",\n \"dynamodb:PartiQLUpdate\",\n \"dynamodb:PurchaseReservedCapacityOfferings\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:RestoreTableFromBackup\",\n \"dynamodb:RestoreTableToPointInTime\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateContinuousBackups\",\n \"dynamodb:UpdateContributorInsights\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTableReplicaAutoScaling\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n Resource: [\n `${core.primaryDynamodbTableArn}`,\n `${core.primaryDynamodbTableArn}/*`,\n `${core.auditLogsDynamodbTableArn}`,\n `${core.auditLogsDynamodbTableArn}/*`,\n // Attach permissions for elastic search dynamo as well (if ES is enabled).\n ...(core.opensearchDynamodbTableArn\n ? [\n `${core.opensearchDynamodbTableArn}`,\n `${core.opensearchDynamodbTableArn}/*`\n ]\n : [])\n ]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:ListBucket\",\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${core.fileManagerBucketId}/*`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n },\n {\n Sid: \"PermissionForCognitoIdp\",\n Effect: \"Allow\",\n Action: \"cognito-idp:*\",\n Resource: `${core.cognitoUserPoolArn}`\n },\n {\n Sid: \"PermissionForEventBus\",\n Effect: \"Allow\",\n Action: \"events:PutEvents\",\n Resource: core.eventBusArn\n },\n {\n Sid: \"PermissionForCloudfront\",\n Effect: \"Allow\",\n Action: \"cloudfront:CreateInvalidation\",\n Resource: pulumi.interpolate`arn:aws:cloudfront::${awsAccountId}:distribution/*`\n },\n // Attach permissions for elastic search domain as well (if ES is enabled).\n ...(core.opensearchDomainArn\n ? [\n {\n Sid: \"PermissionForOS\",\n Effect: \"Allow\" as const,\n Action: \"es:*\",\n Resource: [\n `${core.opensearchDomainArn}`,\n `${core.opensearchDomainArn}/*`\n ]\n }\n ]\n : [])\n ]\n };\n\n return policy;\n })\n }\n });\n}\n"],"names":["EMPTY_TRASH_BIN_EVENT_RULE_NAME","EMPTY_TRASH_BIN_EVENT_PERMISSION_NAME","EMPTY_TRASH_BIN_EVENT_RULE_TARGET","ApiGraphql","createAppModule","app","params","policy","createGraphqlLambdaPolicy","role","createLambdaRole","graphql","aws","LAMBDA_RUNTIME","pulumi","path","getCommonLambdaEnvVariables","value","VpcConfig","eventRule","JSON","routeParams","apiGateway","console","kebabName","toKebabCase","coreOutput","CoreOutput","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion","core"],"mappings":";;;;;;;;;AAwBA,MAAMA,kCAAkC;AACxC,MAAMC,wCAAwC;AAC9C,MAAMC,oCAAoC;AAInC,MAAMC,aAAaC,gBAAgB;IACtC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAAqB;QACxC,MAAMC,SAASC,0BAA0BH;QACzC,MAAMI,OAAOC,i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,OAAOzB;YACX;QACJ;IACJ;AACJ"}
|
|
@@ -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 { getProjectSdk } from \"@webiny/project\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { isVpcEnabled } from \"~/pulumi/apps/extensions/isVpcEnabled.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 getProjectSdk();\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 app.addModule(VpcConfig, {\n enabled: isVpcEnabled(vpcExtensionsConfig, isProduction)\n });\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, 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 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","getProjectSdk","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","VpcConfig","isVpcEnabled","graphql","ApiGraphql","getEnvVariableAwsRegion","websocket","ApiWebsocket","fileManager","ApiFileManager","apiGateway","ApiGateway","cloudfront","ApiCloudfront","backgroundTask","ApiBackgroundTask","scheduler","ApiScheduler","apiCustomDomains","apiCustomDomainsExt","domains","sslMethod","certificateArn","minimumProtocolVersion","applyCustomDomain","getAwsAccountId","addDomainsUrlsOutputs","applyAwsResourceTags","withServiceManifest","withCommonLambdaEnvVariables","v"],"mappings":";;;;;;;;;;;;;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C,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 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 { getProjectSdk } from \"@webiny/project\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { isVpcEnabled } from \"~/pulumi/apps/extensions/isVpcEnabled.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 getProjectSdk();\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 app.addModule(VpcConfig, {\n enabled: isVpcEnabled(vpcExtensionsConfig, isProduction)\n });\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, 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 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","getProjectSdk","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","VpcConfig","isVpcEnabled","graphql","ApiGraphql","getEnvVariableAwsRegion","websocket","ApiWebsocket","fileManager","ApiFileManager","apiGateway","ApiGateway","cloudfront","ApiCloudfront","backgroundTask","ApiBackgroundTask","scheduler","ApiScheduler","apiCustomDomains","apiCustomDomainsExt","domains","sslMethod","certificateArn","minimum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AEA,GAAG;gBAE3B;YACJ;QACJ;QAEA5D,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/api/handleGuardDutyEvents.js","sources":["../../../../src/pulumi/apps/api/handleGuardDutyEvents.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { type ApiPulumiApp, CoreOutput } from \"~/pulumi/index.js\";\n\nexport const handleGuardDutyEvents = (app: ApiPulumiApp) => {\n const core = app.getModule(CoreOutput);\n const graphql = app.resources.graphql.functions.graphql;\n\n const baseConfig = graphql.config.clone();\n\n const threatDetectionHandler = app.addResource(aws.lambda.Function, {\n name: \"fm-threat-detection\",\n config: {\n ...baseConfig,\n memorySize: 1024,\n description: \"Handles Guard Duty threat scan results.\",\n environment: {\n variables: graphql.output.environment.apply(env => {\n return {\n WEBINY_FUNCTION_TYPE: \"threat-detection-event-handler\",\n ...env?.variables\n };\n })\n },\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: `fm-bucket-malware-protection-event-rule`,\n config: {\n eventBusName: core.eventBusName,\n eventPattern: JSON.stringify({\n source: [\"aws.guardduty\"],\n \"detail-type\": [\"GuardDuty Malware Protection Object Scan Result\"]\n })\n }\n });\n\n app.addResource(aws.lambda.Permission, {\n name: \"fm-bucket-malware-protection-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: threatDetectionHandler.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n app.addResource(aws.cloudwatch.EventTarget, {\n name: `fm-bucket-malware-protection-event-target`,\n config: {\n rule: eventRule.output.name,\n arn: threatDetectionHandler.output.arn,\n eventBusName: core.eventBusName\n }\n });\n};\n"],"names":["handleGuardDutyEvents","app","core","CoreOutput","graphql","baseConfig","threatDetectionHandler","aws","env","eventRule","JSON"],"mappings":";;AAGO,MAAMA,wBAAwB,CAACC;IAClC,MAAMC,OAAOD,IAAI,SAAS,CAACE;IAC3B,MAAMC,UAAUH,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO;IAEvD,MAAMI,aAAaD,QAAQ,MAAM,CAAC,KAAK;IAEvC,MAAME,yBAAyBL,IAAI,WAAW,CAACM,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;QAChE,MAAM;QACN,QAAQ;YACJ,GAAGF,UAAU;YACb,YAAY;YACZ,aAAa;YACb,aAAa;gBACT,WAAWD,QAAQ,MAAM,CAAC,WAAW,CAAC,KAAK,CAACI,CAAAA,MACjC;wBACH,sBAAsB;wBACtB,GAAGA,KAAK,SAAS;oBACrB;
|
|
1
|
+
{"version":3,"file":"pulumi/apps/api/handleGuardDutyEvents.js","sources":["../../../../src/pulumi/apps/api/handleGuardDutyEvents.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { type ApiPulumiApp, CoreOutput } from \"~/pulumi/index.js\";\n\nexport const handleGuardDutyEvents = (app: ApiPulumiApp) => {\n const core = app.getModule(CoreOutput);\n const graphql = app.resources.graphql.functions.graphql;\n\n const baseConfig = graphql.config.clone();\n\n const threatDetectionHandler = app.addResource(aws.lambda.Function, {\n name: \"fm-threat-detection\",\n config: {\n ...baseConfig,\n memorySize: 1024,\n description: \"Handles Guard Duty threat scan results.\",\n environment: {\n variables: graphql.output.environment.apply(env => {\n return {\n WEBINY_FUNCTION_TYPE: \"threat-detection-event-handler\",\n ...env?.variables\n };\n })\n },\n loggingConfig: {\n logFormat: \"JSON\"\n }\n }\n });\n\n const eventRule = app.addResource(aws.cloudwatch.EventRule, {\n name: `fm-bucket-malware-protection-event-rule`,\n config: {\n eventBusName: core.eventBusName,\n eventPattern: JSON.stringify({\n source: [\"aws.guardduty\"],\n \"detail-type\": [\"GuardDuty Malware Protection Object Scan Result\"]\n })\n }\n });\n\n app.addResource(aws.lambda.Permission, {\n name: \"fm-bucket-malware-protection-event-permission\",\n config: {\n action: \"lambda:InvokeFunction\",\n function: threatDetectionHandler.output.arn,\n principal: \"events.amazonaws.com\",\n sourceArn: eventRule.output.arn\n }\n });\n\n app.addResource(aws.cloudwatch.EventTarget, {\n name: `fm-bucket-malware-protection-event-target`,\n config: {\n rule: eventRule.output.name,\n arn: threatDetectionHandler.output.arn,\n eventBusName: core.eventBusName\n }\n });\n};\n"],"names":["handleGuardDutyEvents","app","core","CoreOutput","graphql","baseConfig","threatDetectionHandler","aws","env","eventRule","JSON"],"mappings":";;AAGO,MAAMA,wBAAwB,CAACC;IAClC,MAAMC,OAAOD,IAAI,SAAS,CAACE;IAC3B,MAAMC,UAAUH,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO;IAEvD,MAAMI,aAAaD,QAAQ,MAAM,CAAC,KAAK;IAEvC,MAAME,yBAAyBL,IAAI,WAAW,CAACM,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;QAChE,MAAM;QACN,QAAQ;YACJ,GAAGF,UAAU;YACb,YAAY;YACZ,aAAa;YACb,aAAa;gBACT,WAAWD,QAAQ,MAAM,CAAC,WAAW,CAAC,KAAK,CAACI,CAAAA,MACjC;wBACH,sBAAsB;wBACtB,GAAGA,KAAK,SAAS;oBACrB,CAAC;YAET;YACA,eAAe;gBACX,WAAW;YACf;QACJ;IACJ;IAEA,MAAMC,YAAYR,IAAI,WAAW,CAACM,uCAAAA,UAAAA,CAAAA,SAAwB,EAAE;QACxD,MAAM;QACN,QAAQ;YACJ,cAAcL,KAAK,YAAY;YAC/B,cAAcQ,KAAK,SAAS,CAAC;gBACzB,QAAQ;oBAAC;iBAAgB;gBACzB,eAAe;oBAAC;iBAAkD;YACtE;QACJ;IACJ;IAEAT,IAAI,WAAW,CAACM,uCAAAA,MAAAA,CAAAA,UAAqB,EAAE;QACnC,MAAM;QACN,QAAQ;YACJ,QAAQ;YACR,UAAUD,uBAAuB,MAAM,CAAC,GAAG;YAC3C,WAAW;YACX,WAAWG,UAAU,MAAM,CAAC,GAAG;QACnC;IACJ;IAEAR,IAAI,WAAW,CAACM,uCAAAA,UAAAA,CAAAA,WAA0B,EAAE;QACxC,MAAM;QACN,QAAQ;YACJ,MAAME,UAAU,MAAM,CAAC,IAAI;YAC3B,KAAKH,uBAAuB,MAAM,CAAC,GAAG;YACtC,cAAcJ,KAAK,YAAY;QACnC;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/blueGreen/validation/validateDeployments.js","sources":["../../../../../src/pulumi/apps/blueGreen/validation/validateDeployments.ts"],"sourcesContent":["import zod from \"zod\";\nimport { createZodError } from \"@webiny/utils/createZodError.js\";\nimport type { IBlueGreenDeployment } from \"../types.js\";\n\nconst schema = zod\n .array(\n zod.object({\n name: zod.string(),\n env: zod.string(),\n variant: zod.string().optional()\n })\n )\n .min(2)\n .max(2)\n .refine(\n items => {\n const check = new Set(items.map(i => i.name));\n return check.size === items.length;\n },\n {\n message: \"Names must be unique.\"\n }\n )\n .refine(\n items => {\n const checks = new Set(\n items.map(item => {\n return `${item.env}#${item.variant || \"not-set\"}`;\n })\n );\n return checks.size === items.length;\n },\n {\n message: \"Environment / variant combinations must be unique.\"\n }\n );\n\nexport const validateDeployments = (deployments: unknown): IBlueGreenDeployment[] => {\n const result = schema.safeParse(deployments);\n if (result.error) {\n throw createZodError(result.error);\n }\n return result.data.map(item => {\n return {\n ...item,\n variant: item.variant\n };\n });\n};\n"],"names":["schema","zod","items","check","Set","i","checks","item","validateDeployments","deployments","result","createZodError"],"mappings":";;AAIA,MAAMA,SAASC,IAAAA,KACL,CACFA,IAAI,MAAM,CAAC;IACP,MAAMA,IAAI,MAAM;IAChB,KAAKA,IAAI,MAAM;IACf,SAASA,IAAI,MAAM,GAAG,QAAQ;AAClC,IAEH,GAAG,CAAC,GACJ,GAAG,CAAC,GACJ,MAAM,CACHC,CAAAA;IACI,MAAMC,QAAQ,IAAIC,IAAIF,MAAM,GAAG,CAACG,CAAAA,IAAKA,EAAE,IAAI;IAC3C,OAAOF,MAAM,IAAI,KAAKD,MAAM,MAAM;AACtC,GACA;IACI,SAAS;AACb,GAEH,MAAM,CACHA,CAAAA;IACI,MAAMI,SAAS,IAAIF,IACfF,MAAM,GAAG,CAACK,CAAAA,OACC,GAAGA,KAAK,GAAG,CAAC,CAAC,EAAEA,KAAK,OAAO,IAAI,WAAW;IAGzD,OAAOD,OAAO,IAAI,KAAKJ,MAAM,MAAM;AACvC,GACA;IACI,SAAS;AACb;AAGD,MAAMM,sBAAsB,CAACC;IAChC,MAAMC,SAASV,OAAO,SAAS,CAACS;IAChC,IAAIC,OAAO,KAAK,EACZ,MAAMC,eAAeD,OAAO,KAAK;IAErC,OAAOA,OAAO,IAAI,CAAC,GAAG,CAACH,CAAAA,OACZ;YACH,GAAGA,IAAI;YACP,SAASA,KAAK,OAAO;QACzB;
|
|
1
|
+
{"version":3,"file":"pulumi/apps/blueGreen/validation/validateDeployments.js","sources":["../../../../../src/pulumi/apps/blueGreen/validation/validateDeployments.ts"],"sourcesContent":["import zod from \"zod\";\nimport { createZodError } from \"@webiny/utils/createZodError.js\";\nimport type { IBlueGreenDeployment } from \"../types.js\";\n\nconst schema = zod\n .array(\n zod.object({\n name: zod.string(),\n env: zod.string(),\n variant: zod.string().optional()\n })\n )\n .min(2)\n .max(2)\n .refine(\n items => {\n const check = new Set(items.map(i => i.name));\n return check.size === items.length;\n },\n {\n message: \"Names must be unique.\"\n }\n )\n .refine(\n items => {\n const checks = new Set(\n items.map(item => {\n return `${item.env}#${item.variant || \"not-set\"}`;\n })\n );\n return checks.size === items.length;\n },\n {\n message: \"Environment / variant combinations must be unique.\"\n }\n );\n\nexport const validateDeployments = (deployments: unknown): IBlueGreenDeployment[] => {\n const result = schema.safeParse(deployments);\n if (result.error) {\n throw createZodError(result.error);\n }\n return result.data.map(item => {\n return {\n ...item,\n variant: item.variant\n };\n });\n};\n"],"names":["schema","zod","items","check","Set","i","checks","item","validateDeployments","deployments","result","createZodError"],"mappings":";;AAIA,MAAMA,SAASC,IAAAA,KACL,CACFA,IAAI,MAAM,CAAC;IACP,MAAMA,IAAI,MAAM;IAChB,KAAKA,IAAI,MAAM;IACf,SAASA,IAAI,MAAM,GAAG,QAAQ;AAClC,IAEH,GAAG,CAAC,GACJ,GAAG,CAAC,GACJ,MAAM,CACHC,CAAAA;IACI,MAAMC,QAAQ,IAAIC,IAAIF,MAAM,GAAG,CAACG,CAAAA,IAAKA,EAAE,IAAI;IAC3C,OAAOF,MAAM,IAAI,KAAKD,MAAM,MAAM;AACtC,GACA;IACI,SAAS;AACb,GAEH,MAAM,CACHA,CAAAA;IACI,MAAMI,SAAS,IAAIF,IACfF,MAAM,GAAG,CAACK,CAAAA,OACC,GAAGA,KAAK,GAAG,CAAC,CAAC,EAAEA,KAAK,OAAO,IAAI,WAAW;IAGzD,OAAOD,OAAO,IAAI,KAAKJ,MAAM,MAAM;AACvC,GACA;IACI,SAAS;AACb;AAGD,MAAMM,sBAAsB,CAACC;IAChC,MAAMC,SAASV,OAAO,SAAS,CAACS;IAChC,IAAIC,OAAO,KAAK,EACZ,MAAMC,eAAeD,OAAO,KAAK;IAErC,OAAOA,OAAO,IAAI,CAAC,GAAG,CAACH,CAAAA,OACZ;YACH,GAAGA,IAAI;YACP,SAASA,KAAK,OAAO;QACzB,CAAC;AAET"}
|
|
@@ -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 * as pulumi from \"@pulumi/pulumi\";\nimport { createAppModule, type PulumiApp, type PulumiAppModule } from \"@webiny/pulumi\";\n\nexport interface CoreCognitoParams {\n protect: boolean;\n useEmailAsUsername: boolean;\n mfa?: boolean;\n}\n\nexport type CoreCognito = PulumiAppModule<typeof CoreCognito>;\n\n/**\n * Standard attributes users may change themselves (with their own access token). The\n * `*_verified` flags are left out, so users can't mark an address they don't own as verified.\n */\nconst STANDARD_USER_WRITABLE_ATTRIBUTES = [\n \"address\",\n \"birthdate\",\n \"email\",\n \"family_name\",\n \"gender\",\n \"given_name\",\n \"locale\",\n \"middle_name\",\n \"name\",\n \"nickname\",\n \"phone_number\",\n \"picture\",\n \"preferred_username\",\n \"profile\",\n \"updated_at\",\n \"website\",\n \"zoneinfo\"\n];\n\n/**\n * Attributes that users must never change themselves. `custom:id` is the Webiny identity id:\n * a user who could write it would sign in as any other user. Webiny sets it with Cognito admin\n * APIs, which `writeAttributes` doesn't restrict.\n */\nexport const USER_PROTECTED_ATTRIBUTES = [\"custom:id\"];\n\n/**\n * Everything users could write before (all standard and all custom attributes of the pool,\n * including custom attributes a project adds to the schema), except the protected ones.\n * Cognito has no deny list for app clients, so the allowed list is built from the pool schema.\n */\nexport const getUserWritableAttributes = (\n schemas: pulumi.Input<aws.types.input.cognito.UserPoolSchema[] | undefined>\n): pulumi.Output<string[]> => {\n return pulumi.output(schemas).apply(items => {\n const custom = (items || [])\n .map(schema => schema.name)\n .filter(name => !STANDARD_USER_WRITABLE_ATTRIBUTES.includes(name))\n .filter(name => !name.endsWith(\"_verified\"))\n .map(name => (name.startsWith(\"custom:\") ? name : `custom:${name}`));\n\n return [...new Set([...STANDARD_USER_WRITABLE_ATTRIBUTES, ...custom])].filter(name => {\n return !USER_PROTECTED_ATTRIBUTES.includes(name);\n });\n });\n};\n\nexport const CoreCognito = createAppModule({\n name: \"Cognito\",\n config(app: PulumiApp, params: CoreCognitoParams) {\n const userPool = app.addResource(aws.cognito.UserPool, {\n name: \"user-pool\",\n config: {\n passwordPolicy: {\n minimumLength: 8,\n requireLowercase: false,\n requireNumbers: false,\n requireSymbols: false,\n requireUppercase: false,\n temporaryPasswordValidityDays: 7\n },\n adminCreateUserConfig: {\n allowAdminCreateUserOnly: true\n },\n autoVerifiedAttributes: [\"email\"],\n emailConfiguration: {\n emailSendingAccount: \"COGNITO_DEFAULT\"\n },\n // In a legacy setup we use email as username.\n // We need to provide a way for users to have this setup,\n // because changing it would require whole cognito pool to be recreated.\n usernameAttributes: params.useEmailAsUsername ? [\"email\"] : undefined,\n aliasAttributes: params.useEmailAsUsername ? undefined : [\"preferred_username\"],\n lambdaConfig: {},\n mfaConfiguration: params.mfa ? \"ON\" : \"OFF\",\n softwareTokenMfaConfiguration: params.mfa ? { enabled: true } : undefined,\n userPoolAddOns: {\n advancedSecurityMode: \"OFF\" /* required */\n },\n verificationMessageTemplate: {\n defaultEmailOption: \"CONFIRM_WITH_CODE\"\n },\n accountRecoverySetting: {\n recoveryMechanisms: [{ name: \"verified_email\", priority: 1 }]\n },\n schemas: [\n {\n attributeDataType: \"String\",\n name: \"email\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"family_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"given_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"id\",\n required: false,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"36\",\n minLength: \"0\"\n }\n }\n ]\n },\n opts: {\n protect: params.protect\n }\n });\n\n const userPoolClient = app.addResource(aws.cognito.UserPoolClient, {\n name: \"user-pool-client\",\n config: {\n userPoolId: userPool.output.id,\n writeAttributes: getUserWritableAttributes(userPool.output.schemas),\n accessTokenValidity: 60,\n idTokenValidity: 60,\n refreshTokenValidity: 30,\n tokenValidityUnits: {\n accessToken: \"minutes\",\n idToken: \"minutes\",\n refreshToken: \"days\"\n }\n }\n });\n\n return {\n userPool,\n userPoolClient\n };\n }\n});\n"],"names":["STANDARD_USER_WRITABLE_ATTRIBUTES","USER_PROTECTED_ATTRIBUTES","getUserWritableAttributes","schemas","pulumi","items","custom","schema","name","Set","CoreCognito","createAppModule","app","params","userPool","aws","undefined","userPoolClient"],"mappings":";;;AAgBA,MAAMA,oCAAoC;IACtC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAOM,MAAMC,4BAA4B;IAAC;CAAY;AAO/C,MAAMC,4BAA4B,CACrCC,UAEOC,0CAAAA,MAAa,CAACD,SAAS,KAAK,CAACE,CAAAA;QAChC,MAAMC,SAAUD,AAAAA,CAAAA,SAAS,
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/CoreCognito.js","sources":["../../../../src/pulumi/apps/core/CoreCognito.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { createAppModule, type PulumiApp, type PulumiAppModule } from \"@webiny/pulumi\";\n\nexport interface CoreCognitoParams {\n protect: boolean;\n useEmailAsUsername: boolean;\n mfa?: boolean;\n}\n\nexport type CoreCognito = PulumiAppModule<typeof CoreCognito>;\n\n/**\n * Standard attributes users may change themselves (with their own access token). The\n * `*_verified` flags are left out, so users can't mark an address they don't own as verified.\n */\nconst STANDARD_USER_WRITABLE_ATTRIBUTES = [\n \"address\",\n \"birthdate\",\n \"email\",\n \"family_name\",\n \"gender\",\n \"given_name\",\n \"locale\",\n \"middle_name\",\n \"name\",\n \"nickname\",\n \"phone_number\",\n \"picture\",\n \"preferred_username\",\n \"profile\",\n \"updated_at\",\n \"website\",\n \"zoneinfo\"\n];\n\n/**\n * Attributes that users must never change themselves. `custom:id` is the Webiny identity id:\n * a user who could write it would sign in as any other user. Webiny sets it with Cognito admin\n * APIs, which `writeAttributes` doesn't restrict.\n */\nexport const USER_PROTECTED_ATTRIBUTES = [\"custom:id\"];\n\n/**\n * Everything users could write before (all standard and all custom attributes of the pool,\n * including custom attributes a project adds to the schema), except the protected ones.\n * Cognito has no deny list for app clients, so the allowed list is built from the pool schema.\n */\nexport const getUserWritableAttributes = (\n schemas: pulumi.Input<aws.types.input.cognito.UserPoolSchema[] | undefined>\n): pulumi.Output<string[]> => {\n return pulumi.output(schemas).apply(items => {\n const custom = (items || [])\n .map(schema => schema.name)\n .filter(name => !STANDARD_USER_WRITABLE_ATTRIBUTES.includes(name))\n .filter(name => !name.endsWith(\"_verified\"))\n .map(name => (name.startsWith(\"custom:\") ? name : `custom:${name}`));\n\n return [...new Set([...STANDARD_USER_WRITABLE_ATTRIBUTES, ...custom])].filter(name => {\n return !USER_PROTECTED_ATTRIBUTES.includes(name);\n });\n });\n};\n\nexport const CoreCognito = createAppModule({\n name: \"Cognito\",\n config(app: PulumiApp, params: CoreCognitoParams) {\n const userPool = app.addResource(aws.cognito.UserPool, {\n name: \"user-pool\",\n config: {\n passwordPolicy: {\n minimumLength: 8,\n requireLowercase: false,\n requireNumbers: false,\n requireSymbols: false,\n requireUppercase: false,\n temporaryPasswordValidityDays: 7\n },\n adminCreateUserConfig: {\n allowAdminCreateUserOnly: true\n },\n autoVerifiedAttributes: [\"email\"],\n emailConfiguration: {\n emailSendingAccount: \"COGNITO_DEFAULT\"\n },\n // In a legacy setup we use email as username.\n // We need to provide a way for users to have this setup,\n // because changing it would require whole cognito pool to be recreated.\n usernameAttributes: params.useEmailAsUsername ? [\"email\"] : undefined,\n aliasAttributes: params.useEmailAsUsername ? undefined : [\"preferred_username\"],\n lambdaConfig: {},\n mfaConfiguration: params.mfa ? \"ON\" : \"OFF\",\n softwareTokenMfaConfiguration: params.mfa ? { enabled: true } : undefined,\n userPoolAddOns: {\n advancedSecurityMode: \"OFF\" /* required */\n },\n verificationMessageTemplate: {\n defaultEmailOption: \"CONFIRM_WITH_CODE\"\n },\n accountRecoverySetting: {\n recoveryMechanisms: [{ name: \"verified_email\", priority: 1 }]\n },\n schemas: [\n {\n attributeDataType: \"String\",\n name: \"email\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"family_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"given_name\",\n required: true,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"2048\",\n minLength: \"0\"\n }\n },\n {\n attributeDataType: \"String\",\n name: \"id\",\n required: false,\n developerOnlyAttribute: false,\n mutable: true,\n stringAttributeConstraints: {\n maxLength: \"36\",\n minLength: \"0\"\n }\n }\n ]\n },\n opts: {\n protect: params.protect\n }\n });\n\n const userPoolClient = app.addResource(aws.cognito.UserPoolClient, {\n name: \"user-pool-client\",\n config: {\n userPoolId: userPool.output.id,\n writeAttributes: getUserWritableAttributes(userPool.output.schemas),\n accessTokenValidity: 60,\n idTokenValidity: 60,\n refreshTokenValidity: 30,\n tokenValidityUnits: {\n accessToken: \"minutes\",\n idToken: \"minutes\",\n refreshToken: \"days\"\n }\n }\n });\n\n return {\n userPool,\n userPoolClient\n };\n }\n});\n"],"names":["STANDARD_USER_WRITABLE_ATTRIBUTES","USER_PROTECTED_ATTRIBUTES","getUserWritableAttributes","schemas","pulumi","items","custom","schema","name","Set","CoreCognito","createAppModule","app","params","userPool","aws","undefined","userPoolClient"],"mappings":";;;AAgBA,MAAMA,oCAAoC;IACtC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAOM,MAAMC,4BAA4B;IAAC;CAAY;AAO/C,MAAMC,4BA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AAoB;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,iBAAiBZ,0BAA0BY,SAAS,MAAM,CAAC,OAAO;gBAClE,qBAAqB;gBACrB,iBAAiB;gBACjB,sBAAsB;gBACtB,oBAAoB;oBAChB,aAAa;oBACb,SAAS;oBACT,cAAc;gBAClB;YACJ;QACJ;QAEA,OAAO;YACHA;YACAG;QACJ;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/amazon.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/amazon.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\n\n/**\n * Amazon doesn't provide first/last name as separate attributes. Instead, it gives you a `name`.\n * To handle this, developers will need to set up a pre-authentication Lambda trigger on the user pool,\n * to generate proper first/last name using custom code.\n */\nexport const getAmazonIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Amazon\",\n providerType: \"LoginWithAmazon\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"user_id\",\n username: \"user_id\",\n email: \"email\",\n given_name: \"name\",\n family_name: \"name\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getAmazonIdpConfig","userPoolId","config"],"mappings":"AASO,MAAMA,qBAAqB,CAC9BC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/amazon.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/amazon.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\n\n/**\n * Amazon doesn't provide first/last name as separate attributes. Instead, it gives you a `name`.\n * To handle this, developers will need to set up a pre-authentication Lambda trigger on the user pool,\n * to generate proper first/last name using custom code.\n */\nexport const getAmazonIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Amazon\",\n providerType: \"LoginWithAmazon\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"user_id\",\n username: \"user_id\",\n email: \"email\",\n given_name: \"name\",\n family_name: \"name\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getAmazonIdpConfig","userPoolId","config"],"mappings":"AASO,MAAMA,qBAAqB,CAC9BC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/apple.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/apple.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\n\nexport const getAppleIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Apple\",\n providerType: \"SignInWithApple\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"sub\",\n username: \"sub\",\n email: \"email\",\n given_name: \"firstName\",\n family_name: \"lastName\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getAppleIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,oBAAoB,CAC7BC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/apple.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/apple.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\n\nexport const getAppleIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Apple\",\n providerType: \"SignInWithApple\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"sub\",\n username: \"sub\",\n email: \"email\",\n given_name: \"firstName\",\n family_name: \"lastName\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getAppleIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,oBAAoB,CAC7BC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/facebook.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/facebook.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\n\nexport const getFacebookIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Facebook\",\n providerType: \"Facebook\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"id\",\n username: \"id\",\n email: \"email\",\n given_name: \"first_name\",\n family_name: \"last_name\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getFacebookIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,uBAAuB,CAChCC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/facebook.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/facebook.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\n\nexport const getFacebookIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Facebook\",\n providerType: \"Facebook\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"id\",\n username: \"id\",\n email: \"email\",\n given_name: \"first_name\",\n family_name: \"last_name\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getFacebookIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,uBAAuB,CAChCC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/google.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/google.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\n\nexport const getGoogleIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Google\",\n providerType: \"Google\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"sub\",\n username: \"sub\",\n email: \"email\",\n given_name: \"given_name\",\n family_name: \"family_name\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getGoogleIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,qBAAqB,CAC9BC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/google.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/google.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\n\nexport const getGoogleIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: \"Google\",\n providerType: \"Google\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"sub\",\n username: \"sub\",\n email: \"email\",\n given_name: \"given_name\",\n family_name: \"family_name\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getGoogleIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,qBAAqB,CAC9BC,YACAC,SAEO;QACHD;QACA,cAAc;QACd,cAAc;QACd,iBAAiBC,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,GAAGA,OAAO,gBAAgB;QAC9B;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/oidc.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/oidc.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\n\nexport const getOidcIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: config.name || \"OIDC\",\n providerType: \"OIDC\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"sub\",\n username: \"sub\",\n email: \"email\",\n given_name: \"given_name\",\n family_name: \"family_name\",\n preferred_username: \"email\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getOidcIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,mBAAmB,CAC5BC,YACAC,SAEO;QACHD;QACA,cAAcC,OAAO,IAAI,IAAI;QAC7B,cAAc;QACd,iBAAiBA,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,oBAAoB;YACpB,GAAGA,OAAO,gBAAgB;QAC9B;IACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/oidc.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/oidc.ts"],"sourcesContent":["import type * as pulumi from \"@pulumi/pulumi\";\nimport { type CognitoIdentityProviderConfig } from \"./configure.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\n\nexport const getOidcIdpConfig = (\n userPoolId: pulumi.Input<string>,\n config: CognitoIdentityProviderConfig\n): IdentityProviderArgs => {\n return {\n userPoolId,\n providerName: config.name || \"OIDC\",\n providerType: \"OIDC\",\n providerDetails: config.providerDetails,\n idpIdentifiers: config.idpIdentifiers,\n attributeMapping: {\n \"custom:id\": \"sub\",\n username: \"sub\",\n email: \"email\",\n given_name: \"given_name\",\n family_name: \"family_name\",\n preferred_username: \"email\",\n ...config.attributeMapping\n }\n };\n};\n"],"names":["getOidcIdpConfig","userPoolId","config"],"mappings":"AAIO,MAAMA,mBAAmB,CAC5BC,YACAC,SAEO;QACHD;QACA,cAAcC,OAAO,IAAI,IAAI;QAC7B,cAAc;QACd,iBAAiBA,OAAO,eAAe;QACvC,gBAAgBA,OAAO,cAAc;QACrC,kBAAkB;YACd,aAAa;YACb,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;YACb,oBAAoB;YACpB,GAAGA,OAAO,gBAAgB;QAC9B;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/createCorePulumiApp.js","sources":["../../../../src/pulumi/apps/core/createCorePulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { createPulumiApp, isResourceOfType } from \"@webiny/pulumi\";\nimport { CoreCognito } from \"./CoreCognito.js\";\nimport { CoreDynamo } from \"./CoreDynamo.js\";\nimport { OpenSearch } from \"./CoreOpenSearch.js\";\nimport { CoreEventBus } from \"./CoreEventBus.js\";\nimport { CoreFileManger } from \"./CoreFileManager.js\";\nimport { CoreVpc } from \"./CoreVpc.js\";\nimport { WatchCommand } from \"./WatchCommand.js\";\nimport { withServiceManifest } from \"~/pulumi/utils/withServiceManifest.js\";\nimport {\n addServiceManifestTableItem,\n type TableDefinition\n} from \"~/pulumi/utils/addServiceManifestTableItem.js\";\nimport * as random from \"@pulumi/random\";\n\nimport { getProjectSdk } from \"@webiny/project\";\nimport { CorePulumi } from \"~/abstractions/features/pulumi/index.js\";\nimport { corePulumi } from \"~/pulumi/features/CorePulumi/index.js\";\nimport { getOsConfigFromExtension } from \"~/pulumi/apps/extensions/getOsConfigFromExtension.js\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { isVpcEnabled } from \"~/pulumi/apps/extensions/isVpcEnabled.js\";\nimport { applyAwsResourceTags, getAwsRegion } from \"~/pulumi/apps/awsUtils.js\";\nimport { configureS3BucketMalwareProtection } from \"./configureS3BucketMalwareProtection.js\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { CoreAuditLogsDynamo } from \"~/pulumi/index.js\";\n\nexport type CorePulumiApp = ReturnType<typeof createCorePulumiApp>;\n\nexport function createCorePulumiApp() {\n const baseApp = createPulumiApp({\n name: \"core\",\n path: \"apps/core\",\n program: async app => {\n const sdk = await getProjectSdk();\n const projectConfig = await sdk.getProjectConfig();\n\n const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();\n const coreStackOutput = await sdk.getAppStackOutput<{\n opensearchDomainName?: string;\n primaryDynamodbTableName?: string;\n }>(\"core\");\n const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);\n const opensearchExtensionConfig = getOsConfigFromExtension(projectConfig);\n\n const deploymentId = new random.RandomId(\"deploymentId\", { byteLength: 8 });\n\n let searchEngineType: \"opensearch\" | null = null;\n let searchEngineParams: typeof opensearchExtensionConfig | null = null;\n\n if (opensearchExtensionConfig) {\n searchEngineParams = opensearchExtensionConfig;\n searchEngineType = \"opensearch\";\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 usingAdvancedVpcParams =\n vpcExtensionsConfig && typeof vpcExtensionsConfig !== \"boolean\";\n\n const featureFlags = await sdk.getFeatureFlags();\n if (featureFlags.isFileManagerThreatDetectionEnabled()) {\n configureS3BucketMalwareProtection(app as CorePulumiApp);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return;\n }\n\n const { resources, addResource, onResource } = app as CorePulumiApp;\n const { useExistingVpc, useVpcEndpoints } = vpcExtensionsConfig;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (\"useVpcEndpoints\" in vpcExtensionsConfig) {\n throw new Error(\n \"Cannot specify `useVpcEndpoints` parameter when using an existing VPC. The VPC endpoints configurations should be already defined within the existing VPC.\"\n );\n }\n\n if (opensearchExtensionConfig) {\n if (!useExistingVpc.openSearchDomainVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `openSearchDomainVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.opensearch.Domain)) {\n resource.config.vpcOptions(\n useExistingVpc!.openSearchDomainVpcConfig\n );\n }\n });\n }\n\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(useExistingVpc!.lambdaFunctionsVpcConfig);\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.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n\n return;\n }\n\n // 2. Now we deal with \"non-existing VPC\" setup.\n if (useVpcEndpoints) {\n const region = getAwsRegion(app);\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.ec2.Vpc)) {\n resource.config.enableDnsSupport(true);\n resource.config.enableDnsHostnames(true);\n }\n });\n\n const { vpc, subnets, routeTables } = resources.vpc!;\n 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 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 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 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 // <-------------------- 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(corePulumi);\n const pulumiHandlers = sdk.getContainer().resolve(CorePulumi);\n\n app.addHandler(() => {\n return pulumiHandlers.execute(app as CorePulumiApp);\n });\n\n const isProduction = app.env.isProduction;\n const protect = isProduction;\n\n // Setup DynamoDB table\n const dynamoDbTable = app.addModule(CoreDynamo, { protect });\n const auditLogsDynamoDbTable = app.addModule(CoreAuditLogsDynamo, { protect });\n\n // Setup VPC\n const vpc = isVpcEnabled(vpcExtensionsConfig, isProduction)\n ? app.addModule(CoreVpc)\n : null;\n\n // Setup Cognito\n const cognito = app.addModule(CoreCognito, {\n protect,\n useEmailAsUsername: false,\n mfa: process.env.COGNITO_MFA === \"true\"\n });\n\n // Cognito custom:id was originally set to maxLength 36 (UUID). Federated OIDC\n // providers (e.g., Entra ID) can produce sub values longer than 36 chars. Since\n // Cognito doesn't allow changing custom attribute constraints after pool creation,\n // we only increase it for new deployments. Existing pools keep their original limit.\n const isNewDeployment = !coreStackOutput || Object.keys(coreStackOutput).length === 0;\n if (isNewDeployment) {\n cognito.userPool.config.schemas(schemas => {\n return schemas?.map(schema => {\n if (schema.name === \"id\") {\n return {\n ...schema,\n stringAttributeConstraints: {\n ...schema.stringAttributeConstraints,\n maxLength: \"256\"\n }\n };\n }\n return schema;\n });\n });\n } else {\n cognito.userPool.opts.ignoreChanges = [\n ...(cognito.userPool.opts.ignoreChanges || []),\n \"schemas\"\n ];\n }\n\n // Setup event bus\n const eventBus = app.addModule(CoreEventBus);\n\n // Setup file core bucket\n const { bucket: fileManagerBucket } = app.addModule(CoreFileManger, { protect });\n\n let opensearch;\n if (searchEngineType === \"opensearch\") {\n const prevDomainName = coreStackOutput?.opensearchDomainName;\n\n // When upgrading from old code that never stored opensearchDomainName, the old\n // code always generated domain names without any prefix (app.params.create\n // .pulumiResourceNamePrefix was never a real Pulumi param, so it returned \"\").\n // Using the SDK default \"wby-\" prefix here would generate a different name and\n // cause Pulumi to destroy and recreate the cluster.\n const isUpgradeFromOldCode =\n !!coreStackOutput?.primaryDynamodbTableName && !prevDomainName;\n const namePrefixForOs = isUpgradeFromOldCode ? \"\" : pulumiResourceNamePrefix || \"\";\n\n opensearch = app.addModule(OpenSearch, {\n protect,\n namePrefix: namePrefixForOs,\n prevDomainName\n });\n }\n\n app.addModule(WatchCommand, { deploymentId: deploymentId.hex });\n\n app.addOutputs({\n deploymentId: deploymentId.hex,\n region: aws.config.region,\n fileManagerBucketId: fileManagerBucket.output.id,\n primaryDynamodbTableArn: dynamoDbTable.output.arn,\n primaryDynamodbTableName: dynamoDbTable.output.name,\n primaryDynamodbTableHashKey: dynamoDbTable.output.hashKey,\n primaryDynamodbTableRangeKey: dynamoDbTable.output.rangeKey,\n auditLogsDynamodbTableArn: auditLogsDynamoDbTable.output.arn,\n auditLogsDynamodbTableName: auditLogsDynamoDbTable.output.name,\n auditLogsDynamodbTableHashKey: auditLogsDynamoDbTable.output.hashKey,\n auditLogsDynamodbTableRangeKey: auditLogsDynamoDbTable.output.rangeKey,\n cognitoUserPoolId: cognito.userPool.output.id,\n cognitoUserPoolArn: cognito.userPool.output.arn,\n cognitoUserPoolPasswordPolicy: cognito.userPool.output.passwordPolicy,\n cognitoAppClientId: cognito.userPoolClient.output.id,\n eventBusName: eventBus.output.name,\n eventBusArn: eventBus.output.arn\n });\n\n // Applies internal and user-defined AWS tags.\n await applyAwsResourceTags(\"core\");\n\n return {\n dynamoDbTable,\n vpc,\n ...cognito,\n fileManagerBucket,\n eventBus,\n opensearch\n };\n }\n });\n\n const app = withServiceManifest(baseApp, manifests => {\n const dynamoTable = baseApp.resources.dynamoDbTable;\n\n const table: TableDefinition = {\n tableName: dynamoTable.output.name,\n hashKey: dynamoTable.output.hashKey,\n rangeKey: dynamoTable.output.rangeKey\n };\n\n manifests.forEach(manifest => addServiceManifestTableItem(baseApp, table, manifest));\n });\n\n app.addHandler(() => {\n app.addServiceManifest({\n name: \"core\",\n manifest: {\n eventBus: {\n arn: baseApp.resources.eventBus.output.arn,\n name: baseApp.resources.eventBus.output.name\n },\n dynamodbTable: {\n arn: baseApp.resources.dynamoDbTable.output.arn,\n name: baseApp.resources.dynamoDbTable.output.name,\n hashKey: baseApp.resources.dynamoDbTable.output.hashKey,\n rangeKey: baseApp.resources.dynamoDbTable.output.rangeKey\n }\n }\n });\n });\n\n return app;\n}\n"],"names":["createCorePulumiApp","baseApp","createPulumiApp","app","sdk","getProjectSdk","projectConfig","pulumiResourceNamePrefix","coreStackOutput","vpcExtensionsConfig","getVpcConfigFromExtension","opensearchExtensionConfig","getOsConfigFromExtension","deploymentId","random","searchEngineType","searchEngineParams","params","process","resource","usingAdvancedVpcParams","featureFlags","configureS3BucketMalwareProtection","resources","addResource","onResource","useExistingVpc","useVpcEndpoints","Error","isResourceOfType","aws","canUseVpc","region","getAwsRegion","vpc","subnets","routeTables","pulumi","subNet","corePulumi","pulumiHandlers","CorePulumi","isProduction","protect","dynamoDbTable","CoreDynamo","auditLogsDynamoDbTable","CoreAuditLogsDynamo","isVpcEnabled","CoreVpc","cognito","CoreCognito","isNewDeployment","Object","schemas","schema","eventBus","CoreEventBus","fileManagerBucket","CoreFileManger","opensearch","prevDomainName","isUpgradeFromOldCode","namePrefixForOs","OpenSearch","WatchCommand","applyAwsResourceTags","withServiceManifest","manifests","dynamoTable","table","manifest","addServiceManifestTableItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BO,SAASA;IACZ,MAAMC,UAAUC,gBAAgB;QAC5B,MAAM;QACN,MAAM;QACN,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CorePulumiApp.js","sources":["../../../../src/pulumi/apps/core/createCorePulumiApp.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { createPulumiApp, isResourceOfType } from \"@webiny/pulumi\";\nimport { CoreCognito } from \"./CoreCognito.js\";\nimport { CoreDynamo } from \"./CoreDynamo.js\";\nimport { OpenSearch } from \"./CoreOpenSearch.js\";\nimport { CoreEventBus } from \"./CoreEventBus.js\";\nimport { CoreFileManger } from \"./CoreFileManager.js\";\nimport { CoreVpc } from \"./CoreVpc.js\";\nimport { WatchCommand } from \"./WatchCommand.js\";\nimport { withServiceManifest } from \"~/pulumi/utils/withServiceManifest.js\";\nimport {\n addServiceManifestTableItem,\n type TableDefinition\n} from \"~/pulumi/utils/addServiceManifestTableItem.js\";\nimport * as random from \"@pulumi/random\";\n\nimport { getProjectSdk } from \"@webiny/project\";\nimport { CorePulumi } from \"~/abstractions/features/pulumi/index.js\";\nimport { corePulumi } from \"~/pulumi/features/CorePulumi/index.js\";\nimport { getOsConfigFromExtension } from \"~/pulumi/apps/extensions/getOsConfigFromExtension.js\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { isVpcEnabled } from \"~/pulumi/apps/extensions/isVpcEnabled.js\";\nimport { applyAwsResourceTags, getAwsRegion } from \"~/pulumi/apps/awsUtils.js\";\nimport { configureS3BucketMalwareProtection } from \"./configureS3BucketMalwareProtection.js\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport { CoreAuditLogsDynamo } from \"~/pulumi/index.js\";\n\nexport type CorePulumiApp = ReturnType<typeof createCorePulumiApp>;\n\nexport function createCorePulumiApp() {\n const baseApp = createPulumiApp({\n name: \"core\",\n path: \"apps/core\",\n program: async app => {\n const sdk = await getProjectSdk();\n const projectConfig = await sdk.getProjectConfig();\n\n const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();\n const coreStackOutput = await sdk.getAppStackOutput<{\n opensearchDomainName?: string;\n primaryDynamodbTableName?: string;\n }>(\"core\");\n const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);\n const opensearchExtensionConfig = getOsConfigFromExtension(projectConfig);\n\n const deploymentId = new random.RandomId(\"deploymentId\", { byteLength: 8 });\n\n let searchEngineType: \"opensearch\" | null = null;\n let searchEngineParams: typeof opensearchExtensionConfig | null = null;\n\n if (opensearchExtensionConfig) {\n searchEngineParams = opensearchExtensionConfig;\n searchEngineType = \"opensearch\";\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 usingAdvancedVpcParams =\n vpcExtensionsConfig && typeof vpcExtensionsConfig !== \"boolean\";\n\n const featureFlags = await sdk.getFeatureFlags();\n if (featureFlags.isFileManagerThreatDetectionEnabled()) {\n configureS3BucketMalwareProtection(app as CorePulumiApp);\n }\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return;\n }\n\n const { resources, addResource, onResource } = app as CorePulumiApp;\n const { useExistingVpc, useVpcEndpoints } = vpcExtensionsConfig;\n\n // 1. We first deal with \"existing VPC\" setup.\n if (useExistingVpc) {\n if (\"useVpcEndpoints\" in vpcExtensionsConfig) {\n throw new Error(\n \"Cannot specify `useVpcEndpoints` parameter when using an existing VPC. The VPC endpoints configurations should be already defined within the existing VPC.\"\n );\n }\n\n if (opensearchExtensionConfig) {\n if (!useExistingVpc.openSearchDomainVpcConfig) {\n throw new Error(\n \"Cannot specify `useExistingVpc` parameter because the `openSearchDomainVpcConfig` parameter wasn't provided.\"\n );\n }\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.opensearch.Domain)) {\n resource.config.vpcOptions(\n useExistingVpc!.openSearchDomainVpcConfig\n );\n }\n });\n }\n\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(useExistingVpc!.lambdaFunctionsVpcConfig);\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.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n\n return;\n }\n\n // 2. Now we deal with \"non-existing VPC\" setup.\n if (useVpcEndpoints) {\n const region = getAwsRegion(app);\n\n onResource(resource => {\n if (isResourceOfType(resource, aws.ec2.Vpc)) {\n resource.config.enableDnsSupport(true);\n resource.config.enableDnsHostnames(true);\n }\n });\n\n const { vpc, subnets, routeTables } = resources.vpc!;\n 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 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 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 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 // <-------------------- 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(corePulumi);\n const pulumiHandlers = sdk.getContainer().resolve(CorePulumi);\n\n app.addHandler(() => {\n return pulumiHandlers.execute(app as CorePulumiApp);\n });\n\n const isProduction = app.env.isProduction;\n const protect = isProduction;\n\n // Setup DynamoDB table\n const dynamoDbTable = app.addModule(CoreDynamo, { protect });\n const auditLogsDynamoDbTable = app.addModule(CoreAuditLogsDynamo, { protect });\n\n // Setup VPC\n const vpc = isVpcEnabled(vpcExtensionsConfig, isProduction)\n ? app.addModule(CoreVpc)\n : null;\n\n // Setup Cognito\n const cognito = app.addModule(CoreCognito, {\n protect,\n useEmailAsUsername: false,\n mfa: process.env.COGNITO_MFA === \"true\"\n });\n\n // Cognito custom:id was originally set to maxLength 36 (UUID). Federated OIDC\n // providers (e.g., Entra ID) can produce sub values longer than 36 chars. Since\n // Cognito doesn't allow changing custom attribute constraints after pool creation,\n // we only increase it for new deployments. Existing pools keep their original limit.\n const isNewDeployment = !coreStackOutput || Object.keys(coreStackOutput).length === 0;\n if (isNewDeployment) {\n cognito.userPool.config.schemas(schemas => {\n return schemas?.map(schema => {\n if (schema.name === \"id\") {\n return {\n ...schema,\n stringAttributeConstraints: {\n ...schema.stringAttributeConstraints,\n maxLength: \"256\"\n }\n };\n }\n return schema;\n });\n });\n } else {\n cognito.userPool.opts.ignoreChanges = [\n ...(cognito.userPool.opts.ignoreChanges || []),\n \"schemas\"\n ];\n }\n\n // Setup event bus\n const eventBus = app.addModule(CoreEventBus);\n\n // Setup file core bucket\n const { bucket: fileManagerBucket } = app.addModule(CoreFileManger, { protect });\n\n let opensearch;\n if (searchEngineType === \"opensearch\") {\n const prevDomainName = coreStackOutput?.opensearchDomainName;\n\n // When upgrading from old code that never stored opensearchDomainName, the old\n // code always generated domain names without any prefix (app.params.create\n // .pulumiResourceNamePrefix was never a real Pulumi param, so it returned \"\").\n // Using the SDK default \"wby-\" prefix here would generate a different name and\n // cause Pulumi to destroy and recreate the cluster.\n const isUpgradeFromOldCode =\n !!coreStackOutput?.primaryDynamodbTableName && !prevDomainName;\n const namePrefixForOs = isUpgradeFromOldCode ? \"\" : pulumiResourceNamePrefix || \"\";\n\n opensearch = app.addModule(OpenSearch, {\n protect,\n namePrefix: namePrefixForOs,\n prevDomainName\n });\n }\n\n app.addModule(WatchCommand, { deploymentId: deploymentId.hex });\n\n app.addOutputs({\n deploymentId: deploymentId.hex,\n region: aws.config.region,\n fileManagerBucketId: fileManagerBucket.output.id,\n primaryDynamodbTableArn: dynamoDbTable.output.arn,\n primaryDynamodbTableName: dynamoDbTable.output.name,\n primaryDynamodbTableHashKey: dynamoDbTable.output.hashKey,\n primaryDynamodbTableRangeKey: dynamoDbTable.output.rangeKey,\n auditLogsDynamodbTableArn: auditLogsDynamoDbTable.output.arn,\n auditLogsDynamodbTableName: auditLogsDynamoDbTable.output.name,\n auditLogsDynamodbTableHashKey: auditLogsDynamoDbTable.output.hashKey,\n auditLogsDynamodbTableRangeKey: auditLogsDynamoDbTable.output.rangeKey,\n cognitoUserPoolId: cognito.userPool.output.id,\n cognitoUserPoolArn: cognito.userPool.output.arn,\n cognitoUserPoolPasswordPolicy: cognito.userPool.output.passwordPolicy,\n cognitoAppClientId: cognito.userPoolClient.output.id,\n eventBusName: eventBus.output.name,\n eventBusArn: eventBus.output.arn\n });\n\n // Applies internal and user-defined AWS tags.\n await applyAwsResourceTags(\"core\");\n\n return {\n dynamoDbTable,\n vpc,\n ...cognito,\n fileManagerBucket,\n eventBus,\n opensearch\n };\n }\n });\n\n const app = withServiceManifest(baseApp, manifests => {\n const dynamoTable = baseApp.resources.dynamoDbTable;\n\n const table: TableDefinition = {\n tableName: dynamoTable.output.name,\n hashKey: dynamoTable.output.hashKey,\n rangeKey: dynamoTable.output.rangeKey\n };\n\n manifests.forEach(manifest => addServiceManifestTableItem(baseApp, table, manifest));\n });\n\n app.addHandler(() => {\n app.addServiceManifest({\n name: \"core\",\n manifest: {\n eventBus: {\n arn: baseApp.resources.eventBus.output.arn,\n name: baseApp.resources.eventBus.output.name\n },\n dynamodbTable: {\n arn: baseApp.resources.dynamoDbTable.output.arn,\n name: baseApp.resources.dynamoDbTable.output.name,\n hashKey: baseApp.resources.dynamoDbTable.output.hashKey,\n rangeKey: baseApp.resources.dynamoDbTable.output.rangeKey\n }\n }\n });\n });\n\n return app;\n}\n"],"names":["createCorePulumiApp","baseApp","createPulumiApp","app","sdk","getProjectSdk","projectConfig","pulumiResourceNamePrefix","coreStackOutput","vpcExtensionsConfig","getVpcConfigFromExtension","opensearchExtensionConfig","getOsConfigFromExtension","deploymentId","random","searchEngineType","searchEngineParams","params","process","resource","usingAdvancedVpcParams","featureFlags","configureS3BucketMalwareProtection","resources","addResource","onResource","useExistingVpc","useVpcEndpoints","Error","isResourceOfType","aws","canUseVpc","region","getAwsRegion","vpc","subnets","routeTables","pulumi","subNet","corePulumi","pulumiHandlers","CorePulumi","isProduction","protect","dynamoDbTable","CoreDynamo","auditLogsDynamoDbTable","CoreAuditLogsDynamo","isVpcEnabled","CoreVpc","cognito","CoreCognito","isNewDeployment","Object","schemas","schema","eventBus","CoreEventBus","fileManagerBucket","CoreFileManger","opensearch","prevDomainName","isUpgradeFromOldCode","namePrefixForOs","OpenSearch","WatchCommand","applyAwsResourceTags","withServiceManifest","manifests","dynamoTable","table","manifest","addServiceManifestTableItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BO,SAASA;IACZ,MAAMC,UAAUC,gBAAgB;QAC5B,MAAM;QACN,MAAM;QACN,SAAS,OAAMC;YACX,MAAMC,MAAM,MAAMC;YAClB,MAAMC,gBAAgB,MAAMF,IAAI,gBAAgB;YAEhD,MAAMG,2BAA2B,MAAMH,IAAI,2BAA2B;YACtE,MAAMI,kBAAkB,MAAMJ,IAAI,iBAAiB,CAGhD;YACH,MAAMK,sBAAsBC,0BAA0BJ;YACtD,MAAMK,4BAA4BC,yBAAyBN;YAE3D,MAAMO,eAAe,IAAIC,0CAAAA,QAAe,CAAC,gBAAgB;gBAAE,YAAY;YAAE;YAEzE,IAAIC,mBAAwC;YAC5C,IAAIC,qBAA8D;YAElE,IAAIL,2BAA2B;gBAC3BK,qBAAqBL;gBACrBI,mBAAmB;YACvB;YAEA,IAAIC,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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,CAAC,IAAI;gBAChD;gBACA,eAAe;oBACX,KAAKA,QAAQ,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG;oBAC/C,MAAMA,QAAQ,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI;oBACjD,SAASA,QAAQ,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO;oBACvD,UAAUA,QAAQ,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ;gBAC7D;YACJ;QACJ;IACJ;IAEA,OAAOE;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/syncSystem/SyncSystemLambda.js","sources":["../../../../src/pulumi/apps/syncSystem/SyncSystemLambda.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils.js\";\nimport { VpcConfig } from \"~/pulumi/apps/index.js\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils.js\";\nimport { LAMBDA_RUNTIME } from \"~/pulumi/constants.js\";\nimport { SyncSystemDynamo } from \"./SyncSystemDynamo.js\";\n\nexport interface SyncSystemLambdaParams {\n protect: boolean;\n config: Record<string, string>;\n}\n\nexport const SyncSystemLambda = createAppModule({\n name: \"SyncSystemLambda\",\n config(app: PulumiApp, _: SyncSystemLambdaParams) {\n const policy = createSyncSystemLambdaPolicy({\n app,\n // TODO - get bucket ids and dynamodb tables from the FileManager app\n primary: {\n fileManagerBucketId: \"primaryFileManagerBucketId\",\n dynamoDbTableArn: \"\"\n },\n secondary: {\n fileManagerBucketId: \"secondaryFileManagerBucketId\",\n dynamoDbTableArn: \"\"\n }\n });\n const role = createLambdaRole(app, {\n name: \"sync-system-lambda-role\",\n policy: policy.output\n });\n\n const syncSystemLambda = app.addResource(aws.lambda.Function, {\n name: \"sync-system-lambda\",\n config: {\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n role: role.output.arn,\n timeout: 900,\n memorySize: 1024,\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"transfer/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\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 return {\n role,\n policy,\n functions: {\n syncSystem: syncSystemLambda\n }\n };\n }\n});\n\ninterface ICreateSyncSystemLambdaPolicyParamsType {\n fileManagerBucketId: string;\n dynamoDbTableArn: string;\n}\n\ninterface ICreateSyncSystemLambdaPolicyParams {\n app: PulumiApp;\n primary: ICreateSyncSystemLambdaPolicyParamsType;\n secondary: ICreateSyncSystemLambdaPolicyParamsType;\n}\n\nfunction createSyncSystemLambdaPolicy(params: ICreateSyncSystemLambdaPolicyParams) {\n const { app, primary, secondary } = params;\n const dynamoDbTable = app.getModule(SyncSystemDynamo);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:ConditionCheckItem\",\n \"dynamodb:CreateBackup\",\n \"dynamodb:CreateTable\",\n \"dynamodb:CreateTableReplica\",\n \"dynamodb:DeleteBackup\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DeleteTableReplica\",\n \"dynamodb:DescribeBackup\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeContributorInsights\",\n \"dynamodb:DescribeExport\",\n \"dynamodb:DescribeKinesisStreamingDestination\",\n \"dynamodb:DescribeLimits\",\n \"dynamodb:DescribeReservedCapacity\",\n \"dynamodb:DescribeReservedCapacityOfferings\",\n \"dynamodb:DescribeStream\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTableReplicaAutoScaling\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:DisableKinesisStreamingDestination\",\n \"dynamodb:EnableKinesisStreamingDestination\",\n \"dynamodb:ExportTableToPointInTime\",\n \"dynamodb:GetItem\",\n \"dynamodb:GetRecords\",\n \"dynamodb:GetShardIterator\",\n \"dynamodb:ListBackups\",\n \"dynamodb:ListContributorInsights\",\n \"dynamodb:ListExports\",\n \"dynamodb:ListStreams\",\n \"dynamodb:ListTables\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:PartiQLDelete\",\n \"dynamodb:PartiQLInsert\",\n \"dynamodb:PartiQLSelect\",\n \"dynamodb:PartiQLUpdate\",\n \"dynamodb:PurchaseReservedCapacityOfferings\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:RestoreTableFromBackup\",\n \"dynamodb:RestoreTableToPointInTime\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateContinuousBackups\",\n \"dynamodb:UpdateContributorInsights\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTableReplicaAutoScaling\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n Resource: [`${dynamoDbTable.output.arn}`, `${dynamoDbTable.output.arn}/*`]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:ListBucket\",\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${primary.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${primary.fileManagerBucketId}/*`,\n pulumi.interpolate`arn:aws:s3:::${secondary.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${secondary.fileManagerBucketId}/*`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n }\n ]\n };\n\n return app.addResource(aws.iam.Policy, {\n name: \"SyncSystemLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb, S3 and Lambda.\",\n policy\n }\n });\n}\n"],"names":["SyncSystemLambda","createAppModule","app","_","policy","createSyncSystemLambdaPolicy","role","createLambdaRole","syncSystemLambda","aws","LAMBDA_RUNTIME","pulumi","path","getCommonLambdaEnvVariables","value","VpcConfig","params","primary","secondary","dynamoDbTable","SyncSystemDynamo","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion"],"mappings":";;;;;;;;;AAgBO,MAAMA,mBAAmBC,gBAAgB;IAC5C,MAAM;IACN,QAAOC,GAAc,EAAEC,CAAyB;QAC5C,MAAMC,SAASC,6BAA6B;YACxCH;YAEA,SAAS;gBACL,qBAAqB;gBACrB,kBAAkB;YACtB;YACA,WAAW;gBACP,qBAAqB;gBACrB,kBAAkB;YACtB;QACJ;QACA,MAAMI,OAAOC,iBAAiBL,KAAK;YAC/B,MAAM;YACN,QAAQE,OAAO,MAAM;QACzB;QAEA,MAAMI,mBAAmBN,IAAI,WAAW,CAACO,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YAC1D,MAAM;YACN,QAAQ;gBACJ,SAASC;gBACT,SAAS;gBACT,MAAMJ,KAAK,MAAM,CAAC,GAAG;gBACrB,SAAS;gBACT,YAAY;gBACZ,MAAM,IAAIK,0CAAAA,KAAAA,CAAAA,YAAyB,CAAC;oBAChC,KAAK,IAAIA,0CAAAA,KAAAA,CAAAA,WAAwB,CAC7BC,KAAK,IAAI,CAACV,IAAI,KAAK,CAAC,SAAS,EAAE;gBAEvC;gBACA,aAAa;oBACT,WAA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,WAAkB,CAAC,aAAa,EAAEO,UAAU,mBAAmB,CAAC,CAAC;oBACjEP,0CAAAA,WAAkB,CAAC,aAAa,EAAEO,UAAU,mBAAmB,CAAC,EAAE,CAAC;iBACtE;YACL;YACA;gBACI,KAAK;gBACL,QAAQ;gBACR,QAAQ;oBAAC;iBAAwB;gBACjC,UAAUP,0CAAAA,WAAkB,CAAC,eAAe,EAAEY,UAAU,CAAC,EAAEF,aAAa,WAAW,CAAC;YACxF;SACH;IACL;IAEA,OAAOnB,IAAI,WAAW,CAACO,uCAAAA,GAAAA,CAAAA,MAAc,EAAE;QACnC,MAAM;QACN,QAAQ;YACJ,aAAa;YACbL;QACJ;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/apps/syncSystem/SyncSystemLambda.js","sources":["../../../../src/pulumi/apps/syncSystem/SyncSystemLambda.ts"],"sourcesContent":["import path from \"path\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport { createAppModule } from \"@webiny/pulumi\";\nimport { createLambdaRole, getCommonLambdaEnvVariables } from \"../lambdaUtils.js\";\nimport { VpcConfig } from \"~/pulumi/apps/index.js\";\nimport { getAwsAccountId, getAwsRegion } from \"../awsUtils.js\";\nimport { LAMBDA_RUNTIME } from \"~/pulumi/constants.js\";\nimport { SyncSystemDynamo } from \"./SyncSystemDynamo.js\";\n\nexport interface SyncSystemLambdaParams {\n protect: boolean;\n config: Record<string, string>;\n}\n\nexport const SyncSystemLambda = createAppModule({\n name: \"SyncSystemLambda\",\n config(app: PulumiApp, _: SyncSystemLambdaParams) {\n const policy = createSyncSystemLambdaPolicy({\n app,\n // TODO - get bucket ids and dynamodb tables from the FileManager app\n primary: {\n fileManagerBucketId: \"primaryFileManagerBucketId\",\n dynamoDbTableArn: \"\"\n },\n secondary: {\n fileManagerBucketId: \"secondaryFileManagerBucketId\",\n dynamoDbTableArn: \"\"\n }\n });\n const role = createLambdaRole(app, {\n name: \"sync-system-lambda-role\",\n policy: policy.output\n });\n\n const syncSystemLambda = app.addResource(aws.lambda.Function, {\n name: \"sync-system-lambda\",\n config: {\n runtime: LAMBDA_RUNTIME,\n handler: \"handler.handler\",\n role: role.output.arn,\n timeout: 900,\n memorySize: 1024,\n code: new pulumi.asset.AssetArchive({\n \".\": new pulumi.asset.FileArchive(\n path.join(app.paths.workspace, \"transfer/build\")\n )\n }),\n environment: {\n variables: getCommonLambdaEnvVariables().apply(value => ({\n ...value,\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 return {\n role,\n policy,\n functions: {\n syncSystem: syncSystemLambda\n }\n };\n }\n});\n\ninterface ICreateSyncSystemLambdaPolicyParamsType {\n fileManagerBucketId: string;\n dynamoDbTableArn: string;\n}\n\ninterface ICreateSyncSystemLambdaPolicyParams {\n app: PulumiApp;\n primary: ICreateSyncSystemLambdaPolicyParamsType;\n secondary: ICreateSyncSystemLambdaPolicyParamsType;\n}\n\nfunction createSyncSystemLambdaPolicy(params: ICreateSyncSystemLambdaPolicyParams) {\n const { app, primary, secondary } = params;\n const dynamoDbTable = app.getModule(SyncSystemDynamo);\n const awsAccountId = getAwsAccountId(app);\n const awsRegion = getAwsRegion(app);\n\n const policy: aws.iam.PolicyDocument = {\n Version: \"2012-10-17\",\n Statement: [\n {\n Sid: \"PermissionForDynamodb\",\n Effect: \"Allow\",\n Action: [\n \"dynamodb:BatchGetItem\",\n \"dynamodb:BatchWriteItem\",\n \"dynamodb:ConditionCheckItem\",\n \"dynamodb:CreateBackup\",\n \"dynamodb:CreateTable\",\n \"dynamodb:CreateTableReplica\",\n \"dynamodb:DeleteBackup\",\n \"dynamodb:DeleteItem\",\n \"dynamodb:DeleteTable\",\n \"dynamodb:DeleteTableReplica\",\n \"dynamodb:DescribeBackup\",\n \"dynamodb:DescribeContinuousBackups\",\n \"dynamodb:DescribeContributorInsights\",\n \"dynamodb:DescribeExport\",\n \"dynamodb:DescribeKinesisStreamingDestination\",\n \"dynamodb:DescribeLimits\",\n \"dynamodb:DescribeReservedCapacity\",\n \"dynamodb:DescribeReservedCapacityOfferings\",\n \"dynamodb:DescribeStream\",\n \"dynamodb:DescribeTable\",\n \"dynamodb:DescribeTableReplicaAutoScaling\",\n \"dynamodb:DescribeTimeToLive\",\n \"dynamodb:DisableKinesisStreamingDestination\",\n \"dynamodb:EnableKinesisStreamingDestination\",\n \"dynamodb:ExportTableToPointInTime\",\n \"dynamodb:GetItem\",\n \"dynamodb:GetRecords\",\n \"dynamodb:GetShardIterator\",\n \"dynamodb:ListBackups\",\n \"dynamodb:ListContributorInsights\",\n \"dynamodb:ListExports\",\n \"dynamodb:ListStreams\",\n \"dynamodb:ListTables\",\n \"dynamodb:ListTagsOfResource\",\n \"dynamodb:PartiQLDelete\",\n \"dynamodb:PartiQLInsert\",\n \"dynamodb:PartiQLSelect\",\n \"dynamodb:PartiQLUpdate\",\n \"dynamodb:PurchaseReservedCapacityOfferings\",\n \"dynamodb:PutItem\",\n \"dynamodb:Query\",\n \"dynamodb:RestoreTableFromBackup\",\n \"dynamodb:RestoreTableToPointInTime\",\n \"dynamodb:Scan\",\n \"dynamodb:UpdateContinuousBackups\",\n \"dynamodb:UpdateContributorInsights\",\n \"dynamodb:UpdateItem\",\n \"dynamodb:UpdateTable\",\n \"dynamodb:UpdateTableReplicaAutoScaling\",\n \"dynamodb:UpdateTimeToLive\"\n ],\n Resource: [`${dynamoDbTable.output.arn}`, `${dynamoDbTable.output.arn}/*`]\n },\n {\n Sid: \"PermissionForS3\",\n Effect: \"Allow\",\n Action: [\n \"s3:ListBucket\",\n \"s3:GetObjectAcl\",\n \"s3:DeleteObject\",\n \"s3:PutObjectAcl\",\n \"s3:PutObject\",\n \"s3:GetObject\"\n ],\n Resource: [\n pulumi.interpolate`arn:aws:s3:::${primary.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${primary.fileManagerBucketId}/*`,\n pulumi.interpolate`arn:aws:s3:::${secondary.fileManagerBucketId}`,\n pulumi.interpolate`arn:aws:s3:::${secondary.fileManagerBucketId}/*`\n ]\n },\n {\n Sid: \"PermissionForLambda\",\n Effect: \"Allow\",\n Action: [\"lambda:InvokeFunction\"],\n Resource: pulumi.interpolate`arn:aws:lambda:${awsRegion}:${awsAccountId}:function:*`\n }\n ]\n };\n\n return app.addResource(aws.iam.Policy, {\n name: \"SyncSystemLambdaPolicy\",\n config: {\n description: \"This policy enables access to Dynamodb, S3 and Lambda.\",\n policy\n }\n });\n}\n"],"names":["SyncSystemLambda","createAppModule","app","_","policy","createSyncSystemLambdaPolicy","role","createLambdaRole","syncSystemLambda","aws","LAMBDA_RUNTIME","pulumi","path","getCommonLambdaEnvVariables","value","VpcConfig","params","primary","secondary","dynamoDbTable","SyncSystemDynamo","awsAccountId","getAwsAccountId","awsRegion","getAwsRegion"],"mappings":";;;;;;;;;AAgBO,MAAMA,mBAAmBC,gBAAgB;IAC5C,MAAM;IACN,QAAOC,GAAc,EAAEC,CAAyB;QAC5C,MAAMC,SAASC,6BAA6B;YACxCH;YAEA,SAAS;gBACL,qBAAqB;gBACrB,kBAAkB;YACtB;YACA,WAAW;gBACP,qBAAqB;gBACrB,kBAAkB;YACtB;QACJ;QACA,MAAMI,OAAOC,iBAAiBL,KAAK;YAC/B,MAAM;YACN,QAAQE,OAAO,MAAM;QACzB;QAEA,MAAMI,mBAAmBN,IAAI,WAAW,CAACO,uCAAAA,MAAAA,CAAAA,QAAmB,EAAE;YAC1D,MAAM;YACN,QAAQ;gBACJ,SAASC;gBACT,SAAS;gBACT,MAAMJ,KAAK,MAAM,CAAC,GAAG;gBACrB,SAAS;gBACT,YAAY;gBACZ,MAAM,IAAIK,0CAAAA,KAAAA,CAAAA,YAAyB,CAAC;oBAChC,KAAK,IAAIA,0CAAAA,KAAAA,CAAAA,WAAwB,CAC7BC,K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AAAA,WAAkB,CAAC,aAAa,EAAEM,QAAQ,mBAAmB,CAAC,EAAE,CAAC;oBACjEN,0CAAAA,WAAkB,CAAC,aAAa,EAAEO,UAAU,mBAAmB,CAAC,CAAC;oBACjEP,0CAAAA,WAAkB,CAAC,aAAa,EAAEO,UAAU,mBAAmB,CAAC,EAAE,CAAC;iBACtE;YACL;YACA;gBACI,KAAK;gBACL,QAAQ;gBACR,QAAQ;oBAAC;iBAAwB;gBACjC,UAAUP,0CAAAA,WAAkB,CAAC,eAAe,EAAEY,UAAU,CAAC,EAAEF,aAAa,WAAW,CAAC;YACxF;SACH;IACL;IAEA,OAAOnB,IAAI,WAAW,CAACO,uCAAAA,GAAAA,CAAAA,MAAc,EAAE;QACnC,MAAM;QACN,QAAQ;YACJ,aAAa;YACbL;QACJ;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/syncSystem/createSyncSystemPulumiApp.js","sources":["../../../../src/pulumi/apps/syncSystem/createSyncSystemPulumiApp.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { createPulumiApp, isResourceOfType } from \"@webiny/pulumi\";\nimport { SyncSystemSQS } from \"./SyncSystemSQS.js\";\nimport { SyncSystemResolverLambda } from \"./SyncSystemResolverLambda.js\";\nimport type { IGetSyncSystemOutputResult, PulumiOutput } from \"./types.js\";\nimport { APPS_SYNC_SYSTEM_PATH } from \"./constants.js\";\nimport { SyncSystemEventBus } from \"./SyncSystemEventBus.js\";\nimport { customApp } from \"./customApp.js\";\nimport { SyncSystemDynamoDb } from \"~/pulumi/apps/syncSystem/SyncSystemDynamoDb.js\";\nimport { SyncSystemWorkerLambda } from \"~/pulumi/apps/syncSystem/SyncSystemWorkerLambda.js\";\nimport { getProjectSdk } from \"@webiny/project\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { applyAwsResourceTags } from \"~/pulumi/apps/awsUtils.js\";\n\nexport function createSyncSystemPulumiApp() {\n return createPulumiApp({\n name: \"sync\",\n path: APPS_SYNC_SYSTEM_PATH,\n program: async app => {\n const sdk = await getProjectSdk();\n const projectConfig = await sdk.getProjectConfig();\n\n const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();\n\n const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);\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 usingAdvancedVpcParams =\n vpcExtensionsConfig && typeof vpcExtensionsConfig !== \"boolean\";\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return;\n }\n\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(useExistingVpc!.lambdaFunctionsVpcConfig);\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.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n\n return;\n });\n // <-------------------- Enterprise end -------------------->\n\n const protect = app.env.isProduction;\n const regionApp = customApp({\n app,\n protect\n });\n /**\n * Sync System services.\n */\n const { sqsQueue } = regionApp.addModule(SyncSystemSQS);\n const dynamoDb = regionApp.addModule(SyncSystemDynamoDb);\n\n const workerLambda = regionApp.addModule(SyncSystemWorkerLambda);\n\n const resolverLambda = regionApp.addModule(SyncSystemResolverLambda);\n const { eventBusRule, eventBus, eventBusTarget, eventBusPolicy } =\n regionApp.addModule(SyncSystemEventBus);\n\n const output: PulumiOutput<IGetSyncSystemOutputResult> = {\n /**\n * Region provider.\n */\n region: pulumi.output(process.env.AWS_REGION as string),\n /**\n * SyncSystemSQS\n */\n sqsUrl: sqsQueue.output.url,\n sqsArn: sqsQueue.output.arn,\n sqsName: sqsQueue.output.name,\n /**\n * DynamoDB\n */\n dynamoDbArn: dynamoDb.output.arn,\n dynamoDbName: dynamoDb.output.name,\n dynamoDbHashKey: dynamoDb.output.hashKey,\n dynamoDbRangeKey: dynamoDb.output.rangeKey as pulumi.Output<string>,\n /**\n * SyncSystemResolverLambda\n */\n resolverLambdaArn: resolverLambda.lambda.output.arn,\n resolverLambdaName: resolverLambda.lambda.output.name,\n resolverLambdaRoleArn: resolverLambda.role.output.arn,\n resolverLambdaRoleName: resolverLambda.role.output.name,\n resolverLambdaRoleId: resolverLambda.role.output.id,\n resolverLambdaPolicyArn: resolverLambda.policy.output.arn,\n resolverLambdaPolicyName: resolverLambda.policy.output.name,\n resolverLambdaPolicyId: resolverLambda.policy.output.id,\n resolverLambdaEventSourceMappingArn: resolverLambda.eventSourceMapping.output.arn,\n resolverLambdaEventSourceMappingId: resolverLambda.eventSourceMapping.output.id,\n // # We can safely cast as we know that the property exists.\n resolverLambdaEventSourceMappingEventSourceArn: resolverLambda.eventSourceMapping\n .output.eventSourceArn as pulumi.Output<string>,\n /**\n * SyncSystemWorkerLambda\n */\n workerLambdaArn: workerLambda.lambda.output.arn,\n workerLambdaName: workerLambda.lambda.output.name,\n workerLambdaRoleArn: workerLambda.role.output.arn,\n workerLambdaRoleName: workerLambda.role.output.name,\n /**\n * SyncSystemEventBus\n */\n eventBusArn: eventBus.output.arn,\n eventBusName: eventBus.output.name,\n eventBusRuleArn: eventBusRule.output.arn,\n eventBusRuleName: eventBusRule.output.id,\n eventBusTargetArn: eventBusTarget.output.arn,\n eventBusPolicyId: eventBusPolicy.output.id,\n eventBusPolicyUrn: eventBusPolicy.output.urn,\n eventBusPolicyQueueUrl: eventBusPolicy.output.queueUrl\n };\n app.addOutputs(output);\n\n // Applies internal and user-defined AWS tags.\n await applyAwsResourceTags(\"sync\");\n\n return {\n sqs: sqsQueue.output,\n dynamoDb: dynamoDb.output,\n eventBus: eventBus.output,\n eventBusRule: eventBusRule.output,\n eventBusTarget: eventBusTarget.output,\n eventBusPolicy: eventBusPolicy.output,\n /**\n * Worker Lambda - used to resolve actions triggered by the resolver Lambda.\n */\n workerLambda: workerLambda.lambda.output,\n workerLambdaRole: workerLambda.role.output,\n /**\n * Resolver Lambda - gets hit by SQS and resolves the data.\n */\n resolverLambda: resolverLambda.lambda.output,\n resolverLambdaRole: resolverLambda.role.output,\n resolverLambdaPolicy: resolverLambda.policy.output,\n resolverLambdaEventSourceMapping: resolverLambda.eventSourceMapping.output,\n /**\n * Systems we are connecting together.\n */\n primary: {},\n secondary: {}\n };\n }\n });\n}\n"],"names":["createSyncSystemPulumiApp","createPulumiApp","APPS_SYNC_SYSTEM_PATH","app","sdk","getProjectSdk","projectConfig","pulumiResourceNamePrefix","vpcExtensionsConfig","getVpcConfigFromExtension","resource","usingAdvancedVpcParams","onResource","addResource","useExistingVpc","Error","isResourceOfType","aws","canUseVpc","protect","regionApp","customApp","sqsQueue","SyncSystemSQS","dynamoDb","SyncSystemDynamoDb","workerLambda","SyncSystemWorkerLambda","resolverLambda","SyncSystemResolverLambda","eventBusRule","eventBus","eventBusTarget","eventBusPolicy","SyncSystemEventBus","output","pulumi","process","applyAwsResourceTags"],"mappings":";;;;;;;;;;;;;AAeO,SAASA;IACZ,OAAOC,gBAAgB;QACnB,MAAM;QACN,MAAMC;QACN,SAAS,OAAMC;YACX,MAAMC,MAAM,MAAMC;Y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":["import * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport { createPulumiApp, isResourceOfType } from \"@webiny/pulumi\";\nimport { SyncSystemSQS } from \"./SyncSystemSQS.js\";\nimport { SyncSystemResolverLambda } from \"./SyncSystemResolverLambda.js\";\nimport type { IGetSyncSystemOutputResult, PulumiOutput } from \"./types.js\";\nimport { APPS_SYNC_SYSTEM_PATH } from \"./constants.js\";\nimport { SyncSystemEventBus } from \"./SyncSystemEventBus.js\";\nimport { customApp } from \"./customApp.js\";\nimport { SyncSystemDynamoDb } from \"~/pulumi/apps/syncSystem/SyncSystemDynamoDb.js\";\nimport { SyncSystemWorkerLambda } from \"~/pulumi/apps/syncSystem/SyncSystemWorkerLambda.js\";\nimport { getProjectSdk } from \"@webiny/project\";\nimport { getVpcConfigFromExtension } from \"~/pulumi/apps/extensions/getVpcConfigFromExtension.js\";\nimport { applyAwsResourceTags } from \"~/pulumi/apps/awsUtils.js\";\n\nexport function createSyncSystemPulumiApp() {\n return createPulumiApp({\n name: \"sync\",\n path: APPS_SYNC_SYSTEM_PATH,\n program: async app => {\n const sdk = await getProjectSdk();\n const projectConfig = await sdk.getProjectConfig();\n\n const pulumiResourceNamePrefix = await sdk.getPulumiResourceNamePrefix();\n\n const vpcExtensionsConfig = getVpcConfigFromExtension(projectConfig);\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 usingAdvancedVpcParams =\n vpcExtensionsConfig && typeof vpcExtensionsConfig !== \"boolean\";\n\n // Not using advanced VPC params? Then immediately exit.\n if (!usingAdvancedVpcParams) {\n return;\n }\n\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(useExistingVpc!.lambdaFunctionsVpcConfig);\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.AWSLambdaVPCAccessExecutionRole\n }\n });\n }\n }\n });\n }\n\n return;\n });\n // <-------------------- Enterprise end -------------------->\n\n const protect = app.env.isProduction;\n const regionApp = customApp({\n app,\n protect\n });\n /**\n * Sync System services.\n */\n const { sqsQueue } = regionApp.addModule(SyncSystemSQS);\n const dynamoDb = regionApp.addModule(SyncSystemDynamoDb);\n\n const workerLambda = regionApp.addModule(SyncSystemWorkerLambda);\n\n const resolverLambda = regionApp.addModule(SyncSystemResolverLambda);\n const { eventBusRule, eventBus, eventBusTarget, eventBusPolicy } =\n regionApp.addModule(SyncSystemEventBus);\n\n const output: PulumiOutput<IGetSyncSystemOutputResult> = {\n /**\n * Region provider.\n */\n region: pulumi.output(process.env.AWS_REGION as string),\n /**\n * SyncSystemSQS\n */\n sqsUrl: sqsQueue.output.url,\n sqsArn: sqsQueue.output.arn,\n sqsName: sqsQueue.output.name,\n /**\n * DynamoDB\n */\n dynamoDbArn: dynamoDb.output.arn,\n dynamoDbName: dynamoDb.output.name,\n dynamoDbHashKey: dynamoDb.output.hashKey,\n dynamoDbRangeKey: dynamoDb.output.rangeKey as pulumi.Output<string>,\n /**\n * SyncSystemResolverLambda\n */\n resolverLambdaArn: resolverLambda.lambda.output.arn,\n resolverLambdaName: resolverLambda.lambda.output.name,\n resolverLambdaRoleArn: resolverLambda.role.output.arn,\n resolverLambdaRoleName: resolverLambda.role.output.name,\n resolverLambdaRoleId: resolverLambda.role.output.id,\n resolverLambdaPolicyArn: resolverLambda.policy.output.arn,\n resolverLambdaPolicyName: resolverLambda.policy.output.name,\n resolverLambdaPolicyId: resolverLambda.policy.output.id,\n resolverLambdaEventSourceMappingArn: resolverLambda.eventSourceMapping.output.arn,\n resolverLambdaEventSourceMappingId: resolverLambda.eventSourceMapping.output.id,\n // # We can safely cast as we know that the property exists.\n resolverLambdaEventSourceMappingEventSourceArn: resolverLambda.eventSourceMapping\n .output.eventSourceArn as pulumi.Output<string>,\n /**\n * SyncSystemWorkerLambda\n */\n workerLambdaArn: workerLambda.lambda.output.arn,\n workerLambdaName: workerLambda.lambda.output.name,\n workerLambdaRoleArn: workerLambda.role.output.arn,\n workerLambdaRoleName: workerLambda.role.output.name,\n /**\n * SyncSystemEventBus\n */\n eventBusArn: eventBus.output.arn,\n eventBusName: eventBus.output.name,\n eventBusRuleArn: eventBusRule.output.arn,\n eventBusRuleName: eventBusRule.output.id,\n eventBusTargetArn: eventBusTarget.output.arn,\n eventBusPolicyId: eventBusPolicy.output.id,\n eventBusPolicyUrn: eventBusPolicy.output.urn,\n eventBusPolicyQueueUrl: eventBusPolicy.output.queueUrl\n };\n app.addOutputs(output);\n\n // Applies internal and user-defined AWS tags.\n await applyAwsResourceTags(\"sync\");\n\n return {\n sqs: sqsQueue.output,\n dynamoDb: dynamoDb.output,\n eventBus: eventBus.output,\n eventBusRule: eventBusRule.output,\n eventBusTarget: eventBusTarget.output,\n eventBusPolicy: eventBusPolicy.output,\n /**\n * Worker Lambda - used to resolve actions triggered by the resolver Lambda.\n */\n workerLambda: workerLambda.lambda.output,\n workerLambdaRole: workerLambda.role.output,\n /**\n * Resolver Lambda - gets hit by SQS and resolves the data.\n */\n resolverLambda: resolverLambda.lambda.output,\n resolverLambdaRole: resolverLambda.role.output,\n resolverLambdaPolicy: resolverLambda.policy.output,\n resolverLambdaEventSourceMapping: resolverLambda.eventSourceMapping.output,\n /**\n * Systems we are connecting together.\n */\n primary: {},\n secondary: {}\n };\n }\n });\n}\n"],"names":["createSyncSystemPulumiApp","createPulumiApp","APPS_SYNC_SYSTEM_PATH","app","sdk","getProjectSdk","projectConfig","pulumiResourceNamePrefix","vpcExtensionsConfig","getVpcConfigFromExtension","resource","usingAdvancedVpcParams","onResource","addResource","useExistingVpc","Error","isResourceOfType","aws","canUseVpc","protect","regionApp","customApp","sqsQueue","SyncSystemSQS","dynamoDb","SyncSystemDynamoDb","workerLambda","SyncSystemWorkerLambda","resolverLambda","SyncSystemResolverLambda","eventBusRule","eventBus","eventBusTarget","eventBusPolicy","SyncSystemEventBus","output","pulumi","process","applyAwsResourceTags"],"mappings":";;;;;;;;;;;;;AAeO,SAASA;IACZ,OAAOC,gBAAgB;QACnB,MAAM;QACN,MAAMC;QACN,SAAS,OAAMC;YACX,MAAMC,MAAM,MAAMC;YAClB,MAAMC,gBAAgB,MAAMF,IAAI,gBAAgB;YAEhD,MAAMG,2BAA2B,MAAMH,IAAI,2BAA2B;YAEtE,MAAMI,sBAAsBC,0BAA0BH;YAEtD,IAAIC,0BACAJ,IAAI,UAAU,CAACO,CAAAA;gBACX,IAAI,CAACA,SAAS,IAAI,CAAC,UAAU,CAACH,2BAC1BG,SAAS,IAAI,GAAG,GAAGH,2BAA2BG,SAAS,IAAI,EAAE;YAErE;YAIJP,IAAI,UAAU,CAAC;gBACX,MAAMQ,yBACFH,uBAAuB,AAA+B,aAA/B,OAAOA;gBAGlC,IAAI,CAACG,wBACD;gBAGJ,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAE,GAAGV;gBACpC,MAAM,EAAEW,cAAc,EAAE,GAAGN;gBAG3B,IAAIM,gBAAgB;oBAChB,IAAI,CAACA,eAAe,wBAAwB,EACxC,MAAM,IAAIC,MACN;oBAIRH,WAAWF,CAAAA;wBACP,IAAIM,iBAAiBN,UAAUO,uCAAAA,MAAAA,CAAAA,QAAmB,GAAG;4B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AM;gBACpB,UAAUE,SAAS,MAAM;gBACzB,UAAUO,SAAS,MAAM;gBACzB,cAAcD,aAAa,MAAM;gBACjC,gBAAgBE,eAAe,MAAM;gBACrC,gBAAgBC,eAAe,MAAM;gBAIrC,cAAcP,aAAa,MAAM,CAAC,MAAM;gBACxC,kBAAkBA,aAAa,IAAI,CAAC,MAAM;gBAI1C,gBAAgBE,eAAe,MAAM,CAAC,MAAM;gBAC5C,oBAAoBA,eAAe,IAAI,CAAC,MAAM;gBAC9C,sBAAsBA,eAAe,MAAM,CAAC,MAAM;gBAClD,kCAAkCA,eAAe,kBAAkB,CAAC,MAAM;gBAI1E,SAAS,CAAC;gBACV,WAAW,CAAC;YAChB;QACJ;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/utils/dynamodb.js","sources":["../../../src/pulumi/utils/dynamodb.ts"],"sourcesContent":["export interface IDynamoDbConfigAttribute {\n name: string;\n type: \"S\";\n}\n\nexport interface IDynamoDbConfigGlobalSecondaryIndex {\n name: string;\n hashKey: string;\n rangeKey: string;\n projectionType: \"ALL\";\n}\n\nexport const createDynamoDbGSI = (indexes: string[]) => {\n return {\n withAttributes(original: IDynamoDbConfigAttribute[]): IDynamoDbConfigAttribute[] {\n return indexes.reduce<IDynamoDbConfigAttribute[]>((collection, name) => {\n collection.push(\n {\n name: `${name}_PK`,\n type: \"S\"\n },\n {\n name: `${name}_SK`,\n type: \"S\"\n }\n );\n\n return collection;\n }, original);\n },\n withGlobalSecondaryIndexes(\n original: IDynamoDbConfigGlobalSecondaryIndex[]\n ): IDynamoDbConfigGlobalSecondaryIndex[] {\n return indexes.reduce((collection, name) => {\n original.push({\n name,\n hashKey: `${name}_PK`,\n rangeKey: `${name}_SK`,\n projectionType: \"ALL\"\n });\n return collection;\n }, original);\n }\n };\n};\n"],"names":["createDynamoDbGSI","indexes","original","collection","name"],"mappings":"AAYO,MAAMA,oBAAoB,CAACC,UACvB;QACH,gBAAeC,QAAoC;YAC/C,OAAOD,QAAQ,MAAM,CAA6B,CAACE,YAAYC;gBAC3DD,WAAW,IAAI,CACX;oBACI,MAAM,GAAGC,KAAK,GAAG,CAAC;oBAClB,MAAM;gBACV,GACA;oBACI,MAAM,GAAGA,KAAK,GAAG,CAAC;oBAClB,MAAM;gBACV;gBAGJ,OAAOD;YACX,GAAGD;QACP;QACA,4BACIA,QAA+C;YAE/C,OAAOD,QAAQ,MAAM,CAAC,CAACE,YAAYC;gBAC/BF,SAAS,IAAI,CAAC;oBACVE;oBACA,SAAS,GAAGA,KAAK,GAAG,CAAC;oBACrB,UAAU,GAAGA,KAAK,GAAG,CAAC;oBACtB,gBAAgB;gBACpB;gBACA,OAAOD;YACX,GAAGD;QACP;IACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/utils/dynamodb.js","sources":["../../../src/pulumi/utils/dynamodb.ts"],"sourcesContent":["export interface IDynamoDbConfigAttribute {\n name: string;\n type: \"S\";\n}\n\nexport interface IDynamoDbConfigGlobalSecondaryIndex {\n name: string;\n hashKey: string;\n rangeKey: string;\n projectionType: \"ALL\";\n}\n\nexport const createDynamoDbGSI = (indexes: string[]) => {\n return {\n withAttributes(original: IDynamoDbConfigAttribute[]): IDynamoDbConfigAttribute[] {\n return indexes.reduce<IDynamoDbConfigAttribute[]>((collection, name) => {\n collection.push(\n {\n name: `${name}_PK`,\n type: \"S\"\n },\n {\n name: `${name}_SK`,\n type: \"S\"\n }\n );\n\n return collection;\n }, original);\n },\n withGlobalSecondaryIndexes(\n original: IDynamoDbConfigGlobalSecondaryIndex[]\n ): IDynamoDbConfigGlobalSecondaryIndex[] {\n return indexes.reduce((collection, name) => {\n original.push({\n name,\n hashKey: `${name}_PK`,\n rangeKey: `${name}_SK`,\n projectionType: \"ALL\"\n });\n return collection;\n }, original);\n }\n };\n};\n"],"names":["createDynamoDbGSI","indexes","original","collection","name"],"mappings":"AAYO,MAAMA,oBAAoB,CAACC,UACvB;QACH,gBAAeC,QAAoC;YAC/C,OAAOD,QAAQ,MAAM,CAA6B,CAACE,YAAYC;gBAC3DD,WAAW,IAAI,CACX;oBACI,MAAM,GAAGC,KAAK,GAAG,CAAC;oBAClB,MAAM;gBACV,GACA;oBACI,MAAM,GAAGA,KAAK,GAAG,CAAC;oBAClB,MAAM;gBACV;gBAGJ,OAAOD;YACX,GAAGD;QACP;QACA,4BACIA,QAA+C;YAE/C,OAAOD,QAAQ,MAAM,CAAC,CAACE,YAAYC;gBAC/BF,SAAS,IAAI,CAAC;oBACVE;oBACA,SAAS,GAAGA,KAAK,GAAG,CAAC;oBACrB,UAAU,GAAGA,KAAK,GAAG,CAAC;oBACtB,gBAAgB;gBACpB;gBACA,OAAOD;YACX,GAAGD;QACP;IACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/utils/uploadFolderToS3.js","sources":["../../../src/pulumi/utils/uploadFolderToS3.ts"],"sourcesContent":["import fs from \"fs\";\nimport type { PresignedPostOptions } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { S3Client, HeadObjectCommand } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport mime from \"mime\";\nimport chunk from \"lodash/chunk.js\";\nimport { relative } from \"path\";\nimport { crawlDirectory } from \"./crawlDirectory.js\";\nimport { getPresignedPost } from \"./getPresignedPost.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\nimport crypto from \"crypto\";\n\nfunction getFileChecksum(file: string): Promise<string> {\n const hash = crypto.createHash(\"md5\");\n\n return new Promise(resolve => {\n const stream = fs.createReadStream(file);\n stream.on(\"data\", function (data: any) {\n hash.update(data, \"utf8\");\n });\n\n stream.on(\"end\", function () {\n resolve(hash.digest(\"hex\"));\n });\n });\n}\n\nexport interface Paths {\n full: string;\n relative: string;\n}\n\nexport type CacheControls = Array<{\n pattern: RegExp;\n value: string;\n}>;\n\nexport interface UploadFolderToS3Params {\n // Path to the folder that needs to be uploaded.\n path: string;\n\n // Object ACL.\n acl: string;\n\n // A callback that gets called every time a file has been uploaded successfully.\n onFileUploadSuccess: (params: { paths: Paths }) => void;\n\n // A callback that gets called every time a file has not been uploaded successfully.\n onFileUploadError: (params: { paths: Paths; error: Error }) => void;\n\n // A callback that gets called every time a file upload has been skipped.\n onFileUploadSkip: (params: { paths: Paths }) => void;\n\n // Target bucket\n bucket: PresignedPostOptions[\"Bucket\"];\n\n // Cache control to apply to each uploaded file\n cacheControl?: string | CacheControls;\n}\n\nexport const uploadFolderToS3 = async ({\n path: root,\n bucket,\n onFileUploadSuccess,\n onFileUploadError,\n onFileUploadSkip,\n // For backwards compatibility, we need to leave ACL on \"public-read\".\n acl = \"public-read\",\n cacheControl = \"max-age=31536000\"\n}: UploadFolderToS3Params) => {\n const s3 = new S3Client({\n region: getEnvVariableAwsRegion()\n });\n\n if (!fs.existsSync(root)) {\n throw new Error(\"Cannot continue, folder does not exist.\");\n }\n\n const paths: string[] = [];\n\n await crawlDirectory(root, async (path: string) => {\n paths.push(path);\n });\n\n const pathsChunks = chunk(paths, 20);\n\n const cacheControls: CacheControls = [];\n if (typeof cacheControl === \"string\") {\n cacheControls.push({ pattern: /.*/, value: cacheControl });\n } else if (Array.isArray(cacheControls)) {\n cacheControls.push(...cacheControl);\n }\n\n for (let i = 0; i < pathsChunks.length; i++) {\n const chunk = pathsChunks[i];\n\n const promises = [];\n for (let j = 0; j < chunk.length; j++) {\n const path = chunk[j];\n\n promises.push(\n new Promise<void>(async resolve => {\n // We also replace \"\\\" with \"/\", which is a path separator on Windows' CMD or Powershell.\n const key = relative(root, path).replace(/\\\\/g, \"/\");\n try {\n // Get file checksum so that we can check if a file needs to be uploaded or not.\n const checksum = await getFileChecksum(path);\n\n let skipUpload = false;\n try {\n const existingObject = await s3.send(\n new HeadObjectCommand({\n Bucket: bucket,\n Key: key\n })\n );\n\n if (existingObject.Metadata?.checksum === checksum) {\n skipUpload = true;\n }\n } catch {\n // Do nothing.\n }\n\n if (skipUpload) {\n if (typeof onFileUploadSkip === \"function\") {\n await onFileUploadSkip({ paths: { full: path, relative: key } });\n }\n } else {\n const cacheControl = cacheControls.find(item => item.pattern.test(key));\n const contentType = mime.getType(path);\n\n const { url, fields } = await getPresignedPost({\n bucket,\n key,\n acl,\n checksum,\n contentType,\n cacheControl: cacheControl ? cacheControl.value : undefined\n });\n\n const data: Record<string, string | Buffer> = {\n ...fields,\n \"Content-Type\": contentType || \"\",\n \"X-Amz-Meta-Checksum\": checksum,\n file: fs.readFileSync(path)\n };\n\n if (cacheControl) {\n data[\"Cache-Control\"] = cacheControl.value;\n }\n\n const formData = new FormData();\n for (const key in data) {\n const value = new Blob([Buffer.from(data[key])]);\n formData.append(key, value);\n }\n\n const res = await fetch(url, {\n method: \"POST\",\n body: formData\n });\n\n if (res.status > 299) {\n throw new Error(`${res.statusText}\\n${await res.text()}`);\n }\n\n if (typeof onFileUploadSuccess === \"function\") {\n await onFileUploadSuccess({ paths: { full: path, relative: key } });\n }\n }\n resolve();\n } catch (e) {\n if (typeof onFileUploadError === \"function\") {\n await onFileUploadError({\n paths: { full: path, relative: key },\n error: e\n });\n }\n resolve();\n }\n })\n );\n }\n\n await Promise.all(promises);\n }\n};\n"],"names":["getFileChecksum","file","hash","crypto","Promise","resolve","stream","fs","data","uploadFolderToS3","root","bucket","onFileUploadSuccess","onFileUploadError","onFileUploadSkip","acl","cacheControl","s3","S3Client","getEnvVariableAwsRegion","Error","paths","crawlDirectory","path","pathsChunks","chunk","cacheControls","Array","i","promises","j","key","relative","checksum","skipUpload","existingObject","HeadObjectCommand","item","contentType","mime","url","fields","getPresignedPost","undefined","formData","FormData","value","Blob","Buffer","res","fetch","e"],"mappings":";;;;;;;;;AAWA,SAASA,gBAAgBC,IAAY;IACjC,MAAMC,OAAOC,SAAAA,UAAiB,CAAC;IAE/B,OAAO,IAAIC,QAAQC,CAAAA;QACf,MAAMC,SAASC,GAAG,gBAAgB,CAACN;QACnCK,OAAO,EAAE,CAAC,QAAQ,SAAUE,IAAS;Y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AO8C,GAAG;oBACR,IAAI,AAA6B,cAA7B,OAAOtC,mBACP,MAAMA,kBAAkB;wBACpB,OAAO;4BAAE,MAAMU;4BAAM,UAAUQ;wBAAI;wBACnC,OAAOoB;oBACX;oBAEJ9C;gBACJ;YACJ;QAER;QAEA,MAAMD,QAAQ,GAAG,CAACyB;IACtB;AACJ"}
|
|
1
|
+
{"version":3,"file":"pulumi/utils/uploadFolderToS3.js","sources":["../../../src/pulumi/utils/uploadFolderToS3.ts"],"sourcesContent":["import fs from \"fs\";\nimport type { PresignedPostOptions } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport { S3Client, HeadObjectCommand } from \"@webiny/aws-sdk/client-s3/index.js\";\nimport mime from \"mime\";\nimport chunk from \"lodash/chunk.js\";\nimport { relative } from \"path\";\nimport { crawlDirectory } from \"./crawlDirectory.js\";\nimport { getPresignedPost } from \"./getPresignedPost.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\nimport crypto from \"crypto\";\n\nfunction getFileChecksum(file: string): Promise<string> {\n const hash = crypto.createHash(\"md5\");\n\n return new Promise(resolve => {\n const stream = fs.createReadStream(file);\n stream.on(\"data\", function (data: any) {\n hash.update(data, \"utf8\");\n });\n\n stream.on(\"end\", function () {\n resolve(hash.digest(\"hex\"));\n });\n });\n}\n\nexport interface Paths {\n full: string;\n relative: string;\n}\n\nexport type CacheControls = Array<{\n pattern: RegExp;\n value: string;\n}>;\n\nexport interface UploadFolderToS3Params {\n // Path to the folder that needs to be uploaded.\n path: string;\n\n // Object ACL.\n acl: string;\n\n // A callback that gets called every time a file has been uploaded successfully.\n onFileUploadSuccess: (params: { paths: Paths }) => void;\n\n // A callback that gets called every time a file has not been uploaded successfully.\n onFileUploadError: (params: { paths: Paths; error: Error }) => void;\n\n // A callback that gets called every time a file upload has been skipped.\n onFileUploadSkip: (params: { paths: Paths }) => void;\n\n // Target bucket\n bucket: PresignedPostOptions[\"Bucket\"];\n\n // Cache control to apply to each uploaded file\n cacheControl?: string | CacheControls;\n}\n\nexport const uploadFolderToS3 = async ({\n path: root,\n bucket,\n onFileUploadSuccess,\n onFileUploadError,\n onFileUploadSkip,\n // For backwards compatibility, we need to leave ACL on \"public-read\".\n acl = \"public-read\",\n cacheControl = \"max-age=31536000\"\n}: UploadFolderToS3Params) => {\n const s3 = new S3Client({\n region: getEnvVariableAwsRegion()\n });\n\n if (!fs.existsSync(root)) {\n throw new Error(\"Cannot continue, folder does not exist.\");\n }\n\n const paths: string[] = [];\n\n await crawlDirectory(root, async (path: string) => {\n paths.push(path);\n });\n\n const pathsChunks = chunk(paths, 20);\n\n const cacheControls: CacheControls = [];\n if (typeof cacheControl === \"string\") {\n cacheControls.push({ pattern: /.*/, value: cacheControl });\n } else if (Array.isArray(cacheControls)) {\n cacheControls.push(...cacheControl);\n }\n\n for (let i = 0; i < pathsChunks.length; i++) {\n const chunk = pathsChunks[i];\n\n const promises = [];\n for (let j = 0; j < chunk.length; j++) {\n const path = chunk[j];\n\n promises.push(\n new Promise<void>(async resolve => {\n // We also replace \"\\\" with \"/\", which is a path separator on Windows' CMD or Powershell.\n const key = relative(root, path).replace(/\\\\/g, \"/\");\n try {\n // Get file checksum so that we can check if a file needs to be uploaded or not.\n const checksum = await getFileChecksum(path);\n\n let skipUpload = false;\n try {\n const existingObject = await s3.send(\n new HeadObjectCommand({\n Bucket: bucket,\n Key: key\n })\n );\n\n if (existingObject.Metadata?.checksum === checksum) {\n skipUpload = true;\n }\n } catch {\n // Do nothing.\n }\n\n if (skipUpload) {\n if (typeof onFileUploadSkip === \"function\") {\n await onFileUploadSkip({ paths: { full: path, relative: key } });\n }\n } else {\n const cacheControl = cacheControls.find(item => item.pattern.test(key));\n const contentType = mime.getType(path);\n\n const { url, fields } = await getPresignedPost({\n bucket,\n key,\n acl,\n checksum,\n contentType,\n cacheControl: cacheControl ? cacheControl.value : undefined\n });\n\n const data: Record<string, string | Buffer> = {\n ...fields,\n \"Content-Type\": contentType || \"\",\n \"X-Amz-Meta-Checksum\": checksum,\n file: fs.readFileSync(path)\n };\n\n if (cacheControl) {\n data[\"Cache-Control\"] = cacheControl.value;\n }\n\n const formData = new FormData();\n for (const key in data) {\n const value = new Blob([Buffer.from(data[key])]);\n formData.append(key, value);\n }\n\n const res = await fetch(url, {\n method: \"POST\",\n body: formData\n });\n\n if (res.status > 299) {\n throw new Error(`${res.statusText}\\n${await res.text()}`);\n }\n\n if (typeof onFileUploadSuccess === \"function\") {\n await onFileUploadSuccess({ paths: { full: path, relative: key } });\n }\n }\n resolve();\n } catch (e) {\n if (typeof onFileUploadError === \"function\") {\n await onFileUploadError({\n paths: { full: path, relative: key },\n error: e\n });\n }\n resolve();\n }\n })\n );\n }\n\n await Promise.all(promises);\n }\n};\n"],"names":["getFileChecksum","file","hash","crypto","Promise","resolve","stream","fs","data","uploadFolderToS3","root","bucket","onFileUploadSuccess","onFileUploadError","onFileUploadSkip","acl","cacheControl","s3","S3Client","getEnvVariableAwsRegion","Error","paths","crawlDirectory","path","pathsChunks","chunk","cacheControls","Array","i","promises","j","key","relative","checksum","skipUpload","existingObject","HeadObjectCommand","item","contentType","mime","url","fields","getPresignedPost","undefined","formData","FormData","value","Blob","Buffer","res","fetch","e"],"mappings":";;;;;;;;;AAWA,SAASA,gBAAgBC,IAAY;IACjC,MAAMC,OAAOC,SAAAA,UAAiB,CAAC;IAE/B,OAAO,IAAIC,QAAQC,CAAAA;QACf,MAAMC,SAASC,GAAG,gBAAgB,CAACN;QACnCK,OAAO,EAAE,CAAC,QAAQ,SAAUE,IAAS;YACjCN,KAAK,MAAM,CAACM,MAAM;QACtB;QAEAF,OAAO,EAAE,CAAC,OAAO;YACbD,QAAQH,KAAK,MAAM,CAAC;QACxB;IACJ;AACJ;AAmCO,MAAMO,mBAAmB,OAAO,EACnC,MAAMC,IAAI,EACVC,MAAM,EACNC,mBAAmB,EACnBC,iBAAiB,EACjBC,gBAAgB,EAEhBC,MAAM,aAAa,EACnBC,eAAe,kBAAkB,EACZ;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