Skip to content

Commit 613c17c

Browse files
Added github actions to check Terraform code
1 parent 3beeea2 commit 613c17c

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

.github/workflows/terraform-ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 'Terraform-ci'
2+
3+
on: [push, pull_request]
4+
5+
defaults:
6+
run:
7+
shell: sh
8+
9+
jobs:
10+
# Terraform init and validate configuration
11+
terraform-init:
12+
name: 'Terraform-init'
13+
runs-on: ubuntu-latest
14+
environment: dev
15+
container:
16+
image: hashicorp/terraform:0.14.6
17+
env:
18+
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
- name: Terraform Init l1
23+
working-directory: ./terraform/layer1-aws
24+
run: terraform init -backend=false
25+
- name: Terraform Init l2
26+
working-directory: ./terraform/layer2-k8s
27+
run: terraform init -backend=false
28+
- name: Terraform Validate l1
29+
working-directory: ./terraform/layer1-aws
30+
run: terraform validate -no-color .
31+
- name: Terraform Validate l2
32+
working-directory: ./terraform/layer2-k8s
33+
run: terraform validate -no-color .
34+
35+
# Checks that all Terraform configuration files format
36+
terraform-format:
37+
name: 'Terraform-format'
38+
runs-on: ubuntu-latest
39+
environment: dev
40+
container:
41+
image: hashicorp/terraform:0.14.6
42+
env:
43+
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
- name: Terraform Format
48+
run: terraform fmt -recursive -write=false -check .
49+
50+
# Checks that all Terraform configuration files tflint
51+
terraform-tflint:
52+
name: 'Terraform-tflint'
53+
runs-on: ubuntu-latest
54+
environment: dev
55+
container:
56+
image: wata727/tflint
57+
env:
58+
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
- name: Terraform tflint l1
63+
working-directory: ./terraform/layer1-aws
64+
run: tflint --no-color
65+
- name: Terraform tflint l2
66+
working-directory: ./terraform/layer2-k8s
67+
run: tflint --no-color

terraform/modules/aws-ec2-pritunl/efs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ resource "aws_efs_file_system" "this" {
77
kms_key_id = var.kms_key_id
88

99
tags = {
10-
"Name" = var.name
11-
}
10+
"Name" = var.name
11+
}
1212
lifecycle {
1313
ignore_changes = [
1414
tags,
@@ -17,7 +17,7 @@ resource "aws_efs_file_system" "this" {
1717
}
1818

1919
resource "aws_efs_mount_target" "this" {
20-
count = length(var.public_subnets)
20+
count = length(var.public_subnets)
2121
file_system_id = aws_efs_file_system.this.id
2222
subnet_id = var.public_subnets[count.index]
2323
security_groups = [

0 commit comments

Comments
 (0)