How to Deploy to AWS Lambda from GitHub Actions
How do you deploy to AWS Lambda from GitHub Actions? You deploy to AWS Lambda from GitHub Actions by configuring your repository with a workflow file that builds your code, packages it, and uses the AWS CLI or AWS-provided GitHub Actions to update your Lambda function automatically on every push, merge, or tag, creating a streamlined CI/CD pipeline for serverless applications.
For enterprise leaders, automating AWS Lambda deployments with GitHub Actions brings greater consistency, faster release cycles, and improved collaboration across engineering teams, while reducing the manual effort and risk associated with cloud deployment workflows.
Step 1: Prepare Your AWS Lambda Function
Before integrating GitHub Actions, ensure your Lambda function:
- Exists in AWS Lambda (manually created or defined via infrastructure as code)
- Uses a supported runtime (e.g., Python, Node.js, Go)
- Has an IAM role with deployment permissions
You’ll also need your function’s name and AWS region.
Executive Insight: This setup allows teams to push code directly to production-ready environments with auditability and version control.
Step 2: Store AWS Credentials in GitHub Secrets
For GitHub Actions to deploy to AWS, store your AWS credentials securely:
- Go to your GitHub repository → Settings > Secrets and variables > Actions
- Click New repository secret and add the following:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- (Optionally) AWS_REGION
These credentials should be from an IAM user or role with permissions like:
{
“Effect”: “Allow”,
“Action”: [
“lambda:UpdateFunctionCode”,
“lambda:GetFunctionConfiguration”
],
“Resource”: “*”
}
Security Tip: Use least privilege access and rotate secrets periodically.
Step 3: Create Your GitHub Actions Workflow
Inside your repository, create a .github/workflows/deploy.yml file.
Example: Deploy Python Lambda
name: Deploy to AWS Lambda
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
– name: Checkout code
uses: actions/checkout@v3
– name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ‘3.11’
– name: Install dependencies
run: |
pip install -r requirements.txt -t .
zip -r function.zip .
– name: Deploy to Lambda
uses: aws-actions/aws-cli-action@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
– name: Update Lambda function code
run: |
aws lambda update-function-code \
–function-name myLambdaFunction \
–zip-file fileb://function.zip
Replace myLambdaFunction and region values with your actual function name and region.
This setup deploys the code every time a commit is pushed to main. Adjust the trigger to suit your branch or tag strategy.
Step 4: Test and Monitor Your Deployments
Once configured:
- Commit and push your code
- GitHub Actions will run the workflow and deploy your function
- Monitor deployment success under the Actions tab in your GitHub repo
- Check AWS Lambda Console to confirm the updated code version
You can also validate functionality with:
- CloudWatch Logs for runtime errors
- Lambda Insights for performance profiling
Pro Tip: Integrate Slack or email notifications into your workflow for deployment alerts.
Step 5: Optional Enhancements for Enterprise CI/CD
For more robust deployment pipelines, consider adding:
- Environment-based deployments using tags, branches, or input parameters
- Manual approvals using GitHub Environments with wait_timer and reviewers
- Rollback strategies using Lambda versions and aliases
- Infrastructure as Code (e.g., Terraform or AWS CDK) for full deployment automation
Strategic Insight: Automating Lambda deployments via GitHub Actions enhances team velocity, reduces deployment friction, and supports DevSecOps best practices.
Final Thoughts
Deploying to AWS Lambda from GitHub Actions allows enterprises to embrace modern CI/CD practices while maintaining the agility and efficiency of serverless development. With a secure, automated pipeline in place, teams can ship code faster, more reliably, and with better visibility.