How To Deploy NodeJs Code Using AWS Lambda & S3 Bucket In GitLab(Simple Explanation)

Published: 12 January 2024
on channel: Devops Zplus
1,172
23

Ref:
https://docs.aws.amazon.com/cli/lates...
https://docs.aws.amazon.com/cli/lates...

Please find below .gitlab-ci.yml file

stages:
make-zip-file
create-s3-bucket-and-upload-zip-file
create-lambda-function

image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest

variables:
my_bucket: nodejs-app-deploy-lambda092

make-zip-file:
stage: make-zip-file
script:
echo "make zip"
mkdir bin/
zip -r9 node-js-app.zip index.js
cp node-js-app.zip bin/
ls
artifacts:
paths:
bin/

create-s3-bucket-and-upload-zip-file:
stage: create-s3-bucket-and-upload-zip-file
script:
aws s3 mb s3://$my_bucket
aws s3 ls
ls bin/
cd bin/
aws s3 cp node-js-app.zip s3://$my_bucket
needs:
job: make-zip-file
artifacts: true

create-lambda-function:
stage: create-lambda-function
script:
echo “Create lambda function”
echo $my_bucket
aws lambda create-function --function-name node-app --runtime nodejs20.x --handler index.handler --role arn:aws:iam::1845983:role/lambda --code S3Bucket=$my_bucket,S3Key=node-js-app.zip


On this page of the site you can watch the video online How To Deploy NodeJs Code Using AWS Lambda & S3 Bucket In GitLab(Simple Explanation) with a duration of hours minute second in good quality, which was uploaded by the user Devops Zplus 12 January 2024, share the link with friends and acquaintances, this video has already been watched 1,172 times on youtube and it was liked by 23 viewers. Enjoy your viewing!