@@ -3,7 +3,7 @@ version: 2
3
3
jobs :
4
4
build :
5
5
docker :
6
- - image : hashicorp/terraform:0.11.2
6
+ - image : hashicorp/terraform:0.11.3
7
7
entrypoint : /bin/sh
8
8
steps :
9
9
- checkout
@@ -23,21 +23,43 @@ jobs:
23
23
- run :
24
24
name : " Install: tflint"
25
25
command : |
26
- apk add wget
27
- wget https://github.com/wata727/tflint/releases/download/v0.5.4/tflint_linux_amd64.zip
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}
28
31
unzip tflint_linux_amd64.zip
29
32
mkdir -p /usr/local/tflint/bin
30
- export PATH=/usr/local/tflint/bin:$PATH
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..."
31
36
install tflint /usr/local/tflint/bin
32
- # - run:
33
- # # Not supporting modules from registry ?? v0.5.4
34
- # name: "Check: tflint"
35
- # command: |
36
- # echo "Initializing terraform..."
37
- # terraform init -input=false
38
- # echo "Running tflint..."
39
- # /usr/local/tflint/bin/tflint --version
40
- # /usr/local/tflint/bin/tflint
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
+ echo "${module} = true"
47
+ done
48
+ echo "}}"
49
+ } > .tflint.hcl
50
+ fi
51
+ echo "tflint configuration:"
52
+ cat .tflint.hcl
53
+ - run :
54
+ # Not supporting modules from registry ?? v0.5.4
55
+ # For now, must ignore in config file
56
+ name : " Check: tflint"
57
+ command : |
58
+ #echo "Initializing terraform..."
59
+ #terraform init -input=false
60
+ echo "Running tflint..."
61
+ /usr/local/tflint/bin/tflint --version
62
+ /usr/local/tflint/bin/tflint
41
63
42
64
workflows :
43
65
version : 2
0 commit comments