Skip to content

Commit

Permalink
feat: local AWS Lambda development (#4185)
Browse files Browse the repository at this point in the history
Co-authored-by: Bruno Zorić <[email protected]>
Co-authored-by: Vitalii Nobis <[email protected]>
Co-authored-by: Pavel Denisjuk <[email protected]>
  • Loading branch information
4 people authored Jul 10, 2024
1 parent 2529e55 commit cfe49a4
Show file tree
Hide file tree
Showing 45 changed files with 2,570 additions and 132 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
**/.pulumi/
.webiny/**
packages/ui/src/RichTextEditor/editorjs/**
packages/cli-plugin-deploy-pulumi/commands/newWatch/handler/mqtt.js
lerna.json
coverage/**
1 change: 1 addition & 0 deletions packages/aws-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@aws-sdk/client-dynamodb-streams": "^3.540.0",
"@aws-sdk/client-eventbridge": "^3.540.0",
"@aws-sdk/client-iam": "^3.540.0",
"@aws-sdk/client-iot": "^3.540.0",
"@aws-sdk/client-lambda": "^3.540.0",
"@aws-sdk/client-s3": "^3.540.0",
"@aws-sdk/client-sfn": "^3.540.0",
Expand Down
1 change: 1 addition & 0 deletions packages/aws-sdk/src/client-iot/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { IoTClient, DescribeEndpointCommand } from "@aws-sdk/client-iot";
8 changes: 7 additions & 1 deletion packages/aws-sdk/src/client-lambda/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda";
export {
LambdaClient,
InvokeCommand,
GetFunctionConfigurationCommand,
UpdateFunctionConfigurationCommand,
UpdateFunctionCodeCommand
} from "@aws-sdk/client-lambda";
205 changes: 133 additions & 72 deletions packages/cli-plugin-deploy-pulumi/commands/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { featureFlags } = require("@webiny/feature-flags");

module.exports = [
{
type: "cli-command",
Expand Down Expand Up @@ -138,79 +140,138 @@ module.exports = [
}
);

yargs.command(
"watch [folder]",
`Rebuild and deploy specified project application while making changes to it`,
yargs => {
yargs.example("$0 watch api --env=dev");
yargs.example(
"$0 watch api --env=dev --scope my-package-1 --scope my-package-2"
);
yargs.example("$0 watch api --env=dev --depth 2");
yargs.example('$0 watch api --env=dev -r "my-function*"');
yargs.example('$0 watch --env=dev --scope "my/{package1,package2}" ');
if (featureFlags.newWatchCommand) {
yargs.command(
"watch [folder]",
`Start a new development session`,
yargs => {
yargs.example("$0 watch api --env=dev");

yargs.positional("folder", {
describe: `Project application folder`,
type: "string"
});
yargs.option("env", {
describe: `Environment`,
type: "string"
});
yargs.option("build", {
describe: `While making code changes, re-build all relevant packages`,
type: "boolean"
});
yargs.option("deploy", {
describe: `While making code changes, re-deploy cloud infrastructure`,
type: "boolean"
});
yargs.option("package", {
alias: "p",
describe: `Override watch packages (list of packages that need to be watched for code changes)`,
type: "string"
});
yargs.option("depth", {
describe: `The level of dependencies that needs to be watched for code changes (does not work when "scope" is passed)`,
type: "number",
default: 2
});
yargs.option("output", {
describe: `Specify the output destination to which all of the logs will be forwarded`,
default: "simple",
type: "string"
});
yargs.option("logs", {
default: undefined,
describe: `Enable base compilation-related logs`,
type: "boolean"
});
yargs.option("remoteRuntimeLogs", {
alias: "r",
describe: `Forward logs from deployed application code to your terminal (optionally accepts a glob pattern for filtering purposes)`,
type: "string"
});
yargs.option("show-timestamps", {
alias: "t",
describe: `Includes timestamps in the logs`,
type: "boolean"
});
yargs.option("debug", {
default: false,
describe: `Turn on debug logs`,
type: "boolean"
});
yargs.option("allowProduction", {
default: false,
describe: `Enables running the watch command with "prod" and "production" environments (not recommended).`,
type: "boolean"
});
},
async argv => {
return require("./watch")(argv, context);
}
);
yargs.positional("folder", {
describe: `Project application folder or application name`,
type: "string"
});
yargs.option("env", {
describe: `Environment`,
type: "string"
});
yargs.option("package", {
alias: "p",
describe: `One or more packages that will be watched for code changes`,
type: "string"
});
yargs.option("function", {
alias: "f",
describe:
"One or more functions that will invoked locally (used with local AWS Lambda development)",
type: "string"
});
yargs.option("inspect", {
alias: "i",
describe:
"Enable Node debugger (used with local AWS Lambda development)",
type: "boolean"
});
yargs.option("depth", {
describe: `The level of dependencies that will be watched for code changes`,
type: "number",
default: 2
});
yargs.option("debug", {
default: false,
describe: `Turn on debug logs`,
type: "boolean"
});
yargs.option("increase-timeout", {
default: 120,
describe: `Increase AWS Lambda function timeout (passed as number of seconds, used with local AWS Lambda development)`,
type: "number"
});
yargs.option("allow-production", {
default: false,
describe: `Enables running the watch command with "prod" and "production" environments (not recommended).`,
type: "boolean"
});
},
async argv => {
return require("./newWatch")(argv, context);
}
);
} else {
yargs.command(
"watch [folder]",
`Rebuild and deploy specified specified project application while making changes to it`,
yargs => {
yargs.example("$0 watch api --env=dev");
yargs.example(
"$0 watch api --env=dev --scope my-package-1 --scope my-package-2"
);
yargs.example("$0 watch api --env=dev --depth 2");
yargs.example('$0 watch api --env=dev -r "my-function*"');
yargs.example('$0 watch --env=dev --scope "my/{package1,package2}" ');

yargs.positional("folder", {
describe: `Project application folder`,
type: "string"
});
yargs.option("env", {
describe: `Environment`,
type: "string"
});
yargs.option("build", {
describe: `While making code changes, re-build all relevant packages`,
type: "boolean"
});
yargs.option("deploy", {
describe: `While making code changes, re-deploy cloud infrastructure`,
type: "boolean"
});
yargs.option("package", {
alias: "p",
describe: `Override watch packages (list of packages that need to be watched for code changes)`,
type: "string"
});
yargs.option("depth", {
describe: `The level of dependencies that needs to be watched for code changes (does not work when "scope" is passed)`,
type: "number",
default: 2
});
yargs.option("output", {
describe: `Specify the output destination to which all of the logs will be forwarded`,
default: "simple",
type: "string"
});
yargs.option("logs", {
default: undefined,
describe: `Enable base compilation-related logs`,
type: "boolean"
});
yargs.option("remoteRuntimeLogs", {
alias: "r",
describe: `Forward logs from deployed application code to your terminal (optionally accepts a glob pattern for filtering purposes)`,
type: "string"
});
yargs.option("show-timestamps", {
alias: "t",
describe: `Includes timestamps in the logs`,
type: "boolean"
});
yargs.option("debug", {
default: false,
describe: `Turn on debug logs`,
type: "boolean"
});
yargs.option("allowProduction", {
default: false,
describe: `Enables running the watch command with "prod" and "production" environments (not recommended).`,
type: "boolean"
});
},
async argv => {
return require("./watch")(argv, context);
}
);
}

yargs.command(
"destroy [folder]",
Expand Down
Loading

0 comments on commit cfe49a4

Please sign in to comment.