-
Notifications
You must be signed in to change notification settings - Fork 5
58 lines (50 loc) · 1.68 KB
/
zappa_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Deploy Zappa to AWS
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy with Zappa
runs-on: ubuntu-latest
environment: production
steps:
# Step 1: Check out code
- name: Checkout Code
uses: actions/checkout@v4
# Step 2: Set up Python version
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
# Step 3: Install Dependencies
- name: Install Dependencies
run: |
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install zappa
# Step 4: Create AWS Profile (Explicit Configuration)
- name: Create AWS Profile
run: |
mkdir -p ~/.aws
echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id=${{ secrets.AWS_ACCESS_KEY_ID }}" >> ~/.aws/credentials
echo "aws_secret_access_key=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials
echo "[default]" > ~/.aws/config
echo "region = ${{ secrets.AWS_REGION }}" >> ~/.aws/config
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
# Step 5: Validate AWS Credentials and Profile
- name: Validate AWS Configuration
run: |
aws configure list
aws sts get-caller-identity
# Step 6: Deploy/Update Zappa
- name: Deploy to AWS Lambda with Zappa
run: |
source .venv/bin/activate
zappa deploy dev || zappa update dev