Created
September 16, 2019 06:06
-
-
Save nikosheng/859e51cee7b58de714ea73e61f03770c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lambda 本地调试 - Intellij Idea 篇 | |
## 先决条件 | |
- [安装sam cli](https://docs.aws.amazon.com/zh_cn/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) | |
- [安装Intellij Idea](https://www.jetbrains.com/idea/) | |
- [安装AWS Toolkit for Intellij](https://aws.amazon.com/cn/intellij/) | |
- [安装Maven](https://maven.apache.org/) | |
## 实验步骤 | |
### 创建本地`Lambda`项目 | |
- 通过`sam cli`创建本地`Lambda`项目,本次实验以`java`作为实验语言 | |
``` | |
$ sam init -r java8 -n sam-app-java | |
``` | |
- 通过`AWS Toolkit for Intellij` 创建`SAM`任务,本次实验通过改方式来预配置环境 | |
- 创建项目后,在项目目录下,通过`sam build`构建该项目,构建任务会调用`maven`安装任务所需要的`jar`完成项目的构建 | |
- 执行`sam local invoke`启动本地调试环境,同时指定一个端口用做`Intellij Idea`客户端远程调试进程的通信。本次实验会暴露`5890` 端口 | |
``` | |
sam local generate-event apigateway aws-proxy | sam local invoke HelloWorldFunction -d 5890 | |
``` | |
- 在`Intellij Idea`的调试设置页面中,新建调试器 | |
- 后台任务启动后,在`Intellij Idea`的代码编辑中,设置`break point`调试断点。 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment