-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (36 loc) · 1.15 KB
/
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
name: Deploy
on:
push:
branches:
- main
paths:
- 'terraform/**'
- '.github/workflows/deploy.yml'
- 'lambda_function/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Package Lambda function
run: |
cd lambda_function
zip -r ../terraform/lambda_function.zip . -x "venv/*"
echo "Lambda function zipped"
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
- name: Deploy infrastructure with Terraform
run: |
cd terraform
terraform init
terraform apply -auto-approve -var-file="terraform/variables.tfvars"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}