Deploy AWS Lambda on AWS S3 using Azure DevOps CI-CD
Once your AWS Lambda function is ready to deploy, you can choose many ways to deploy it on S3, I choose azure DevOps version control here to deploy it on S3.
The designed .yaml file is below on Ubuntu OS:
Note: Please set up your environment variables in Azure Library (AWS_Configuration_Variables) and defined them in the .yaml file.
# (see https://aka.ms/yaml for the YAML schema reference)
trigger:
branches:
include:
- main
paths:
include:
- /Migrations
pool:
vmImage: ‘ubuntu-latest’
variables:
- group: AWS_Configuration_Variables
steps:
- task: Bash@3
inputs:
targetType: ‘inline’
script: |
echo ‘Starting aws cli’
sudo apt install aws cli
aws — version
echo ‘configure aws cli’
export AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID)
export AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY)
export AWS_DEFAULT_REGION=$(AWS_DEFAULT_REGION)
echo ‘ — — — — — — -Zip the project folder — — — — — — -’
zip -r9 $(PROJECT_FOLDER)/snowfunc.zip .
echo ‘ — — — — — — — — — — -zip complete at ‘$(PROJECT_FOLDER)
aws s3 cp $(PROJECT_FOLDER)/snowfunc.zip s3://parts-data-blobs3/snowfunc.zip
echo ‘ — — — uploaded on AWS S3 — — — — — — — ‘
AWS lambda update-function-code — function-name snowfunc — region $(AWS_DEFAULT_REGION) — s3-bucket parts-data-blobs3 — s3-key snowfunc.zip
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
happy deployment 😊