-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 1.84 KB
/
deployment.yaml
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
name: Deploy AWS Resources in Terraform
run-name: ${{ github.actor }} deployed the Terraform code to AWS.
on:
push:
branches:
- 'main'
jobs:
terraform:
runs-on: ubuntu-latest
env:
TF_VAR_vpc_id: ${{ secrets.VPC_ID }}
TF_VAR_domain: ${{ secrets.domain }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: format
id: fmt
run: terraform fmt -check
continue-on-error: true
working-directory: ./terraform
- name: initialize
id: init
run: |
terraform init \
-backend-config="access_key=$AWS_ACCESS_KEY_ID" \
-backend-config="secret_key=$AWS_SECRET_ACCESS_KEY" \
-backend-config="region=us-east-1"
working-directory: ./terraform
- name: validate
id: validate
run: terraform validate
working-directory: ./terraform
- name: plan
id: plan
run: terraform plan
working-directory: ./terraform
- name: apply
id: apply
run: terraform apply -auto-approve
working-directory: ./terraform
- name: get_url
id: get_url
run: echo "URL=$(terraform output -raw url)" >> $GITHUB_ENV
working-directory: ./terraform
- name: validate_config
id: validate_config
run: |
pip install requests bs4
python3 validate.py
working-directory: ./test
- name: destroy
id: destroy
run: terraform destroy --auto-approve
working-directory: ./terraform