-
Notifications
You must be signed in to change notification settings - Fork 2
52 lines (45 loc) · 1.71 KB
/
tf-validate.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
name: Terraform IaC template validation for Jenkins
on:
workflow_dispatch:
pull_request:
branches: [master]
push:
branches: [master]
jobs:
tf_validate:
runs-on: ubuntu-latest
environment: ${{ vars.ENVIRONMENT }}
name: Configure AWS `ghactions` IAM user
steps:
- uses: actions/checkout@v3
- name: Create Terraform variables
run: |
cd root && touch prod.tfvars
echo region=${{ vars.AWS_REGION }} >> prod.tfvars
echo env=${{ vars.ENV }} >> prod.tfvars
echo vpc_cidr_block=${{ vars.VPC_CIDR_BLOCK }} >> prod.tfvars
echo public_route_table_cidr_block=${{ vars.PUBLIC_ROUTE_TABLE_CIDR_BLOCK }} >> prod.tfvars
echo public_subnets=${{ vars.PUBLIC_SUBNETS }} >> prod.tfvars
echo private_subnets=${{ vars.PRIVATE_SUBNETS }} >> prod.tfvars
echo root_account_ids=${{ secrets.AMI_USERS }} >> prod.tfvars
echo ami_prefix=${{ vars.AMI_USERS }} >> prod.tfvars
echo instance_type=${{vars.INSTANCE_TYPE}} >> prod.tfvars
echo domain_name=${{vars.DOMAIN_NAME}} >> prod.tfvars
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Setup `Terraform`
uses: hashicorp/setup-terraform@v2
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate