-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.sh
executable file
·66 lines (61 loc) · 1.57 KB
/
tests.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -euo pipefail
echo "****************************"
echo "*** executability checks ***"
echo "****************************"
ansible --version
aws --version
aws-vault --version
docker --version
pre-commit --version
terraform --version
terraform-docs --version
tflint --version
echo "[OK]"
echo
echo "*************************"
echo "*** aws and aws-vault ***"
echo "*************************"
export AWS_CONFIG_FILE=aws-config
cat > aws-config << EOF
[default]
region = eu-central-1
EOF
aws configure list
export AWS_VAULT_BACKEND=file
aws-vault list
rm -rf aws-config ~/.awsvault
echo "[OK]"
echo
echo "******************************************"
echo "*** pre-commit, tflint, terraform-docs ***"
echo "*** and terraform ***"
echo "******************************************"
cat > main.tf << EOF
# tflint-ignore: terraform_required_providers, terraform_required_version
resource "null_resource" "test" {
}
EOF
cat > .pre-commit-config.yaml << EOF
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.81.0
hooks:
- id: terraform_fmt
- id: terraform_docs
EOF
# pre-commit requires valid git repo. Recreate it in case it does not exist
[[ -d .git ]] || git init
pre-commit run
tflint --filter=main.tf
terraform-docs markdown . > /dev/null
terraform init
terraform apply -auto-approve
rm -rf \
.cache .pre-commit-config.yaml \
.terraform .terraform.d terraform.tfstate main.tf
echo "[OK]"
echo
echo "***********************************"
echo "*** All tests were successful! ****"
echo "***********************************"