英文:
How do we upload lambda function .zip directly from CLI?
问题
我使用Ubuntu,并且有一个使用Redis的Golang Lambda函数。已经将其压缩并上传。但我仍然需要进一步开发它。
每次我进行更改并想在CloudWatch中查看日志时...似乎我需要一遍又一遍地执行这些步骤。
代码 -> 构建main.go -> 压缩 -> 上传 -> 触发函数 -> 查看日志
这样效率很低。
有没有简化这些步骤的方法?
是否可以通过CLI上传它?
谢谢!
英文:
I use Ubuntu and have this Golang lambda function with Redis. Already zipped and uploaded it. But I still need to develop it further.
Every time I made changes and want to see the logs in CloudWatch... It seems that I need to do the steps over and over.
code -> build main.go -> zipped -> upload it -> trigger the function -> see the logs
ineffective.
is there a way to simplify the steps?
is it possible to upload it through CLI?
thank you!
答案1
得分: 3
你可以使用命令行界面进行上传:
aws lambda update-function-code \
--function-name my-function \
--zip-file fileb://my-function.zip
你可以在文档中查看这个特定的示例。
其他步骤应该很容易通过一个简单的脚本自动化。
英文:
You can upload using the cli:
aws lambda update-function-code \
--function-name my-function \
--zip-file fileb://my-function.zip
you can see this particular example in the docs.
The other steps should be pretty easy to automate with a simple script.
答案2
得分: 0
对于需要在本地触发部署,但使用 S3 对象的任何人:
aws lambda update-function-code \
--function-name "my-lambda-function" \
--s3-bucket "<bucket>" \
--s3-key "<object key>"
以下是使用 SAM CLI 构建并上传到 S3 的方法:
sam build
sam package --s3-bucket "<bucket>"
英文:
For anyone requiring to also trigger the deploy locally, but instead using an S3 object:
aws lambda update-function-code \
--function-name "my-lambda-function" \
--s3-bucket "<bucket>" \
--s3-key "<object key>"
Here's how to build and upload to S3 using the SAM CLI:
sam build
sam package --s3-bucket "<bucket>"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论