-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (50 loc) · 1.58 KB
/
_terraform_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
59
60
61
62
name: Build docker images
on:
workflow_call:
inputs:
environment:
type: string
description: 'Github environment to use'
required: true
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
env:
ENV: ${{ vars.ENVIRONMENT }}
AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_VARS_BASE64: ${{ secrets.TF_VARS_BASE64 }}
TF_VAR_stack_version: ${{ github.sha }}
defaults:
run:
working-directory: deployment
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.9.7"
- name: mask tf variables
run: |
echo "${TF_VARS_BASE64}" \
| base64 --decode \
| jq 'to_entries | map(.value // empty) | .[]' \
| xargs -I{} echo '::add-mask::{}'
- name: tf init
run: |
terraform init \
-backend-config "bucket=data-inclusion-tf-states" \
-backend-config "key=${ENV}"
- name: tf validate
run: |
terraform validate
- name: tf plan
run: |
trap "rm -f terraform.tfvars.json" EXIT
echo "${TF_VARS_BASE64}" | base64 --decode > terraform.tfvars.json
terraform plan -input=false
- name: tf apply
run: |
trap "rm -f terraform.tfvars.json" EXIT
echo "${TF_VARS_BASE64}" | base64 --decode > terraform.tfvars.json
terraform apply -input=false -auto-approve