-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (81 loc) · 2.48 KB
/
terraform-plan-destroy.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Terraform Plan Destroy
on:
workflow_dispatch:
jobs:
plan:
environment: test
name: "Run Terraform Plan"
runs-on: ubuntu-20.04
env:
tf-version: 1.3.9
defaults:
run:
working-directory: .
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: ${{ env.tf-version }}
terraform_wrapper: true
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
- name: Terraform Init
id: init
run: terraform init -no-color
- name: Create Artifact Folder
shell: bash
run: |
sudo mkdir -p -m777 ${{ github.workspace }}/tfplanoutput
- name: Terraform Plan
id: plan
run: |
terraform plan -destroy -no-color -var-file=test-env.tfvars -out=${{ github.workspace }}/tfplanoutput/tf.plan
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: artifact
path: ${{ github.workspace }}/tfplanoutput/
if-no-files-found: error
apply:
name: "Run Terraform Apply"
needs: plan
runs-on: ubuntu-20.04
env:
tf-version: 1.3.9
environment: test
steps:
- name: 'Checkout'
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: ${{ env.tf-version }}
terraform_wrapper: true
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
- name: Terraform Init
id: init
run: terraform init -no-color
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: ${{ github.workspace }}/tfplanoutput
- name: Terraform Apply
id: apply
run: |
terraform apply -no-color -input=false ${{ github.workspace }}/tfplanoutput/tf.plan
- name: Terraform Output
id: output
run: |
terraform output