Skip to content

Commit 989b57d

Browse files
committed
Add CircleCI. Fix formatting
1 parent 0f43130 commit 989b57d

File tree

6 files changed

+107
-13
lines changed

6 files changed

+107
-13
lines changed

.circleci/config.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
docker:
6+
- image: hashicorp/terraform:0.11.3
7+
entrypoint: /bin/sh
8+
steps:
9+
- checkout
10+
- run:
11+
name: "Validate tf files (terraform validate)"
12+
command: |
13+
find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (terraform validate -check-variables=false "$m" && echo "√ $m") || exit 1 ; done
14+
- run:
15+
name: "Check: Terraform formatting (terraform fmt)"
16+
command: |
17+
if [ `terraform fmt --list=true -diff=true -write=false | tee format-issues | wc -c` -ne 0 ]; then
18+
echo "Some terraform files need be formatted, run 'terraform fmt' to fix"
19+
echo "Formatting issues:"
20+
cat format-issues
21+
exit 1
22+
fi
23+
- run:
24+
name: "Install: tflint"
25+
command: |
26+
apk add jq wget
27+
# Get latest version of tflint
28+
pkg_arch=linux_amd64
29+
dl_url=$(curl -s https://api.github.com/repos/wata727/tflint/releases/latest | jq -r ".assets[] | select(.name | test(\"${pkg_arch}\")) | .browser_download_url")
30+
wget ${dl_url}
31+
unzip tflint_linux_amd64.zip
32+
mkdir -p /usr/local/tflint/bin
33+
# Setup PATH for later run steps - ONLY for Bash and not in Bash
34+
#echo 'export PATH=/usr/local/tflint/bin:$PATH' >> $BASH_ENV
35+
echo "Installing tflint..."
36+
install tflint /usr/local/tflint/bin
37+
echo "Configuring tflint..."
38+
tf_ver=$(terraform version | awk 'FNR <= 1' | cut -dv -f2)
39+
echo -e "\tConfig for terraform version: ${tf_ver}"
40+
if [ -f '.tflint.hcl' ]; then
41+
sed -i "/terraform_version =/s/\".*\"/\"${tf_ver}\"/" .tflint.hcl
42+
else
43+
{
44+
echo -e "config {\nterraform_version = \"${tf_ver}\"\ndeep_check = true\nignore_module = {"
45+
for module in $(grep -h '[^a-zA-Z]source[ =]' *.tf | sed -r 's/.*=\s+//' | sort -u); do
46+
# if not ^"../
47+
echo "${module} = true"
48+
done
49+
echo "}}"
50+
} > .tflint.hcl
51+
fi
52+
echo "tflint configuration:"
53+
cat .tflint.hcl
54+
- run:
55+
# Not supporting modules from registry ?? v0.5.4
56+
# For now, must ignore in config file
57+
name: "Check: tflint"
58+
command: |
59+
#echo "Initializing terraform..."
60+
#terraform init -input=false
61+
echo "Running tflint..."
62+
/usr/local/tflint/bin/tflint --version
63+
/usr/local/tflint/bin/tflint
64+
65+
workflows:
66+
version: 2
67+
build:
68+
jobs:
69+
- build

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![CircleCI](https://circleci.com/gh/devops-workflow/terraform-aws-efs.svg?style=svg)](https://circleci.com/gh/devops-workflow/terraform-aws-efs)
2+
13
# terraform-aws-efs
24

35
Terraform module to provision an AWS [`EFS`](https://aws.amazon.com/efs/) Network File System.

main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ module "label" {
2525
}
2626

2727
resource "aws_efs_file_system" "default" {
28-
count = "${module.enabled.value}"
29-
performance_mode = "${var.performance_mode}"
30-
encrypted = "${var.encrypted}"
31-
kms_key_id = "${var.kms_key_id}"
32-
tags = "${module.label.tags}"
28+
count = "${module.enabled.value}"
29+
performance_mode = "${var.performance_mode}"
30+
encrypted = "${var.encrypted}"
31+
kms_key_id = "${var.kms_key_id}"
32+
tags = "${module.label.tags}"
3333
}
3434

3535
resource "aws_efs_mount_target" "default" {
@@ -45,6 +45,7 @@ resource "aws_security_group" "default" {
4545
description = "EFS Access"
4646
vpc_id = "${var.vpc_id}"
4747
tags = "${module.label.tags}"
48+
4849
lifecycle {
4950
create_before_destroy = true
5051
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ output "dns_name" {
33
description = ""
44
value = "${element(concat(aws_efs_file_system.default.*.dns_name, list("")),0)}"
55
}
6+
67
output "id" {
78
description = "ID of EFS"
89
value = "${element(concat(aws_efs_file_system.default.*.id, list("")),0)}"
910
}
11+
1012
output "kms_key_id" {
1113
description = ""
1214
value = "${element(concat(aws_efs_file_system.default.*.kms_key_id, list("")),0)}"
@@ -24,10 +26,12 @@ output "mount_target_ids" {
2426
description = "List of IDs of the EFS mount targets"
2527
value = ["${aws_efs_mount_target.default.*.id}"]
2628
}
29+
2730
output "mount_target_ips" {
2831
description = "List of IPs of the EFS mount targets"
2932
value = ["${aws_efs_mount_target.default.*.ip_address}"]
3033
}
34+
3135
output "mount_target_net_intf_ids" {
3236
description = "List of network interface IDs of the EFS mount targets"
3337
value = ["${aws_efs_mount_target.default.*.id}"]

test/main.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
module "efs" {
2-
source = "../"
3-
name = "efs-vol"
4-
environment = "testing"
5-
organization = ""
2+
source = "../"
3+
name = "efs-vol"
4+
environment = "testing"
5+
organization = ""
6+
67
#attributes = ["role", "policy", "use", ""]
78
#tags = "${map("Key", "Value")}"
8-
zone_id = "ZURF67XJUWC5A" # one
9+
zone_id = "ZURF67XJUWC5A" # one
10+
911
security_groups = []
10-
subnets = ["subnet-857efce3","subnet-0852f140","subnet-6395c038"]
11-
vpc_id = "vpc-417c0027" # one
12+
subnets = ["subnet-857efce3", "subnet-0852f140", "subnet-6395c038"]
13+
vpc_id = "vpc-417c0027" # one
14+
1215
#enabled = false
1316
}
1417

1518
# Test:
1619
# enabled = false
20+

variables.tf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
1-
21
// Variables specific to module label
32
variable "attributes" {
43
description = "Suffix name with additional attributes (policy, role, etc.)"
54
type = "list"
65
default = []
76
}
7+
88
variable "delimiter" {
99
description = "Delimiter to be used between `name`, `namespaces`, `attributes`, etc."
1010
type = "string"
1111
default = "-"
1212
}
13+
1314
variable "environment" {
1415
description = "Environment (ex: dev, qa, stage, prod)"
1516
type = "string"
1617
}
18+
1719
variable "name" {
1820
description = "Base name for resource"
1921
type = "string"
2022
}
23+
2124
variable "namespace-env" {
2225
description = "Prefix name with the environment"
2326
default = true
2427
}
28+
2529
variable "namespace-org" {
2630
description = "Prefix name with the organization. If both env and org namespaces are used, format will be <org>-<env>-<name>"
2731
default = false
2832
}
33+
2934
variable "organization" {
3035
description = "Organization name"
3136
type = "string"
3237
default = ""
3338
}
39+
3440
variable "tags" {
3541
description = "A map of additional tags to add"
3642
type = "map"
@@ -43,6 +49,7 @@ variable "dns_ttl" {
4349
type = "string"
4450
default = "60"
4551
}
52+
4653
variable "zone_id" {
4754
description = "Route53 DNS zone ID"
4855
type = "string"
@@ -54,34 +61,41 @@ variable "enabled" {
5461
description = "Set to false to prevent the module from creating anything"
5562
default = true
5663
}
64+
5765
variable "encrypted" {
5866
description = "If true, the disk will be encrypted"
5967
type = "string"
6068
default = "false"
6169
}
70+
6271
variable "kms_key_id" {
6372
description = "ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true"
6473
type = "string"
6574
default = ""
6675
}
76+
6777
variable "performance_mode" {
6878
description = "The file system performance mode. Can be either generalPurpose or maxIO"
6979
type = "string"
7080
default = "generalPurpose"
7181
}
82+
7283
variable "region" {
7384
description = "AWS region"
7485
type = "string"
7586
default = ""
7687
}
88+
7789
variable "security_groups" {
7890
description = "AWS security group IDs to allow to connect to the EFS"
7991
type = "list"
8092
}
93+
8194
variable "subnets" {
8295
description = "AWS subnet IDs"
8396
type = "list"
8497
}
98+
8599
variable "vpc_id" {
86100
description = "AWS VPC ID"
87101
type = "string"

0 commit comments

Comments
 (0)