如何从 VSCode 更新我的 AWS Lambda 函数? [英] How can I update my AWS Lambda function from VSCode?

查看:64
本文介绍了如何从 VSCode 更新我的 AWS Lambda 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个用 NodeJS 编写的 AWS Lambda 函数,但我厌倦了在 AWS 控制台中编码,或者不得不在我的 VSCode 中手动压缩我的代码以在 AWS 控制台中手动上传它.

So I have an AWS Lambda function written in NodeJS, but I am tired of coding in the AWS Console or having to manually zip my code in my VSCode to manually upload it in he AWS Console.

我知道我可以使用 aws lambda update-function-code --function-name myFunction --zip-file "fileb://myZipFile" 更新我的函数.但是,每次我在 VSCode 中保存我的工作时,如何压缩它并启动此命令?

I know that I can update my function with aws lambda update-function-code --function-name myFunction --zip-file "fileb://myZipFile". But how can I zip it and launch this command every time I save my work in VSCode ?

另外,我使用的是 Windows.

Also, I am on Windows.

推荐答案

如果没有一些额外的工作,你就无法做到这一点.

You can't do this without some additional work.

一些选项是:

  • 使用 保存时运行 VS Code 扩展并配置自定义命令在保存文件时运行
  • 创建一个 SAM 项目并安装 AWS Toolkit for VS Code 扩展以提供 部署协助
  • 创建一个包含 zip/deployment 脚本的 package.json 并使用 NPM 扩展 用于 VS Code 执行部署脚本
  • 构建 CI/CD 解决方案:使用 VS Code 提交和推送您的代码,然后管道接管并部署它
  • 使用 shell 脚本或带有目标的 Makefile 进行压缩和部署,然后在 VS Code 内置终端中手动或以其他方式简单地执行它
  • use the Run on Save VS Code extension and configure a custom command to run when a file is saved
  • create a SAM project and install the AWS Toolkit for VS Code extension to provide deployment assistance
  • create a package.json that includes a script for zip/deployment and use the NPM extension for VS Code to execute the deploy script
  • build a CI/CD solution: use VS Code to commit and push your code, then the pipeline takes over and deploys it
  • use a shell script, or a Makefile with a target, that zips and deploys and then simply execute it, manually or otherwise, in the VS Code in-built terminal

这篇关于如何从 VSCode 更新我的 AWS Lambda 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