-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (77 loc) · 2.37 KB
/
cd.yml
File metadata and controls
95 lines (77 loc) · 2.37 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Continuous Deployment
on:
push:
branches:
- main
jobs:
create-lambda-layer-zip:
name: Create lambda layer zip
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python 3.8.1
uses: actions/setup-python@v2
with:
python-version: 3.8.1
- name: Install aws-xray-sdk
run: |
pip3 install aws-xray-sdk -t ./python
- name: Zip aws-xray-sdk
run: |
zip -r layer.zip ./python
- name: Upload layer.zip artifact
uses: actions/upload-artifact@v4
with:
name: layer
path: ./layer.zip
deploy-infra:
needs: create-lambda-layer-zip
name: Deploy Infrastructure w/ Terraform
runs-on: ubuntu-20.04
permissions:
contents: read
id-token: write
packages: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download layer.zip
uses: actions/download-artifact@v3
with:
name: layer
- name: Generate .auto.tfvars
run: |
echo "access_key=\"${{ secrets.AWS_ACCESS_KEY_ID }}\"" >> ./.auto.tfvars
echo "secret_key=\"${{ secrets.AWS_SECRET_ACCESS_KEY }}\"" >> ./.auto.tfvars
echo "---------------------------------------------------------"
cat ./.auto.tfvars
echo "---------------------------------------------------------"
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terrform format
id: fmt
run: terraform fmt -check
- name: Terraform Init
id: init
env:
TF_TOKEN: ${{ secrets.TF_API_TOKEN }}
run: terraform init
- name: Terraform validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
if: github.event_name == 'pull_request'
run: terraform plan -no-color -input=false
continue-on-error: true
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
run: terraform apply -auto-approve -input=false