Skip to content

Commit 607cbb3

Browse files
committed
Add CircleCI. Fix formatting
1 parent 004f320 commit 607cbb3

File tree

9 files changed

+353
-122
lines changed

9 files changed

+353
-122
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# terraform-aws-alb
23
A Terraform module containing common configurations for an AWS new style Load
34
Balancer (ALB/NLB). Available through the [terraform registry](https://registry.terraform.io/modules/devops-workflow/lb/aws).
@@ -6,7 +7,8 @@ Balancer (ALB/NLB). Available through the [terraform registry](https://registry.
67

78
| Branch | Build status |
89
| --- | --- |
9-
| master | [![build Status](https://travis-ci.org/terraform-aws-modules/terraform-aws-alb.svg?branch=master)](https://travis-ci.org/terraform-aws-modules/terraform-aws-alb) |
10+
| master | [![CircleCI](https://circleci.com/gh/devops-workflow/terraform-aws-alb.svg?style=svg)](https://circleci.com/gh/devops-workflow/terraform-aws-alb) |
11+
| master | [![TravisCI](https://travis-ci.org/terraform-aws-modules/terraform-aws-alb.svg?branch=master)](https://travis-ci.org/terraform-aws-modules/terraform-aws-alb) |
1012

1113
## Assumptions
1214
* You want to create a set of resources for the ALB: namely an associated target group and listener.

examples/test_fixtures/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ module "security-group" {
3939

4040
module "lb" {
4141
source = "../.."
42-
lb_name = "my-lb"
43-
lb_security_groups = ["${module.security-group.this_security_group_id}"]
42+
lb_name = "my-lb"
43+
lb_security_groups = ["${module.security-group.this_security_group_id}"]
4444
region = "${var.region}"
4545
vpc_id = "${module.vpc.vpc_id}"
4646
subnets = "${module.vpc.public_subnets}"
4747
certificate_arn = "${aws_iam_server_certificate.fixture_cert.arn}"
48-
lb_protocols = ["HTTPS"]
48+
lb_protocols = ["HTTPS"]
4949
health_check_path = "/"
5050
create_log_bucket = true
5151
enable_logging = true

0 commit comments

Comments
 (0)