-
Notifications
You must be signed in to change notification settings - Fork 61
109 lines (93 loc) · 2.65 KB
/
validate.yml
File metadata and controls
109 lines (93 loc) · 2.65 KB
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
name: Validate
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
terraform-validate:
name: Terraform Validate
runs-on: ubuntu-latest
strategy:
matrix:
terraform_version: ['1.3.0', '1.5.0', '1.9.0']
aws_provider_version: ['4.0.0', '5.0.0', '5.70.0']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform_version }}
- name: Create test versions.tf
run: |
cat > test_versions.tf << EOF
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> ${{ matrix.aws_provider_version }}"
}
}
}
EOF
- name: Terraform Format Check
run: terraform fmt -check=true -recursive
- name: Terraform Init
run: terraform init -backend=false
- name: Terraform Validate
run: terraform validate
- name: Cleanup
run: rm -f test_versions.tf
validate-examples:
name: Validate Examples
runs-on: ubuntu-latest
strategy:
matrix:
example: [
'simple_plan',
'complete_plan',
'selection_by_tags',
'selection_by_conditions',
'simple_plan_with_report',
'simple_plan_using_variables',
'simple_plan_using_lock_configuration',
'simple_plan_windows_vss_backup',
'organization_backup_policy',
'multiple_plans',
'aws_recommended_audit_framework',
'complete_audit_framework',
'simple_audit_framework'
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
- name: Terraform Format Check
run: |
if [ -d "examples/${{ matrix.example }}" ]; then
cd examples/${{ matrix.example }}
terraform fmt -check=true
fi
- name: Terraform Init
run: |
if [ -d "examples/${{ matrix.example }}" ]; then
cd examples/${{ matrix.example }}
terraform init -backend=false
fi
- name: Terraform Validate
run: |
if [ -d "examples/${{ matrix.example }}" ]; then
cd examples/${{ matrix.example }}
terraform validate
fi
- name: Terraform Plan
run: |
if [ -d "examples/${{ matrix.example }}" ]; then
cd examples/${{ matrix.example }}
terraform plan -out=tfplan
fi