-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (107 loc) · 3.01 KB
/
main.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Terraform
on:
push:
branches:
- master
- main
- dev
- feature/*
pull_request:
branches:
- feature/*
jobs:
# tflint-checks:
# name: TFLint Checks
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - uses: terraform-linters/setup-tflint@v2
# name: Setup TFLint
# with:
# tflint_version: v0.38.1
# - name: Show version
# run: tflint --version
# - name: Init TFLint
# run: tflint --init
# - name: Run TFLint
# run: tflint -f compact
# tfsec-checks:
# name: TFSec Checks
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Run Tfsec
# uses: aquasecurity/[email protected]
# with:
# soft_fail: true
terraform-plan:
name: Terraform Plan
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: "TerraformPlan"
- name: Setup Nodejs
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Plan
id: terraform-plan
run: |
./plan.sh
env:
TF_VAR_AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_TO_ASSUME }}
TF_STATE_BUCKET: ${{ secrets.TF_STATE_BUCKET }}
TF_STATE_KEY: ${{ secrets.TF_STATE_KEY }}
TF_STATE_REGION: ${{ secrets.AWS_REGION }}
TF_STATE_DYNAMODB_TABLE: ${{ secrets.TF_STATE_DYNAMODB_TABLE }}
# - name: Upload Plan
# uses: actions/upload-artifact@v3
# with:
# name: terraform-plan
# if-no-files-found: error
# path: |
# plan.out
# .terraform
# .terraform.lock.hcl
# terraform-apply:
# name: Terraform Apply
# needs: terraform-plan
# runs-on: ubuntu-latest
# permissions:
# id-token: write
# contents: read
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - uses: aws-actions/configure-aws-credentials@v1
# with:
# role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
# aws-region: ${{ secrets.AWS_REGION }}
# role-session-name: "TerraformPlan"
# - name: Setup Nodejs
# uses: actions/setup-node@v2
# with:
# node-version: '14'
# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v2
# - name: Download Plan
# uses: actions/download-artifact@v3
# with:
# name: terraform-plan
# - name: Terraform Apply
# id: terraform-apply
# run: |
# chmod -R a+x .terraform
# ./apply.sh