@webiny/project-aws 6.6.0-alpha.7 → 6.6.0-alpha.8

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.
@@ -1,11 +1,11 @@
1
1
  import { BeforeDeploy, LoggerService } from "@webiny/project/abstractions/index.js";
2
2
  import { GracefulError } from "@webiny/project";
3
- import { STS } from "@webiny/aws-sdk/client-sts/index.js";
4
3
  class EnsureAwsCredentialsBeforeDeployImpl {
5
4
  constructor(loggerService){
6
5
  this.loggerService = loggerService;
7
6
  }
8
7
  async execute() {
8
+ const { STS } = await import("@webiny/aws-sdk/client-sts/index.js");
9
9
  process.env.AWS_SDK_LOAD_CONFIG = "true";
10
10
  const sts = new STS({});
11
11
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js","sources":["../../../src/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.ts"],"sourcesContent":["import { BeforeDeploy, LoggerService } from \"@webiny/project/abstractions/index.js\";\nimport { GracefulError } from \"@webiny/project\";\nimport { STS } from \"@webiny/aws-sdk/client-sts/index.js\";\n\nclass EnsureAwsCredentialsBeforeDeployImpl implements BeforeDeploy.Interface {\n constructor(private loggerService: LoggerService.Interface) {}\n\n async execute() {\n process.env.AWS_SDK_LOAD_CONFIG = \"true\";\n const sts = new STS({});\n\n try {\n await sts.getCallerIdentity({});\n } catch (err) {\n this.loggerService.debug({ err }, \"AWS credentials error.\");\n throw GracefulError.from(\n new Error(\"AWS credentials are not configured correctly.\"),\n 'No valid AWS credentials were found. Run \"aws configure\" or set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables before deploying. Learn more: https://webiny.link/aws-credentials'\n );\n }\n\n const region = await sts.config.region();\n if (!region) {\n throw GracefulError.from(\n new Error(\"AWS region is not defined.\"),\n \"No AWS region is set. Define the AWS_REGION environment variable or set a default region in your AWS profile. Learn more: https://webiny.link/aws-region\"\n );\n }\n\n process.env.AWS_REGION = region;\n\n const { accessKeyId } = await sts.config.credentials();\n const profile = process.env.AWS_PROFILE;\n\n if (profile) {\n this.loggerService.info(`Using profile \"${profile}\" in \"${region}\" region.`);\n } else {\n this.loggerService.info(`Using access key ID \"${accessKeyId}\" in \"${region}\" region.`);\n }\n }\n}\n\nexport const EnsureAwsCredentialsBeforeDeploy = BeforeDeploy.createImplementation({\n implementation: EnsureAwsCredentialsBeforeDeployImpl,\n dependencies: [LoggerService]\n});\n"],"names":["EnsureAwsCredentialsBeforeDeployImpl","loggerService","process","sts","STS","err","GracefulError","Error","region","accessKeyId","profile","EnsureAwsCredentialsBeforeDeploy","BeforeDeploy","LoggerService"],"mappings":";;;AAIA,MAAMA;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,UAAU;QACZC,QAAQ,GAAG,CAAC,mBAAmB,GAAG;QAClC,MAAMC,MAAM,IAAIC,IAAI,CAAC;QAErB,IAAI;YACA,MAAMD,IAAI,iBAAiB,CAAC,CAAC;QACjC,EAAE,OAAOE,KAAK;YACV,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;gBAAEA;YAAI,GAAG;YAClC,MAAMC,cAAc,IAAI,CACpB,IAAIC,MAAM,kDACV;QAER;QAEA,MAAMC,SAAS,MAAML,IAAI,MAAM,CAAC,MAAM;QACtC,IAAI,CAACK,QACD,MAAMF,cAAc,IAAI,CACpB,IAAIC,MAAM,+BACV;QAIRL,QAAQ,GAAG,CAAC,UAAU,GAAGM;QAEzB,MAAM,EAAEC,WAAW,EAAE,GAAG,MAAMN,IAAI,MAAM,CAAC,WAAW;QACpD,MAAMO,UAAUR,QAAQ,GAAG,CAAC,WAAW;QAEvC,IAAIQ,SACA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,eAAe,EAAEA,QAAQ,MAAM,EAAEF,OAAO,SAAS,CAAC;aAE3E,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAEC,YAAY,MAAM,EAAED,OAAO,SAAS,CAAC;IAE7F;AACJ;AAEO,MAAMG,mCAAmCC,aAAa,oBAAoB,CAAC;IAC9E,gBAAgBZ;IAChB,cAAc;QAACa;KAAc;AACjC"}
1
+ {"version":3,"file":"extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.js","sources":["../../../src/extensions/ProjectAws/EnsureAwsCredentialsBeforeDeploy.ts"],"sourcesContent":["import { BeforeDeploy, LoggerService } from \"@webiny/project/abstractions/index.js\";\nimport { GracefulError } from \"@webiny/project\";\n\nclass EnsureAwsCredentialsBeforeDeployImpl implements BeforeDeploy.Interface {\n constructor(private loggerService: LoggerService.Interface) {}\n\n async execute() {\n // Loaded here rather than at the top of the file. Validating the project config imports this\n // hook on every command, and only a deploy needs the STS client.\n const { STS } = await import(\"@webiny/aws-sdk/client-sts/index.js\");\n\n process.env.AWS_SDK_LOAD_CONFIG = \"true\";\n const sts = new STS({});\n\n try {\n await sts.getCallerIdentity({});\n } catch (err) {\n this.loggerService.debug({ err }, \"AWS credentials error.\");\n throw GracefulError.from(\n new Error(\"AWS credentials are not configured correctly.\"),\n 'No valid AWS credentials were found. Run \"aws configure\" or set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables before deploying. Learn more: https://webiny.link/aws-credentials'\n );\n }\n\n const region = await sts.config.region();\n if (!region) {\n throw GracefulError.from(\n new Error(\"AWS region is not defined.\"),\n \"No AWS region is set. Define the AWS_REGION environment variable or set a default region in your AWS profile. Learn more: https://webiny.link/aws-region\"\n );\n }\n\n process.env.AWS_REGION = region;\n\n const { accessKeyId } = await sts.config.credentials();\n const profile = process.env.AWS_PROFILE;\n\n if (profile) {\n this.loggerService.info(`Using profile \"${profile}\" in \"${region}\" region.`);\n } else {\n this.loggerService.info(`Using access key ID \"${accessKeyId}\" in \"${region}\" region.`);\n }\n }\n}\n\nexport const EnsureAwsCredentialsBeforeDeploy = BeforeDeploy.createImplementation({\n implementation: EnsureAwsCredentialsBeforeDeployImpl,\n dependencies: [LoggerService]\n});\n"],"names":["EnsureAwsCredentialsBeforeDeployImpl","loggerService","STS","process","sts","err","GracefulError","Error","region","accessKeyId","profile","EnsureAwsCredentialsBeforeDeploy","BeforeDeploy","LoggerService"],"mappings":";;AAGA,MAAMA;IACF,YAAoBC,aAAsC,CAAE;aAAxCA,aAAa,GAAbA;IAAyC;IAE7D,MAAM,UAAU;QAGZ,MAAM,EAAEC,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC;QAE7BC,QAAQ,GAAG,CAAC,mBAAmB,GAAG;QAClC,MAAMC,MAAM,IAAIF,IAAI,CAAC;QAErB,IAAI;YACA,MAAME,IAAI,iBAAiB,CAAC,CAAC;QACjC,EAAE,OAAOC,KAAK;YACV,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;gBAAEA;YAAI,GAAG;YAClC,MAAMC,cAAc,IAAI,CACpB,IAAIC,MAAM,kDACV;QAER;QAEA,MAAMC,SAAS,MAAMJ,IAAI,MAAM,CAAC,MAAM;QACtC,IAAI,CAACI,QACD,MAAMF,cAAc,IAAI,CACpB,IAAIC,MAAM,+BACV;QAIRJ,QAAQ,GAAG,CAAC,UAAU,GAAGK;QAEzB,MAAM,EAAEC,WAAW,EAAE,GAAG,MAAML,IAAI,MAAM,CAAC,WAAW;QACpD,MAAMM,UAAUP,QAAQ,GAAG,CAAC,WAAW;QAEvC,IAAIO,SACA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,eAAe,EAAEA,QAAQ,MAAM,EAAEF,OAAO,SAAS,CAAC;aAE3E,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAEC,YAAY,MAAM,EAAED,OAAO,SAAS,CAAC;IAE7F;AACJ;AAEO,MAAMG,mCAAmCC,aAAa,oBAAoB,CAAC;IAC9E,gBAAgBZ;IAChB,cAAc;QAACa;KAAc;AACjC"}
@@ -1,4 +1,3 @@
1
- import { InvokeCommand, LambdaClient } from "@webiny/aws-sdk/client-lambda/index.js";
2
1
  import { GetAppStackOutput } from "@webiny/project/abstractions/index.js";
