本节我们将在上节的基础上,使用SAM测试及部署项目。
进行build:
sam build
和之前的项目一样,执行sam local invoke,会启动一个docker容器对项目进行测试:

查看docker images, 可以找到构建的镜像列表:

sam deploy --guided
输入项目名称,所有的选项都选择y。

在HelloWorldFunction may not have authorization defined, Is this okay部分,如果选择跳过会报Error: Security Constraints Not Satisfied! 错误
参考: https://stackoverflow.com/questions/61841136/what-is-the-cause-of-the-security-constraints-not-satisfied-error-when-using-sam
生成changset后,继续进行部署:

部署完成后,会输出API Gateway的URL:

在浏览器中访问,结果如Lambda中定义的json体:

部署完成后,进入Lambda服务。新创建的Lambda会自动绑定对应的API Gateway 触发器:
