Articles → AWS → Deploy The Lambda Function Using The AWS CLI

Deploy The Lambda Function Using The AWS CLI






Create A Lambda Function




Picture showing the lambda function created in AWS console
Click to Enlarge


Create A S3 Bucket




Picture showing the S3 bucket created in AWS console
Click to Enlarge


Sample Node.Js Code




exports.handler = async (event) => {
    console.log(event);
    return 'This is the updated code!';
};



Upload Code On S3 Bucket




Picture showing the node.js code uploaded on S3 bucket
Click to Enlarge


Configure CLI And Deploy Code Using CLI




aws lambda update-function-code --function-name myfunc --s3-bucket gyansangrah-bucket --s3-key myCode.zip –publish




  1. myfunc is the lambda function name
  2. gyansangrah-bucket is the S3 bucket name
  3. myCode.zip is the code file key uploaded on the S3 bucket
Picture showing executing the CLI command for uploading the code from S3 bucket to the lambda function
Click to Enlarge


Output


Picture showing the code uploaded to the lambda function using the CLI command
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Friday, February 3, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250