-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (49 loc) · 1.62 KB
/
terraform-deploy.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
name: Terraform-Deploy
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
- name: Terraform Format
run: terraform fmt -check
- name: Terraform Init
run: terraform init -input=false
- name: Terraform Validate
run: terraform validate -no-color
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_SECRET_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Terraform Apply
run: |
terraform apply \
-var="range_ssh_public_key=${{ secrets.RANGE_SSH_PUBLIC_KEY }}" \
-var="aws_region=${{ secrets.AWS_REGION }}" \
-input=false \
-auto-approve
# - name: Archive State
# if: always()
# uses: actions/upload-artifact@v2
# with:
# name: range-tf-state
# path: ./terraform.tfstate
# retention-days: 30
- name: Encrypt State
if: always()
run: |
echo "${{ secrets.COFC_SECURITY_GPG_PUBLIC_KEY }}" | gpg --import
gpg --trust-model always -er ${{ secrets.COFC_SECURITY_GPG_FINGERPRINT }} ./terraform.tfstate
- name: Archive State
if: always()
uses: actions/upload-artifact@v2
with:
name: range-tf-state-enc
path: ./terraform.tfstate.gpg
retention-days: 30