3
2
  import { InvokeLambdaFunction } from "../abstractions/InvokeLambdaFunction.js";
4
3
  class InvokeLambdaFunctionImpl {
@@ -8,6 +7,7 @@ class InvokeLambdaFunctionImpl {
8
7
  async execute(params) {
9
8
  const stackOutput = await this.getAppStackOutput.execute("api");
10
9
  if (!stackOutput) throw new Error("Could not retrieve API stack output for Lambda invocation.");
10
+ const { LambdaClient, InvokeCommand } = await import("@webiny/aws-sdk/client-lambda/index.js");
11
11
  const { region } = stackOutput;
12
12
  const lambdaClient = new LambdaClient({
13
13
  region
@@ -1 +1 @@
1
- {"version":3,"file":"features/InvokeLambdaFunction.js","sources":["../../src/features/InvokeLambdaFunction.ts"],"sourcesContent":["import { LambdaClient, InvokeCommand } from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport { GetAppStackOutput } from \"@webiny/project/abstractions/index.js\";\nimport { InvokeLambdaFunction as InvokeLambdaFunctionAbstraction } from \"~/abstractions/InvokeLambdaFunction.js\";\nimport { IDefaultStackOutput } from \"~/pulumi/types.js\";\n\nexport class InvokeLambdaFunctionImpl implements InvokeLambdaFunctionAbstraction.Interface {\n constructor(private getAppStackOutput: GetAppStackOutput.Interface) {}\n\n async execute<T = any>(\n params: InvokeLambdaFunctionAbstraction.Params\n ): Promise<InvokeLambdaFunctionAbstraction.Result<T>> {\n // Get region from stack output\n const stackOutput = await this.getAppStackOutput.execute<IDefaultStackOutput>(\"api\");\n\n if (!stackOutput) {\n throw new Error(\"Could not retrieve API stack output for Lambda invocation.\");\n }\n\n const { region } = stackOutput;\n const lambdaClient = new LambdaClient({ region });\n\n const response = await lambdaClient.send(\n new InvokeCommand({\n FunctionName: params.functionName,\n InvocationType: params.invocationType || \"RequestResponse\",\n Payload: JSON.stringify(params.payload)\n })\n );\n\n const decoder = new TextDecoder(\"utf-8\");\n const payload = JSON.parse(decoder.decode(response.Payload));\n\n return {\n statusCode: response.StatusCode,\n payload\n };\n }\n}\n\nexport const InvokeLambdaFunction = InvokeLambdaFunctionAbstraction.createImplementation({\n implementation: InvokeLambdaFunctionImpl,\n dependencies: [GetAppStackOutput]\n});\n"],"names":["InvokeLambdaFunctionImpl","getAppStackOutput","params","stackOutput","Error","region","lambdaClient","LambdaClient","response","InvokeCommand","JSON","decoder","TextDecoder","payload","InvokeLambdaFunction","InvokeLambdaFunctionAbstraction","GetAppStackOutput"],"mappings":";;;AAKO,MAAMA;IACT,YAAoBC,iBAA8C,CAAE;aAAhDA,iBAAiB,GAAjBA;IAAiD;IAErE,MAAM,QACFC,MAA8C,EACI;QAElD,MAAMC,cAAc,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAsB;QAE9E,IAAI,CAACA,aACD,MAAM,IAAIC,MAAM;QAGpB,MAAM,EAAEC,MAAM,EAAE,GAAGF;QACnB,MAAMG,eAAe,IAAIC,aAAa;YAAEF;QAAO;QAE/C,MAAMG,WAAW,MAAMF,aAAa,IAAI,CACpC,IAAIG,cAAc;YACd,cAAcP,OAAO,YAAY;YACjC,gBAAgBA,OAAO,cAAc,IAAI;YACzC,SAASQ,KAAK,SAAS,CAACR,OAAO,OAAO;QAC1C;QAGJ,MAAMS,UAAU,IAAIC,YAAY;QAChC,MAAMC,UAAUH,KAAK,KAAK,CAACC,QAAQ,MAAM,CAACH,SAAS,OAAO;QAE1D,OAAO;YACH,YAAYA,SAAS,UAAU;YAC/BK;QACJ;IACJ;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAoD,CAAC;IACrF,gBAAgBf;IAChB,cAAc;QAACgB;KAAkB;AACrC"}
1
+ {"version":3,"file":"features/InvokeLambdaFunction.js","sources":["../../src/features/InvokeLambdaFunction.ts"],"sourcesContent":["import { GetAppStackOutput } from \"@webiny/project/abstractions/index.js\";\nimport { InvokeLambdaFunction as InvokeLambdaFunctionAbstraction } from \"~/abstractions/InvokeLambdaFunction.js\";\nimport { IDefaultStackOutput } from \"~/pulumi/types.js\";\n\nexport class InvokeLambdaFunctionImpl implements InvokeLambdaFunctionAbstraction.Interface {\n constructor(private getAppStackOutput: GetAppStackOutput.Interface) {}\n\n async execute<T = any>(\n params: InvokeLambdaFunctionAbstraction.Params\n ): Promise<InvokeLambdaFunctionAbstraction.Result<T>> {\n // Get region from stack output\n const stackOutput = await this.getAppStackOutput.execute<IDefaultStackOutput>(\"api\");\n\n if (!stackOutput) {\n throw new Error(\"Could not retrieve API stack output for Lambda invocation.\");\n }\n\n // Loaded here rather than at the top of the file. Validating the project config imports this\n // file on every command, and only an actual invocation needs the Lambda client.\n const { LambdaClient, InvokeCommand } =\n await import(\"@webiny/aws-sdk/client-lambda/index.js\");\n\n const { region } = stackOutput;\n const lambdaClient = new LambdaClient({ region });\n\n const response = await lambdaClient.send(\n new InvokeCommand({\n FunctionName: params.functionName,\n InvocationType: params.invocationType || \"RequestResponse\",\n Payload: JSON.stringify(params.payload)\n })\n );\n\n const decoder = new TextDecoder(\"utf-8\");\n const payload = JSON.parse(decoder.decode(response.Payload));\n\n return {\n statusCode: response.StatusCode,\n payload\n };\n }\n}\n\nexport const InvokeLambdaFunction = InvokeLambdaFunctionAbstraction.createImplementation({\n implementation: InvokeLambdaFunctionImpl,\n dependencies: [GetAppStackOutput]\n});\n"],"names":["InvokeLambdaFunctionImpl","getAppStackOutput","params","stackOutput","Error","LambdaClient","InvokeCommand","region","lambdaClient","response","JSON","decoder","TextDecoder","payload","InvokeLambdaFunction","InvokeLambdaFunctionAbstraction","GetAppStackOutput"],"mappings":";;AAIO,MAAMA;IACT,YAAoBC,iBAA8C,CAAE;aAAhDA,iBAAiB,GAAjBA;IAAiD;IAErE,MAAM,QACFC,MAA8C,EACI;QAElD,MAAMC,cAAc,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAsB;QAE9E,IAAI,CAACA,aACD,MAAM,IAAIC,MAAM;QAKpB,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAE,GACjC,MAAM,MAAM,CAAC;QAEjB,MAAM,EAAEC,MAAM,EAAE,GAAGJ;QACnB,MAAMK,eAAe,IAAIH,aAAa;YAAEE;QAAO;QAE/C,MAAME,WAAW,MAAMD,aAAa,IAAI,CACpC,IAAIF,cAAc;YACd,cAAcJ,OAAO,YAAY;YACjC,gBAAgBA,OAAO,cAAc,IAAI;YACzC,SAASQ,KAAK,SAAS,CAACR,OAAO,OAAO;QAC1C;QAGJ,MAAMS,UAAU,IAAIC,YAAY;QAChC,MAAMC,UAAUH,KAAK,KAAK,CAACC,QAAQ,MAAM,CAACF,SAAS,OAAO;QAE1D,OAAO;YACH,YAAYA,SAAS,UAAU;YAC/BI;QACJ;IACJ;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAoD,CAAC;IACrF,gBAAgBf;IAChB,cAAc;QAACgB;KAAkB;AACrC"}
@@ -1,8 +1,5 @@
1
1
  import { GetApp, ListAppLambdaFunctionsService, LoggerService, ProjectSdkParamsService, PulumiExportService, PulumiGetStackOutputService, UiService, Watch, WatchedLambdaFunctionsService } from "@webiny/project/abstractions/index.js";
2
2
  import chalk from "chalk";
3
- import { getIotEndpoint } from "./getIotEndpoint.js";
4
- import { replaceLambdaFunctions } from "./replaceLambdaFunctions.js";
5
- import { initInvocationForwarding } from "@webiny/project/features/Watch/initInvocationForwarding.js";
6
3
  class AwsWatch {
7
4
  constructor(getApp, logger, listAppLambdaFunctionsService, ui, pulumiGetStackOutputService, pulumiExportService, watchedLambdaFunctionsService, projectSdkParamsService, decoratee){
8
5
  this.getApp = getApp;
@@ -52,6 +49,9 @@ class AwsWatch {
52
49
  if (!coreStackOutput) throw new Error(`You must deploy the ${chalk.bold("core")} app before you can start a watch session. To do that, run: ${chalk.bold(`yarn webiny deploy core --env ${sdkParams.env}`)}`);
53
50
  const deploymentId = coreStackOutput?.deploymentId;
54
51
  const iotEndpointTopic = `webiny-watch-${deploymentId}`;
52
+ const { getIotEndpoint } = await import("./getIotEndpoint.js");
53
+ const { replaceLambdaFunctions } = await import("./replaceLambdaFunctions.js");
54
+ const { initInvocationForwarding } = await import("@webiny/project/features/Watch/initInvocationForwarding.js");
55
55
  const iotEndpoint = await getIotEndpoint(coreStackOutput);
56
56
  const sessionId = new Date().getTime();
57
57
  const increaseTimeout = params.increaseTimeout;
@@ -1 +1 @@
1
- {"version":3,"file":"features/Watch/AwsWatch.js","sources":["../../../src/features/Watch/AwsWatch.ts"],"sourcesContent":["import {\n GetApp,\n ListAppLambdaFunctionsService,\n LoggerService,\n ProjectSdkParamsService,\n PulumiExportService,\n PulumiGetStackOutputService,\n UiService,\n Watch,\n WatchedLambdaFunctionsService\n} from \"@webiny/project/abstractions/index.js\";\nimport chalk from \"chalk\";\nimport type inspectorType from \"inspector\";\nimport { type ICoreStackOutput } from \"@webiny/project/abstractions/features/GetAppStackOutput.js\";\nimport { getIotEndpoint } from \"./getIotEndpoint.js\";\nimport { replaceLambdaFunctions } from \"./replaceLambdaFunctions.js\";\nimport { initInvocationForwarding } from \"@webiny/project/features/Watch/initInvocationForwarding.js\";\n\nexport class AwsWatch implements Watch.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private listAppLambdaFunctionsService: ListAppLambdaFunctionsService.Interface,\n private ui: UiService.Interface,\n private pulumiGetStackOutputService: PulumiGetStackOutputService.Interface,\n private pulumiExportService: PulumiExportService.Interface,\n private watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface,\n private decoratee: Watch.Interface\n ) {}\n\n async execute(params: Watch.Params): Promise<Watch.Result> {\n // Validate Lambda-specific params before the base runs workspace build.\n if (\"app\" in params && params.increaseTimeout && params.increaseTimeout > 900) {\n throw new Error(\n `When increasing the timeout, the maximum value that can be passed is 900 seconds (15 minutes).`\n );\n }\n\n const result = await this.decoratee.execute(params);\n\n // No Lambda machinery for package-only watch.\n if (!(\"app\" in params)) {\n return result;\n }\n\n const app = this.getApp.execute(params.app);\n const sdkParams = this.projectSdkParamsService.get();\n const ui = this.ui;\n const logger = this.logger;\n\n const functionsWhitelist = Array.isArray(params.function)\n ? params.function\n : ([params.function].filter(Boolean) as string[]);\n\n const functionsList = await this.listAppLambdaFunctionsService.execute(app, {\n whitelist: functionsWhitelist\n });\n\n const deployCommand = `yarn webiny deploy ${app.name} --env ${sdkParams.env}`;\n const learnMoreLink = \"https://webiny.link/local-aws-lambda-development\";\n const troubleshootingLink = learnMoreLink + \"#troubleshooting\";\n\n if (functionsList.meta.count === 0) {\n if (functionsList.meta.totalCount > 0) {\n ui.info(\n [\n \"No AWS Lambda functions will be invoked locally. If this is unexpected, you can try the following:\",\n \" ‣ stop the current development session\",\n \" ‣ redeploy the %s application by running %s command\",\n \" ‣ start a new %s session by rerunning %s command\",\n \"\",\n \"Learn more: %s\"\n ].join(\"\\n\"),\n app.name,\n deployCommand,\n \"webiny watch\",\n \"webiny watch\",\n troubleshootingLink\n );\n }\n return result;\n }\n\n ui.info(`Local AWS Lambda development session started.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n\n logger.debug(\n \"The events for following AWS Lambda functions will be forwarded locally: \",\n functionsList.list.map(fn => fn.name)\n );\n\n ui.emptyLine();\n const { default: exitHook } = await import(/* webpackChunkName: \"exit-hook\" */ \"exit-hook\");\n\n exitHook(() => {\n console.log();\n console.log();\n\n ui.info(`Terminating local AWS Lambda development session.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app?.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n });\n\n const coreApp = this.getApp.execute(\"core\");\n const coreStackOutput =\n await this.pulumiGetStackOutputService.execute<ICoreStackOutput>(coreApp);\n\n if (!coreStackOutput) {\n throw new Error(\n `You must deploy the ${chalk.bold(\n \"core\"\n )} app before you can start a watch session. To do that, run: ${chalk.bold(\n `yarn webiny deploy core --env ${sdkParams.env}`\n )}`\n );\n }\n\n const deploymentId = coreStackOutput?.deploymentId;\n const iotEndpointTopic = `webiny-watch-${deploymentId}`;\n const iotEndpoint = await getIotEndpoint(coreStackOutput);\n\n const sessionId = new Date().getTime();\n const increaseTimeout = params.increaseTimeout;\n const localExecutionHandshakeTimeout = params.increaseHandshakeTimeout || 5;\n\n replaceLambdaFunctions({\n app,\n deploymentId,\n dependencies: {\n uiService: ui,\n loggerService: logger,\n pulumiExportService: this.pulumiExportService,\n watchedLambdaFunctionsService: this.watchedLambdaFunctionsService\n },\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout\n });\n\n let inspector: typeof inspectorType | undefined = undefined;\n if (params.inspect) {\n inspector = await import(\"inspector\");\n inspector!.open(9229, \"127.0.0.1\");\n ui.emptyLine();\n\n exitHook(() => {\n inspector!.close();\n });\n }\n\n initInvocationForwarding({\n iotEndpoint,\n iotEndpointTopic,\n functionsList,\n sessionId\n });\n\n return result;\n }\n}\n\nexport const awsWatch = Watch.createDecorator({\n decorator: AwsWatch,\n dependencies: [\n GetApp,\n LoggerService,\n ListAppLambdaFunctionsService,\n UiService,\n PulumiGetStackOutputService,\n PulumiExportService,\n WatchedLambdaFunctionsService,\n ProjectSdkParamsService\n ]\n});\n"],"names":["AwsWatch","getApp","logger","listAppLambdaFunctionsService","ui","pulumiGetStackOutputService","pulumiExportService","watchedLambdaFunctionsService","projectSdkParamsService","decoratee","params","Error","result","app","sdkParams","functionsWhitelist","Array","Boolean","functionsList","deployCommand","learnMoreLink","troubleshootingLink","fn","exitHook","console","coreApp","coreStackOutput","chalk","deploymentId","iotEndpointTopic","iotEndpoint","getIotEndpoint","sessionId","Date","increaseTimeout","localExecutionHandshakeTimeout","replaceLambdaFunctions","inspector","initInvocationForwarding","awsWatch","Watch","GetApp","LoggerService","ListAppLambdaFunctionsService","UiService","PulumiGetStackOutputService","PulumiExportService","WatchedLambdaFunctionsService","ProjectSdkParamsService"],"mappings":"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"}
1
+ {"version":3,"file":"features/Watch/AwsWatch.js","sources":["../../../src/features/Watch/AwsWatch.ts"],"sourcesContent":["import {\n GetApp,\n ListAppLambdaFunctionsService,\n LoggerService,\n ProjectSdkParamsService,\n PulumiExportService,\n PulumiGetStackOutputService,\n UiService,\n Watch,\n WatchedLambdaFunctionsService\n} from \"@webiny/project/abstractions/index.js\";\nimport chalk from \"chalk\";\nimport type inspectorType from \"inspector\";\nimport { type ICoreStackOutput } from \"@webiny/project/abstractions/features/GetAppStackOutput.js\";\n\nexport class AwsWatch implements Watch.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private listAppLambdaFunctionsService: ListAppLambdaFunctionsService.Interface,\n private ui: UiService.Interface,\n private pulumiGetStackOutputService: PulumiGetStackOutputService.Interface,\n private pulumiExportService: PulumiExportService.Interface,\n private watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface,\n private decoratee: Watch.Interface\n ) {}\n\n async execute(params: Watch.Params): Promise<Watch.Result> {\n // Validate Lambda-specific params before the base runs workspace build.\n if (\"app\" in params && params.increaseTimeout && params.increaseTimeout > 900) {\n throw new Error(\n `When increasing the timeout, the maximum value that can be passed is 900 seconds (15 minutes).`\n );\n }\n\n const result = await this.decoratee.execute(params);\n\n // No Lambda machinery for package-only watch.\n if (!(\"app\" in params)) {\n return result;\n }\n\n const app = this.getApp.execute(params.app);\n const sdkParams = this.projectSdkParamsService.get();\n const ui = this.ui;\n const logger = this.logger;\n\n const functionsWhitelist = Array.isArray(params.function)\n ? params.function\n : ([params.function].filter(Boolean) as string[]);\n\n const functionsList = await this.listAppLambdaFunctionsService.execute(app, {\n whitelist: functionsWhitelist\n });\n\n const deployCommand = `yarn webiny deploy ${app.name} --env ${sdkParams.env}`;\n const learnMoreLink = \"https://webiny.link/local-aws-lambda-development\";\n const troubleshootingLink = learnMoreLink + \"#troubleshooting\";\n\n if (functionsList.meta.count === 0) {\n if (functionsList.meta.totalCount > 0) {\n ui.info(\n [\n \"No AWS Lambda functions will be invoked locally. If this is unexpected, you can try the following:\",\n \" ‣ stop the current development session\",\n \" ‣ redeploy the %s application by running %s command\",\n \" ‣ start a new %s session by rerunning %s command\",\n \"\",\n \"Learn more: %s\"\n ].join(\"\\n\"),\n app.name,\n deployCommand,\n \"webiny watch\",\n \"webiny watch\",\n troubleshootingLink\n );\n }\n return result;\n }\n\n ui.info(`Local AWS Lambda development session started.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n\n logger.debug(\n \"The events for following AWS Lambda functions will be forwarded locally: \",\n functionsList.list.map(fn => fn.name)\n );\n\n ui.emptyLine();\n const { default: exitHook } = await import(/* webpackChunkName: \"exit-hook\" */ \"exit-hook\");\n\n exitHook(() => {\n console.log();\n console.log();\n\n ui.info(`Terminating local AWS Lambda development session.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app?.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n });\n\n const coreApp = this.getApp.execute(\"core\");\n const coreStackOutput =\n await this.pulumiGetStackOutputService.execute<ICoreStackOutput>(coreApp);\n\n if (!coreStackOutput) {\n throw new Error(\n `You must deploy the ${chalk.bold(\n \"core\"\n )} app before you can start a watch session. To do that, run: ${chalk.bold(\n `yarn webiny deploy core --env ${sdkParams.env}`\n )}`\n );\n }\n\n const deploymentId = coreStackOutput?.deploymentId;\n const iotEndpointTopic = `webiny-watch-${deploymentId}`;\n // Loaded here rather than at the top of the file. This decorator is registered for every\n // command, and these pull in the AWS IoT and Lambda clients and mqtt, which only a watch\n // session needs.\n const { getIotEndpoint } = await import(\"./getIotEndpoint.js\");\n const { replaceLambdaFunctions } = await import(\"./replaceLambdaFunctions.js\");\n const { initInvocationForwarding } =\n await import(\"@webiny/project/features/Watch/initInvocationForwarding.js\");\n\n const iotEndpoint = await getIotEndpoint(coreStackOutput);\n\n const sessionId = new Date().getTime();\n const increaseTimeout = params.increaseTimeout;\n const localExecutionHandshakeTimeout = params.increaseHandshakeTimeout || 5;\n\n replaceLambdaFunctions({\n app,\n deploymentId,\n dependencies: {\n uiService: ui,\n loggerService: logger,\n pulumiExportService: this.pulumiExportService,\n watchedLambdaFunctionsService: this.watchedLambdaFunctionsService\n },\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout\n });\n\n let inspector: typeof inspectorType | undefined = undefined;\n if (params.inspect) {\n inspector = await import(\"inspector\");\n inspector!.open(9229, \"127.0.0.1\");\n ui.emptyLine();\n\n exitHook(() => {\n inspector!.close();\n });\n }\n\n initInvocationForwarding({\n iotEndpoint,\n iotEndpointTopic,\n functionsList,\n sessionId\n });\n\n return result;\n }\n}\n\nexport const awsWatch = Watch.createDecorator({\n decorator: AwsWatch,\n dependencies: [\n GetApp,\n LoggerService,\n ListAppLambdaFunctionsService,\n UiService,\n PulumiGetStackOutputService,\n PulumiExportService,\n WatchedLambdaFunctionsService,\n ProjectSdkParamsService\n ]\n});\n"],"names":["AwsWatch","getApp","logger","listAppLambdaFunctionsService","ui","pulumiGetStackOutputService","pulumiExportService","watchedLambdaFunctionsService","projectSdkParamsService","decoratee","params","Error","result","app","sdkParams","functionsWhitelist","Array","Boolean","functionsList","deployCommand","learnMoreLink","troubleshootingLink","fn","exitHook","console","coreApp","coreStackOutput","chalk","deploymentId","iotEndpointTopic","getIotEndpoint","replaceLambdaFunctions","initInvocationForwarding","iotEndpoint","sessionId","Date","increaseTimeout","localExecutionHandshakeTimeout","inspector","awsWatch","Watch","GetApp","LoggerService","ListAppLambdaFunctionsService","UiService","PulumiGetStackOutputService","PulumiExportService","WatchedLambdaFunctionsService","ProjectSdkParamsService"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/project-aws",
3
- "version": "6.6.0-alpha.7",
3
+ "version": "6.6.0-alpha.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -20,15 +20,15 @@
20
20
  "@pulumi/aws": "^7.43.0",
21
21
  "@pulumi/pulumi": "^3.259.0",
22
22
  "@pulumi/random": "4.21.1",
23
- "@webiny/aws-layers": "6.6.0-alpha.7",
24
- "@webiny/aws-sdk": "6.6.0-alpha.7",
25
- "@webiny/cli-core": "6.6.0-alpha.7",
23
+ "@webiny/aws-layers": "6.6.0-alpha.8",
24
+ "@webiny/aws-sdk": "6.6.0-alpha.8",
25
+ "@webiny/cli-core": "6.6.0-alpha.8",
26
26
  "@webiny/di": "1.1.0",
27
- "@webiny/global-config": "6.6.0-alpha.7",
28
- "@webiny/project": "6.6.0-alpha.7",
29
- "@webiny/pulumi": "6.6.0-alpha.7",
30
- "@webiny/pulumi-sdk": "6.6.0-alpha.7",
31
- "@webiny/utils": "6.6.0-alpha.7",
27
+ "@webiny/global-config": "6.6.0-alpha.8",
28
+ "@webiny/project": "6.6.0-alpha.8",
29
+ "@webiny/pulumi": "6.6.0-alpha.8",
30
+ "@webiny/pulumi-sdk": "6.6.0-alpha.8",
31
+ "@webiny/utils": "6.6.0-alpha.8",
32
32
  "chalk": "6.0.0",
33
33
  "email-addresses": "5.0.0",
34
34
  "exit-hook": "5.1.0",
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@types/lodash": "4.17.25",
47
47
  "@types/ncp": "2.0.8",
48
- "@webiny/build-tools": "6.6.0-alpha.7",
48
+ "@webiny/build-tools": "6.6.0-alpha.8",
49
49
  "typescript": "7.0.2",
50
50
  "vitest": "4.1.11"
51
51
  },
@@ -1,9 +1,8 @@
1
- import { Pulumi } from "@webiny/pulumi-sdk";
2
1
  import { GetProjectService, GetPulumiService, ProjectSdkParamsService } from "@webiny/project/abstractions/index.js";
3
2
  export declare class DefaultGetPulumiService implements GetPulumiService.Interface {
4
3
  private readonly getProjectService;
5
4
  private readonly projectSdkParamsService;
6
5
  constructor(getProjectService: GetProjectService.Interface, projectSdkParamsService: ProjectSdkParamsService.Interface);
7
- execute(params?: GetPulumiService.Params): Promise<Pulumi>;
6
+ execute(params?: GetPulumiService.Params): Promise<import("@webiny/pulumi-sdk").Pulumi>;
8
7
  }
9
8
  export declare const getPulumiService: import("@webiny/di").Implementation<typeof DefaultGetPulumiService>;
@@ -1,4 +1,3 @@
1
- import { Pulumi } from "@webiny/pulumi-sdk";
2
1
  import { createImplementation } from "@webiny/di";
3
2
  import { GetProjectService, GetPulumiService, ProjectSdkParamsService } from "@webiny/project/abstractions/index.js";
4
3
  import { WBY_PROJECT_SDK_CONTEXT, serializeProjectSdkContext } from "@webiny/project/utils/index.js";
@@ -24,6 +23,7 @@ class DefaultGetPulumiService {
24
23
  ...contextEnv
25
24
  }
26
25
  };
26
+ const { Pulumi } = await import("@webiny/pulumi-sdk");
27
27
  return Pulumi.create({
28
28
  ...pulumiOptions,
29
29
  execa: mergedExeca,
@@ -1 +1 @@
1
- {"version":3,"file":"services/GetPulumiService/GetPulumiService.js","sources":["../../../src/services/GetPulumiService/GetPulumiService.ts"],"sourcesContent":["import { Pulumi } from \"@webiny/pulumi-sdk\";\nimport { createImplementation } from \"@webiny/di\";\nimport {\n GetProjectService,\n GetPulumiService,\n ProjectSdkParamsService\n} from \"@webiny/project/abstractions/index.js\";\nimport {\n serializeProjectSdkContext,\n WBY_PROJECT_SDK_CONTEXT\n} from \"@webiny/project/utils/index.js\";\n\nexport class DefaultGetPulumiService implements GetPulumiService.Interface {\n constructor(\n private readonly getProjectService: GetProjectService.Interface,\n private readonly projectSdkParamsService: ProjectSdkParamsService.Interface\n ) {}\n\n async execute(params: GetPulumiService.Params = {}) {\n const project = this.getProjectService.execute();\n const { app, pulumiOptions = {} } = params;\n\n let cwd;\n if (app) {\n cwd = app.paths.workspaceFolder.toString();\n }\n\n const sdkParams = this.projectSdkParamsService.get();\n const contextEnv = {\n [WBY_PROJECT_SDK_CONTEXT]: serializeProjectSdkContext(sdkParams)\n };\n\n const mergedExeca = {\n ...pulumiOptions.execa,\n cwd,\n env: {\n ...pulumiOptions.execa?.env,\n ...contextEnv\n }\n };\n\n return Pulumi.create({\n ...pulumiOptions,\n execa: mergedExeca,\n pulumiFolder: project.paths.dotWebinyFolder.toString()\n });\n }\n}\n\nexport const getPulumiService = createImplementation({\n abstraction: GetPulumiService,\n implementation: DefaultGetPulumiService,\n dependencies: [GetProjectService, ProjectSdkParamsService]\n});\n"],"names":["DefaultGetPulumiService","getProjectService","projectSdkParamsService","params","project","app","pulumiOptions","cwd","sdkParams","contextEnv","WBY_PROJECT_SDK_CONTEXT","serializeProjectSdkContext","mergedExeca","Pulumi","getPulumiService","createImplementation","GetPulumiService","GetProjectService","ProjectSdkParamsService"],"mappings":";;;;AAYO,MAAMA;IACT,YACqBC,iBAA8C,EAC9CC,uBAA0D,CAC7E;aAFmBD,iBAAiB,GAAjBA;aACAC,uBAAuB,GAAvBA;IAClB;IAEH,MAAM,QAAQC,SAAkC,CAAC,CAAC,EAAE;QAChD,MAAMC,UAAU,IAAI,CAAC,iBAAiB,CAAC,OAAO;QAC9C,MAAM,EAAEC,GAAG,EAAEC,gBAAgB,CAAC,CAAC,EAAE,GAAGH;QAEpC,IAAII;QACJ,IAAIF,KACAE,MAAMF,IAAI,KAAK,CAAC,eAAe,CAAC,QAAQ;QAG5C,MAAMG,YAAY,IAAI,CAAC,uBAAuB,CAAC,GAAG;QAClD,MAAMC,aAAa;YACf,CAACC,wBAAwB,EAAEC,2BAA2BH;QAC1D;QAEA,MAAMI,cAAc;YAChB,GAAGN,cAAc,KAAK;YACtBC;YACA,KAAK;gBACD,GAAGD,cAAc,KAAK,EAAE,GAAG;gBAC3B,GAAGG,UAAU;YACjB;QACJ;QAEA,OAAOI,OAAO,MAAM,CAAC;YACjB,GAAGP,aAAa;YAChB,OAAOM;YACP,cAAcR,QAAQ,KAAK,CAAC,eAAe,CAAC,QAAQ;QACxD;IACJ;AACJ;AAEO,MAAMU,mBAAmBC,qBAAqB;IACjD,aAAaC;IACb,gBAAgBhB;IAChB,cAAc;QAACiB;QAAmBC;KAAwB;AAC9D"}
1
+ {"version":3,"file":"services/GetPulumiService/GetPulumiService.js","sources":["../../../src/services/GetPulumiService/GetPulumiService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n GetProjectService,\n GetPulumiService,\n ProjectSdkParamsService\n} from \"@webiny/project/abstractions/index.js\";\nimport {\n serializeProjectSdkContext,\n WBY_PROJECT_SDK_CONTEXT\n} from \"@webiny/project/utils/index.js\";\n\nexport class DefaultGetPulumiService implements GetPulumiService.Interface {\n constructor(\n private readonly getProjectService: GetProjectService.Interface,\n private readonly projectSdkParamsService: ProjectSdkParamsService.Interface\n ) {}\n\n async execute(params: GetPulumiService.Params = {}) {\n const project = this.getProjectService.execute();\n const { app, pulumiOptions = {} } = params;\n\n let cwd;\n if (app) {\n cwd = app.paths.workspaceFolder.toString();\n }\n\n const sdkParams = this.projectSdkParamsService.get();\n const contextEnv = {\n [WBY_PROJECT_SDK_CONTEXT]: serializeProjectSdkContext(sdkParams)\n };\n\n const mergedExeca = {\n ...pulumiOptions.execa,\n cwd,\n env: {\n ...pulumiOptions.execa?.env,\n ...contextEnv\n }\n };\n\n // Loaded here rather than at the top of the file. This service is registered for every\n // command, and the Pulumi SDK is only needed by the commands that run Pulumi.\n const { Pulumi } = await import(\"@webiny/pulumi-sdk\");\n\n return Pulumi.create({\n ...pulumiOptions,\n execa: mergedExeca,\n pulumiFolder: project.paths.dotWebinyFolder.toString()\n });\n }\n}\n\nexport const getPulumiService = createImplementation({\n abstraction: GetPulumiService,\n implementation: DefaultGetPulumiService,\n dependencies: [GetProjectService, ProjectSdkParamsService]\n});\n"],"names":["DefaultGetPulumiService","getProjectService","projectSdkParamsService","params","project","app","pulumiOptions","cwd","sdkParams","contextEnv","WBY_PROJECT_SDK_CONTEXT","serializeProjectSdkContext","mergedExeca","Pulumi","getPulumiService","createImplementation","GetPulumiService","GetProjectService","ProjectSdkParamsService"],"mappings":";;;AAWO,MAAMA;IACT,YACqBC,iBAA8C,EAC9CC,uBAA0D,CAC7E;aAFmBD,iBAAiB,GAAjBA;aACAC,uBAAuB,GAAvBA;IAClB;IAEH,MAAM,QAAQC,SAAkC,CAAC,CAAC,EAAE;QAChD,MAAMC,UAAU,IAAI,CAAC,iBAAiB,CAAC,OAAO;QAC9C,MAAM,EAAEC,GAAG,EAAEC,gBAAgB,CAAC,CAAC,EAAE,GAAGH;QAEpC,IAAII;QACJ,IAAIF,KACAE,MAAMF,IAAI,KAAK,CAAC,eAAe,CAAC,QAAQ;QAG5C,MAAMG,YAAY,IAAI,CAAC,uBAAuB,CAAC,GAAG;QAClD,MAAMC,aAAa;YACf,CAACC,wBAAwB,EAAEC,2BAA2BH;QAC1D;QAEA,MAAMI,cAAc;YAChB,GAAGN,cAAc,KAAK;YACtBC;YACA,KAAK;gBACD,GAAGD,cAAc,KAAK,EAAE,GAAG;gBAC3B,GAAGG,UAAU;YACjB;QACJ;QAIA,MAAM,EAAEI,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC;QAEhC,OAAOA,OAAO,MAAM,CAAC;YACjB,GAAGP,aAAa;YAChB,OAAOM;YACP,cAAcR,QAAQ,KAAK,CAAC,eAAe,CAAC,QAAQ;QACxD;IACJ;AACJ;AAEO,MAAMU,mBAAmBC,qBAAqB;IACjD,aAAaC;IACb,gBAAgBhB;IAChB,cAAc;QAACiB;QAAmBC;KAAwB;AAC9D"}