How do we upload lambda function .zip directly from CLI?
Asked Answered
V

2

8

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?

Vaso answered 13/9, 2021 at 14:20 Comment(0)
P
13

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.

Pimp answered 13/9, 2021 at 14:28 Comment(0)
O
0

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>"
Outlander answered 4/7, 2023 at 22:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.