简体   繁体   中英

deploy zip to aws lambda automatically

I have zipped my source code using python and moved Zip file to S3 bucket. And how can I automatically deploy this zip file to my already existing Lambda function. could you please give an idea on this. Thanks in advance.

  • first install serverless.
npm install -g serverless
  • check this repo for examples. I am providing a simple python lambda function example. serverless examples
  • You can reference your lambda function from the files and also create necessary roles and invoke permissions and mention your resources in serverless.yml.
  • To deploy the cloud formation script simply use below command from the directory of serverless.yml file
serverless deploy
  • To delete the resources you deployed simply use following command from serverless.yml file's directory.
serverless remove
  • This saves you a lot of time than creating your resources through console.
  • You can also see different examples of nodejs etc in that repo.
  • You can setup S3 to trigger a different lambda function whenever a code is uploaded in the s3 bucket and configure this lambda function to upload that zip in s3 to your desired lambda function.
  • If your usecase is you only have to do changes and update the code from bucket. You can use serverless instead of paying for another lambda function.
  • Serverless uses cloudformation underlyingly.
  • see this reference on how to setup a s3 trigger create s3 trigger . Write your logic using boto3 client in this triggered lambda to upload the code to other lambda.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM