diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..06df5fa --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,32 @@ +# based on: https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/master/.circleci/config.yml +version: 2 + +terraform: &terraform + docker: + - image: hashicorp/terraform:light + working_directory: /tmp/workspace/terraform + +jobs: + validate: + <<: *terraform + steps: + - checkout + - run: + name: change to terraform directory + command: cd terraform + - run: + name: Validate Terraform configurations + command: find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (terraform validate -check-variables=false "$m" && echo "√ $m") || exit 1 ; done + - run: + name: Check if Terraform configurations are properly formatted + command: tf=$(terraform fmt -write=false -diff); if [[ -n "$tf" ]]; then printf "$tf\n\n\nSome terraform files failed syntax validation, run 'terraform fmt' to fix\n\n"; exit 1; fi + - persist_to_workspace: + root: . + paths: . + +workflows: + version: 2 + build: + jobs: + - validate +